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

20230608

上级 83a9e094
此差异已折叠。
/*!
DOMOperation.js
date 1685085340815 [Fri May 26 2023 15:15:40 GMT+0800 (China Standard Time)]
date 1686210071353 [Thu Jun 08 2023 15:41:11 GMT+0800 (China Standard Time)]
(c) 2023 Bright_Leader
Licensed under the Apache-2.0.
dependenc(y/ies):
- Bright.js date >= 1685064723739
- Bright.js date >= 1686188991871
*/
(function exportFunction(globalObject,factory){"use strict";
/*
......@@ -404,30 +404,6 @@ const isDocument=function(value){
);
};
(function(){ /* module: checking some common node types */
objectToExport.isText=function(){
const bText=bwindow.Text; /* http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-1312295772 */
return function(value){
let key,key0;
return(
value instanceof bText&&
(key=nodeType_key) in value&&
value[key]===TEXT_NODE_nodeType&&
(key=nodeName_key) in value&&
value[key]==="#text"&&
(key=nodeValue_key) in value&&
(key0="data") in value&&
value[key]===value[key0]
);
};
}();
return;
})();
const attributes_key="attributes";
const isElement=function(value){
......@@ -444,14 +420,84 @@ const isElement=function(value){
);
};
const length_key="length";
const bdocument=bwindow.document;
const createTextNode=function(){ /* module: text node creation and manipulation */
const bDocument_createTextNode=bDocument_prototype.createTextNode;
const bText=bwindow.Text; /* http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-1312295772 */
const bTextIsFunction=isFunction(bText); /* false on Internet Explorer 9-11 */
const isTextNode=function(value){
let key,key0;
return(
value instanceof bText&&
isArrayLike(value)&&
(key=nodeType_key) in value&&
value[key]===TEXT_NODE_nodeType&&
(key=nodeName_key) in value&&
value[key]==="#text"&&
(key=nodeValue_key) in value&&
(key0="data") in value&&
value[key]===value[key0]
);
};
function isNotATextNodeError(value){
return(
"\x22"+
value+
"\x22 (type:\x20"+
(value!==null?typeof value:value)+
") is not a text node ( http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-1312295772 )!"
);
}
const bText_prototype=bText[prototype_key];
const bText_splitText=bText_prototype.splitText;
const splitTextNode=function(textNode,offset){
if(isPrimitive(textNode))throw valueIsPrimitiveError(textNode);
if(!isTextNode(textNode))throw isNotATextNodeError(textNode);
return Function_call[call_key](
bText_splitText,
textNode,
offset
);
};
objectToExport.smartSplitTextNode=function(){
const roundInteger=returnOrThrowFunction(BrightObject.roundInteger);
return function(textNode,offset){
if(isPrimitive(textNode))throw valueIsPrimitiveError(textNode);
return splitTextNode(
textNode,
roundInteger(0,textNode[length_key]-1,offset)
);
};
}();
objectToExport.isTextNode=isTextNode;
objectToExport.isNotATextNodeError=isNotATextNodeError;
objectToExport.splitTextNode=splitTextNode;
return function(contents){
return bTextIsFunction?new bText(contents):Function_call[call_key](bDocument_createTextNode,bdocument,contents);
};
}();
const arrayLikeFindIndex=returnOrThrowFunction(BrightObject.arrayLikeFindIndex),
arrayLikeFilter=returnOrThrowFunction(BrightObject.arrayLikeFilter);
const bElement_getAttribute=bElement_prototype.getAttribute,
bDocument_getElementsByTagName=bDocument_prototype.getElementsByTagName,
bDocument_createTextNode=bDocument_prototype.createTextNode;
const bdocument=bwindow.document;
bDocument_getElementsByTagName=bDocument_prototype.getElementsByTagName;
(function(){ /* module: some static functions for elements search and creation */
......@@ -527,15 +573,13 @@ objectToExport.getElementsByName=function(nameName,customDocument){
return getElementsByTagName;
}();
objectToExport.createTextNode=function(contents){
return Function_call[call_key](bDocument_createTextNode,bdocument,contents);
};
objectToExport.createDocumentFragment=function(){
const bDocument_createDocumentFragment=bDocument_prototype.createDocumentFragment,
bDocumentFragment=bwindow.DocumentFragment; /* http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-B63ED1A3 */
const bDocumentFragmentIsFunction=isFunction(bDocumentFragment);
objectToExport.isDocumentFragment=function(value){
let key;
return(
......@@ -549,10 +593,8 @@ objectToExport.isDocumentFragment=function(value){
);
};
return isFunction(bDocumentFragment)?function(){
return new bDocumentFragment();
}:function(){ /* This function is for Internet Explorer 9-11. */
return Function_call[call_key](bDocument_createDocumentFragment,bdocument);
return function(){
return bDocumentFragmentIsFunction?new bDocumentFragment():Function_call[call_key](bDocument_createDocumentFragment,bdocument);
};
}();
......@@ -569,8 +611,6 @@ function isNotAnElementError(value){
);
}
const length_key="length";
const staticMethodFunction0=function(actionFunction){
returnOrThrowFunction(actionFunction);
......@@ -733,15 +773,23 @@ function constructorRequireNewError(value){
};
}();
const InnerConstructor_prototype=assignMultipleProperties(
InnerConstructor[prototype_key],
const InnerConstructor_prototype=InnerConstructor[prototype_key];
tryES5DefineProperty(
InnerConstructor_prototype,
length_key,0,
True,False,False
);
assignMultipleProperties(
InnerConstructor_prototype,
[
length_key,
reference_key,
isArrayLike_key
],
[
0,
null,
False
],
......@@ -980,9 +1028,7 @@ const safeModifyNodeText=(function selfFn(target,text){
Function_call[call_key](
bNode_appendChild,
target,
Function_call[call_key](
bDocument_createTextNode,
bdocument,
createTextNode(
isFunction(text)?text(target,target_nodeType):text
)
);
......@@ -1646,152 +1692,7 @@ hence this must be checked before other operations.
return;
})();
function throwUnsupportedFeature(){
throw "This feature is unsupported!";
}
(function(){ /* module: native ECMAScript array methods implementation */
objectToExport.arrayMethodsImplementation=function(){
const arrayMethodsImplementation_errorMessage0=function(value){
return(
"Can not implement methods to \x22"+
Function_call[call_key](Object_toString,value)+
"\x22!"
);
};
const arrayMethodsImplementation=function(){
function getArrayMethodNames(){
return [
"toString", /* These two methods are not generic in ECMAScript 3. */
"toLocaleString",
"concat", /* ECMAScript 3 */
"join",
"pop",
"push",
"reverse",
"shift",
"slice",
"sort",
"splice",
"unshift",
"indexOf", /* ECMAScript 5 */
"lastIndexOf",
"every",
"some",
"forEach",
"map",
"filter",
"reduce",
"reduceRight",
"copyWithin", /* ECMAScript 6 */
"entries",
"fill",
"find",
"findIndex",
"keys",
"values",
"includes" /* ECMAScript 7 */
];
/*
- ECMA-262, 7th edition, June 2016
http://262.ecma-international.org/7.0/index.html
http://www.ecma-international.org/wp-content/uploads/ECMA-262_7th_edition_june_2016.pdf
*/
}
function getSymbolKeys(){
return [
"iterator",
"unscopables"
];
}
function isSymbol(value){
return typeof value==="symbol";
}
const nativeSymbol=bwindow.Symbol;
const nativeSymbolIsFunction=isFunction(nativeSymbol);
return function(target,writable,enumerable,configurable){
if(isPrimitive(target))throw valueIsPrimitiveError(target);
if(
target===Array_prototype||
target===Array_constructor
)throw arrayMethodsImplementation_errorMessage0(target);
let i_var,tempArray,len,j0,j1,j2,j3;
for(
i_var=0,
len=(tempArray=getArrayMethodNames())[length_key];
i_var<len;
i_var+=1
)tryES5DefineProperty(
target,
j0=tempArray[i_var],
isFunction(j1=Array_prototype[j0])?j1:throwUnsupportedFeature,
writable,enumerable,configurable
);
for(
i_var=0,
len=(tempArray=getSymbolKeys())[length_key];
i_var<len;
i_var+=1
){
j0=tempArray[i_var];
j2=(
nativeSymbolIsFunction&&
isSymbol(j1=nativeSymbol[j0])&&
j1 in Array_prototype
);
tryES5DefineProperty(
target,
"Symbol."+j0,
j2?(j3=Array_prototype[j1]):throwUnsupportedFeature,
writable,enumerable,configurable
);
j2&&tryES5DefineProperty(
target,
j1,j3,
writable,enumerable,configurable
);
}
(i_var=length_key) in target||tryES5DefineProperty(
target,
i_var,0,
writable,enumerable,configurable
);
i_var=tempArray=len=j0=j1=j2=j3=null;
return target;
};
}();
arrayMethodsImplementation(InnerConstructor_prototype,True,False,True);
return arrayMethodsImplementation;
}();
(function(){
defineDontEnumProperty(
InnerConstructor_prototype,
......@@ -1804,16 +1705,29 @@ defineDontEnumProperty(
return;
})();
function throwUnsupportedFeature(){
throw "This feature is unsupported!";
}
(function(){
let tempFunction;
try{
throwUnsupportedFeature();
}catch(err){
throwUnsupportedFeature.message=err;
}
let tempKey;
(
isFunction(tempFunction=BrightObject.exportInstanceMethods)&&
tempFunction(InnerConstructor_prototype,True,False,True)
defineDontEnumProperty(
InnerConstructor_prototype,
tempKey="unsupportedFeature",
throwUnsupportedFeature
);
tempFunction=null;
objectToExport[tempKey]=throwUnsupportedFeature;
tempKey=null;
return;
})();
......@@ -1898,6 +1812,7 @@ tempResult=null;
objectToExport.isDocument=isDocument;
objectToExport.isElement=isElement;
objectToExport.createTextNode=createTextNode;
objectToExport.isNode=isNode;
objectToExport.isNotAnElementError=isNotAnElementError;
......@@ -1905,28 +1820,7 @@ objectToExport.isNotANodeError=isNotANodeError;
objectToExport.DOMOperation=InnerConstructor;
(function(){
try{
throwUnsupportedFeature();
}catch(err){
throwUnsupportedFeature.message=err;
}
let tempKey;
defineDontEnumProperty(
InnerConstructor_prototype,
tempKey="unsupportedFeature",
throwUnsupportedFeature
);
objectToExport[tempKey]=throwUnsupportedFeature;
tempKey=null;
return;
})();
objectToExport.assignMultipleProperties=assignMultipleProperties;
(function(){
......@@ -1940,13 +1834,12 @@ function sharedKeys(){
function sharedValues(){
return [
"Bright_Leader",
1685085340815
1686210071353
];
}
assignMultipleProperties(objectToExport,sharedKeys(),sharedValues(),True,False,True);
assignMultipleProperties(InnerConstructor_prototype,sharedKeys(),sharedValues(),True,False,True);
objectToExport.assignMultipleProperties=assignMultipleProperties;
return;
})();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册