提交 4ebbb2e1 编写于 作者: MengZian's avatar MengZian

20230717

上级 4f667b48
此差异已折叠。
/*!
DOMOperation.js
date 1687494211485 [Fri Jun 23 2023 12:23:31 GMT+0800 (China Standard Time)]
date 1689559121327 [Mon Jul 17 2023 09:58:41 GMT+0800 (China Standard Time)]
(c) 2023 Bright_Leader
Licensed under the Apache-2.0.
dependenc(y/ies):
- Bright.js date >= 1687485630671
- Bright.js date >= 1689498007161
*/
(function exportFunction(globalObject,factory){"use strict";
/*
......@@ -35,9 +35,9 @@ http://www.ecma-international.org/wp-content/uploads/ECMA-262_6th_edition_june_2
*/
const typeFunction="function";
const isPrimitive=function(value){
const isObjectType=function(value){
const typeOfValue=typeof value;
return !value||(typeOfValue!=="object"&&typeOfValue!==typeFunction);
return !!value&&(typeOfValue==="object"||typeOfValue===typeFunction);
};
const returnOrThrowObjectType=function(){
......@@ -53,13 +53,16 @@ http://www.ecma-international.org/wp-content/uploads/ECMA-262_6th_edition_june_2
}
return function(value){
if(isPrimitive(value))throw valueIsPrimitiveError(value);
else return value;
if(isObjectType(value))return value;
else throw valueIsPrimitiveError(value);
};
}();
returnOrThrowObjectType(globalObject);
const False=false,
True=true;
const constructor_key="constructor",
prototype_key="prototype";
......@@ -121,9 +124,14 @@ http://www.ecma-international.org/wp-content/uploads/ECMA-262_6th_edition_june_2
const name="DOMOperation";
const relinquish_key="relinquish",
useRequireJS_key="useRequireJS",
source_key="source",
isAsynchronous_key="isAsynchronous";
let var0,
isAsynchronous;
isAsynchronous=False;
/* eslint {
"no-undef": [
"error",
......@@ -136,23 +144,23 @@ http://www.ecma-international.org/wp-content/uploads/ECMA-262_6th_edition_june_2
ESLint [ http://eslint.org/ ] configurations
*/
let define_,
isAsynchronous;
const useRequireJS=(
typeof define===typeFunction&& /* eslint-disable-line no-undef */
typeof (define_=define)===typeFunction&& /* eslint-disable-line no-undef */
typeof requirejs===typeFunction&& /* eslint-disable-line no-undef */
!isPrimitive(define_.amd)
); /* RequireJS included? [ http://requirejs.org/ ] (based on version 2.0.4 [ http://requirejs.org/docs/release/2.0.4/comments/require.js ] ) */
isAsynchronous=false;
useRequireJS?(
define_(
(
(typeof
define /* eslint-disable-line no-undef */
===typeFunction)&&
(typeof (var0=
define /* eslint-disable-line no-undef */
)===typeFunction)&&
(typeof
requirejs /* eslint-disable-line no-undef */
===typeFunction)&&
isObjectType(var0.amd) /* RequireJS included? [ http://requirejs.org/ ] (based on version 2.0.4 [ http://requirejs.org/docs/release/2.0.4/comments/require.js ] ) */
)?(
var0(
["exports",dep0],
function(exports){
returnOrThrowObjectType(exports)[relinquish_key]=relinquishFunction(exports,name,globalObject);
exports[useRequireJS_key]=useRequireJS;
exports[source_key]="RequireJS [ http://requirejs.org/ ]";
exports[isAsynchronous_key]=isAsynchronous;
name in globalObject||(globalObject[name]=exports);
const dependencies=tryES5CreateNullPrototypeObject();
......@@ -163,14 +171,15 @@ ESLint [ http://eslint.org/ ] configurations
):(globalObject[name]=function(){
const product=tryES5CreateNullPrototypeObject();
product[relinquish_key]=relinquishFunction(product,name,globalObject);
product[useRequireJS_key]=useRequireJS;
product[source_key]="this";
product[isAsynchronous_key]=isAsynchronous;
const dependencies=tryES5CreateNullPrototypeObject();
dependencies[dep0]=globalObject[dep0];
let tempKey;
dependencies[tempKey=dep0]=globalObject[tempKey];
return factory(product,globalObject,dependencies);
}());
isAsynchronous=true;
isAsynchronous=True;
return;
})(
this,
......@@ -230,11 +239,11 @@ function isObjectType(value){
return !!value&&(typeOfValue==="object"||typeOfValue==="function");
}
function isEmpty(value){
function isNullish(value){
return value===void null||value===null;
}
function isNotEmpty(value){
function isNotNullish(value){
return value!==null&&value!==void null;
}
......@@ -247,7 +256,7 @@ const constructor_key="constructor",
const False=false,
True=true;
const Function_constructor=isPrimitive[constructor_key],
const Function_constructor=factoryFunction[constructor_key],
Object_constructor={}[constructor_key],
Array_constructor=[][constructor_key];
const Function_prototype=Function_constructor[prototype_key],
......@@ -263,6 +272,24 @@ function isFunction(value){
return typeof value==="function";
}
const returnOrThrowFunction=function(){
function notAFunctionError(value){
return(
"\x22"+
value+
"\x22 (type:\x20"+
(value!==null?typeof value:value)+
") is not a function!"
);
}
return function(value){
if(isFunction(value))return value;
else throw notAFunctionError(value);
};
}();
const isArray=function(value){
return isObjectType(value)&&value[constructor_key]===Array_constructor;
};
......@@ -293,7 +320,7 @@ const String_match=String_prototype.match;
);
}catch(err){
return(
isEmpty(tempFunction)&&
isNullish(tempFunction)&&
isObjectType(err)&&
(
isArray(
......@@ -334,7 +361,7 @@ function xmlEntitiesFilterFn(match){
const String_replace=String_prototype.replace;
return function(str){
return isNotEmpty(str)?Function_call[call_key](
return isNotNullish(str)?Function_call[call_key](
String_replace,
str, /*
Passing an empty value (undefined or null) here will result in
......@@ -353,24 +380,6 @@ The reson behind this is here: [ http://262.ecma-international.org/5.1/#sec-9.10
return;
})();
const returnOrThrowFunction=function(){
function notAFunctionError(value){
return(
"\x22"+
value+
"\x22 (type:\x20"+
(value!==null?typeof value:value)+
") is not a function!"
);
}
return function(value){
if(isFunction(value))return value;
else throw notAFunctionError(value);
};
}();
const isArrayLike=function(){
const isArrayLike_Bright=returnOrThrowFunction(BrightObject.isArrayLike);
......@@ -398,12 +407,12 @@ const isPlainObject_Bright=returnOrThrowFunction(BrightObject.isPlainObject);
/* browser native item(s) */
/* Document Object Model (DOM) Level 1 Specification [ http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/ ] */
const bElement=bwindow.Element, /* http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-745549614 */
bDocument=bwindow.Document, /* http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#i-Document */
bNode=bwindow.Node; /* http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-1950641247 */
const bElement_prototype=bElement[prototype_key],
bDocument_prototype=bDocument[prototype_key],
bNode_prototype=bNode[prototype_key];
const bElement=returnOrThrowObjectType(bwindow.Element), /* http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-745549614 */
bDocument=returnOrThrowObjectType(bwindow.Document), /* http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#i-Document */
bNode=returnOrThrowObjectType(bwindow.Node); /* http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-1950641247 */
const bElement_prototype=returnOrThrowObjectType(bElement[prototype_key]),
bDocument_prototype=returnOrThrowObjectType(bDocument[prototype_key]),
bNode_prototype=returnOrThrowObjectType(bNode[prototype_key]);
const ELEMENT_NODE_nodeType=bNode_prototype.ELEMENT_NODE||1,
ATTRIBUTE_NODE_nodeType=bNode_prototype.ATTRIBUTE_NODE||2,
......@@ -798,7 +807,7 @@ function constructorRequireNewError(value){
return function constructorFn(target,dontRefer){
const self=this;
if(!(self instanceof constructorFn))throw constructorRequireNewError(constructorFn);
if(isEmpty(target))return self;
if(isNullish(target))return self;
let i_var,len;
if(isArrayLike(target)){
len=target[length_key];
......@@ -853,7 +862,7 @@ objectToExport.attributesGetter=function(target,names){
returnOrThrowElement(
returnOrThrowObjectType(target)
);
if(isEmpty(names))return target[attributes_key];
if(isNullish(names))return target[attributes_key];
else if(isPrimitive(names))return Function_call[call_key]( /* single get */
bElement_getAttribute,
target,
......@@ -878,7 +887,7 @@ const bElement_removeAttribute=bElement_prototype.removeAttribute;
returnOrThrowObjectType(targetElement)
);
Function_call[call_key](
isNotEmpty(attributeValue)?bElement_setAttribute:bElement_removeAttribute, /* Supplying the third argument with null or undefined allows you to remove that attribute. */
isNotNullish(attributeValue)?bElement_setAttribute:bElement_removeAttribute, /* Supplying the third argument with null or undefined allows you to remove that attribute. */
targetElement,
attributeName,
isFunction(attributeValue)?attributeValue(targetElement,attributeName):attributeValue /*
......@@ -1150,6 +1159,8 @@ const bNode_replaceChild=bNode_prototype.replaceChild;
};
}();
const nextSibling_key="nextSibling";
(function(){
const bNode_insertBefore=bNode_prototype.insertBefore;
......@@ -1183,7 +1194,7 @@ objectToExport.insertNodeAfter=function(nodeToInsert,referenceNode){
isNode(referenceNode_parentNode=referenceNode[parentNode_key])&&(
(
referenceNode_parentNode.lastChild!==referenceNode&&
isNode(referenceNode_nextSibling=referenceNode.nextSibling)
isNode(referenceNode_nextSibling=referenceNode[nextSibling_key])
)?Function_call[call_key](
bNode_insertBefore,
referenceNode_parentNode,
......@@ -1217,6 +1228,24 @@ const bNode_cloneNode=bNode_prototype.cloneNode;
};
}();
const removeSiblings=function(targetNode,spareLeft,spareRight){
let parentNode,
siblingNode;
if(isNode(parentNode=returnOrThrowNode(
returnOrThrowObjectType(targetNode)
)[parentNode_key])){
if(!spareLeft){
while(isNode(siblingNode=targetNode.previousSibling))
Function_call[call_key](bNode_removeChild,parentNode,siblingNode);
}
if(!spareRight){
while(isNode(siblingNode=targetNode[nextSibling_key]))
Function_call[call_key](bNode_removeChild,parentNode,siblingNode);
}
}
return targetNode;
};
let tempKey;
defineDontEnumProperty(
......@@ -1287,6 +1316,14 @@ defineDontEnumProperty(
objectToExport[tempKey]=removeSelfFromParentNode;
defineDontEnumProperty(
InnerConstructor_prototype,
tempKey="removeSiblings",
instanceMethodDecorator0_DOMOperation(isNode,removeSiblings)
);
objectToExport[tempKey]=removeSiblings;
return;
})();
......@@ -1405,7 +1442,7 @@ const Boolean_constructor=False[constructor_key];
This function returns an array.
It can be regarded as an enhanced version of "String.prototype.split".
*/
if(isEmpty(originalString))return new Array_constructor();
if(isNullish(originalString))return new Array_constructor();
const resultArray=Function_call[call_key](
String_split,
originalString,
......@@ -1427,8 +1464,8 @@ const Array_concat=Array_prototype.concat;
return function(originalString,delimiter,newContents,needFiltering){
if(
isEmpty(originalString)||
isEmpty(newContents)
isNullish(originalString)||
isNullish(newContents)
)return "";
let result,key;
result=segmentStringWithDelimiter(originalString,delimiter,needFiltering);
......@@ -1603,7 +1640,7 @@ const Array_splice=Array_prototype.splice;
className
);
if(
isNotEmpty(indexFound)&&
isNotNullish(indexFound)&&
indexFound>-1
){
Function_call[call_key](Array_splice,classNames,indexFound,1);
......@@ -1768,96 +1805,21 @@ defineDontEnumProperty(
}
);
return;
})();
function throwUnsupportedFeature(){
throw "This feature is unsupported!";
}
try{
throwUnsupportedFeature();
}catch(err){
throwUnsupportedFeature.message=err;
}
objectToExport.unsupportedFeature=throwUnsupportedFeature;
(function(){ /* optional module: querySelector */
/* Please test whether this is supported before using! */
objectToExport.documentQuerySelector=function(){
const bDocument_querySelector=bDocument_prototype.querySelector;
return isFunction(bDocument_querySelector)?function(selector,customDocument){
return Function_call[call_key](
bDocument_querySelector,
isDocument(customDocument)?customDocument:bdocument,
selector
);
}:throwUnsupportedFeature;
}();
return;
})();
(function(){ /* optional module: querySelectorAll */
objectToExport.documentQuerySelectorAll=function(){
const bDocument_querySelectorAll=bDocument_prototype.querySelectorAll;
return isFunction(bDocument_querySelectorAll)?function(selector,customDocument){
return Function_call[call_key](
bDocument_querySelectorAll,
isDocument(customDocument)?customDocument:bdocument,
selector
);
}:throwUnsupportedFeature;
}();
return;
})();
(function(){ /* optional module: XML and HTML string parser */
let bDOMParser,
bDOMParser_prototype,
bDOMParser_parseFromString;
defineDontEnumProperty(
InnerConstructor_prototype,
"array",
function(){
const prefix="text/";
const implementArrayLikeMethods=returnOrThrowFunction(BrightObject.implementArrayLikeMethods);
const isAvailable=(
isFunction(bDOMParser=bwindow.DOMParser)&&
isObjectType(bDOMParser_prototype=bDOMParser[prototype_key])&&
isFunction(bDOMParser_parseFromString=bDOMParser_prototype.parseFromString)
return function(){
const self=this;
isObjectType(self)&&implementArrayLikeMethods(self);
return self;
};
}()
);
objectToExport.stringToXML=isAvailable?function(str){
return Function_call[call_key](
bDOMParser_parseFromString,
new bDOMParser(),
str,
prefix+"xml"
);
}:throwUnsupportedFeature;
objectToExport.stringToHTML=isAvailable?function(str){
return Function_call[call_key](
bDOMParser_parseFromString,
new bDOMParser(),
str,
prefix+"html"
);
}:throwUnsupportedFeature;
isAvailable||(bDOMParser=bDOMParser_prototype=bDOMParser_parseFromString=null); /*
We have to release references of these variables
because earlier evaluations may get stuck in process.
*/
return;
})();
......@@ -1882,7 +1844,7 @@ function sharedKeys(){
function sharedValues(){
return [
"Bright_Leader",
1687494211485
1689559121327
];
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册