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

1696129594811

上级 3d9b39ed
/*!
browserDOMOperation.js
date 1694313016757 [Sun Sep 10 2023 10:30:16 GMT+0800 (China Standard Time)]
date 1696129594811 [Sun Oct 01 2023 11:06:34 GMT+0800 (China Standard Time)]
(c) 2023 Bright_Leader
Licensed under the Apache-2.0.
*/
......@@ -396,14 +396,14 @@ const String_constructor=new Object_constructor("")[constructor_key],
const String_prototype=String_constructor[prototype_key];
const Object_toString=Object_prototype.toString;
(function(){ /* module: tests whether the browser is under Content-Security-Policy restrictions */
objectToExport.cspUnsafeEval=function(){
const String_match=String_prototype.match;
const Object_toString=Object_prototype.toString;
return function(){ /* "script-src" CSP directive test */
let tempFunction;
try{
......@@ -523,7 +523,7 @@ const definePropertyIsFunction=isFunction(defineProperty);
const tryES5CreateNullPrototypeObject=function(){
const create=Object_constructor.create; /* http://262.ecma-international.org/5.1/#sec-15.2.3.5 */
const create=Object_constructor.create;
const createIsFunction=isFunction(create);
return function(){
......@@ -538,11 +538,62 @@ const createIsFunction=isFunction(create);
};
}();
const createNullPrototypeArrayLikeObject=function(){
const newObject=tryES5CreateNullPrototypeObject();
const args=arguments;
const len=args[length_key];
tryES5DefineProperty(
newObject,
length_key,len,
True,False,False
);
let i_var;
for(i_var=0;i_var<len;i_var+=1)tryES5DefineProperty(
newObject,
i_var,
args[i_var],
True,True,True
);
return newObject;
};
const assignMultipleProperties=function(target,keys,values,writable,enumerable,configurable){
returnOrThrowObjectType(target);
returnOrThrowObjectType(keys);
returnOrThrowObjectType(values);
let i_var,len;
for(
i_var=0,
len=toLength(keys[length_key]);
i_var<len;
i_var+=1
)(
Function_call[call_key](Object_hasOwnProperty,keys,i_var)&&
Function_call[call_key](Object_hasOwnProperty,values,i_var)&&
tryES5DefineProperty(target,keys[i_var],values[i_var],writable,enumerable,configurable)
);
return target;
};
const valueOf_key="valueOf";
const Object_valueOf=Object_prototype[valueOf_key];
const toObject=function(value){
return returnOrThrowObjectType(
Function_call[call_key](Object_valueOf,value)
);
};
/* some array-like methods */
const arrayLikeFindIndex=function(predicate,predicateThisArg){
returnOrThrowFunction(predicate);
const self=new Object_constructor(this);
const self=toObject(this);
const len=toLength(self[length_key]);
const predicateThisArgIsNullish=isNullish(predicateThisArg);
let key,value;
......@@ -558,7 +609,7 @@ const arrayLikeFindIndex=function(predicate,predicateThisArg){
const arrayLikeFilter=function(callbackFn,callbackFnThisArg){
returnOrThrowFunction(callbackFn);
const self=new Object_constructor(this);
const self=toObject(this);
const callbackFnThisArgIsNullish=isNullish(callbackFnThisArg);
const len=toUint32(self[length_key]);
let k_var,t_var,v_var;
......@@ -585,7 +636,7 @@ const arrayLikeFilter=function(callbackFn,callbackFnThisArg){
const arrayLikeMap=function(callbackFn,callbackFnThisArg){
returnOrThrowFunction(callbackFn);
const self=new Object_constructor(this);
const self=toObject(this);
const len=toUint32(self[length_key]);
const newArray=new Array_constructor(len);
const callbackFnThisArgIsNullish=isNullish(callbackFnThisArg);
......@@ -610,7 +661,7 @@ const arrayLikeMap=function(callbackFn,callbackFnThisArg){
const arrayLikeForEach=function(callbackFn,callbackFnThisArg){
returnOrThrowFunction(callbackFn);
const self=new Object_constructor(this);
const self=toObject(this);
let key,value;
const callbackFnThisArgIsNullish=isNullish(callbackFnThisArg);
const len=toUint32(self[length_key]);
......@@ -626,7 +677,7 @@ const arrayLikeForEach=function(callbackFn,callbackFnThisArg){
};
const arrayLikeIndexOf=function(searchElement,fromIndex){
const self=new Object_constructor(this);
const self=toObject(this);
const len=toUint32(self[length_key]);
if(len===0)return -1;
const n_var=isNullish(fromIndex)?0:forceToInteger(fromIndex);
......@@ -648,7 +699,7 @@ const arrayLikeIndexOf=function(searchElement,fromIndex){
const arrayLikeEvery=function(callbackFn,callbackFnThisArg){
returnOrThrowFunction(callbackFn);
const self=new Object_constructor(this);
const self=toObject(this);
const len=toUint32(self[length_key]);
const callbackFnThisArgIsNullish=isNullish(callbackFnThisArg);
let k_var,v_var;
......@@ -666,7 +717,7 @@ const arrayLikeEvery=function(callbackFn,callbackFnThisArg){
const arrayLikeSome=function(callbackFn,callbackFnThisArg){
returnOrThrowFunction(callbackFn);
const self=new Object_constructor(this);
const self=toObject(this);
const len=toUint32(self[length_key]);
const callbackFnThisArgIsNullish=isNullish(callbackFnThisArg);
let key,value;
......@@ -699,7 +750,7 @@ const defineDontEnumProperty=function(target,key,value){
return tryES5DefineProperty(target,key,value,True,False,True);
};
const IteratorResult=function(){ /* http://262.ecma-international.org/6.0/#sec-iteratorresult-interface */
const IteratorResult=function(){
const value_key="value",
done_key="done";
......@@ -789,8 +840,6 @@ const key_itemKind="key",
value_itemKind="value",
key_plus_value_itemKind="key+value";
const valueOf_key="valueOf";
const ArrayIterator=function(){
const constructorFn=function(array,kind){
......@@ -817,7 +866,7 @@ tryES5DefineProperty(
constructorFn_prototype,
iterator_wellKnownSymbol,
Object_prototype[valueOf_key],
Object_valueOf,
False,False,False
);
......@@ -901,7 +950,7 @@ defineDontEnumProperty(
const arrayLike_entries_keys_values_maker=function(iterationKind){
return function(){
return new ArrayIterator(
new Object_constructor(this),
toObject(this),
iterationKind
);
};
......@@ -1242,42 +1291,13 @@ const helperFunction=function(firstArgument,laterArguments){
};
}();
const assignMultipleProperties=function(){
const returnOrThrowArray=returnOrThrow_makeFunction(
isArray,
function(value){
return(
"\x22"+
value+
"\x22 (type:\x20"+
(value!==null?typeof value:value)+
") is not an array!"
);
}
);
return function(target,keys,values,writable,enumerable,configurable){
returnOrThrowObjectType(target);
returnOrThrowArray(keys);
returnOrThrowArray(values);
let i_var,len;
for(i_var=0,len=keys[length_key];i_var<len;i_var+=1)(
Function_call[call_key](Object_hasOwnProperty,keys,i_var)&&
Function_call[call_key](Object_hasOwnProperty,values,i_var)&&
tryES5DefineProperty(target,keys[i_var],values[i_var],writable,enumerable,configurable)
);
return target;
};
}();
const reference_key="reference",
isArrayLike_key="isArrayLike";
const reference_uniqueSymbol=createUniqueSymbol(reference_key),
isArrayLike_uniqueSymbol=createUniqueSymbol(isArrayLike_key);
const InnerConstructor=function(){
const DOMOperation=function(){
function constructorRequireNewError(value){
return(
......@@ -1314,8 +1334,8 @@ function constructorRequireNewError(value){
};
}();
const InnerConstructor_prototype=tryES5DefineProperty(
InnerConstructor[prototype_key],
const DOMOperation_prototype=tryES5DefineProperty(
DOMOperation[prototype_key],
length_key,0,
......@@ -1323,16 +1343,16 @@ const InnerConstructor_prototype=tryES5DefineProperty(
);
assignMultipleProperties(
InnerConstructor_prototype,
DOMOperation_prototype,
[
createNullPrototypeArrayLikeObject(
reference_uniqueSymbol,
isArrayLike_uniqueSymbol
],
[
),
createNullPrototypeArrayLikeObject(
null,
False
],
),
True,False,True
);
......@@ -1420,7 +1440,7 @@ const bDocument_createElement=returnOrThrowFunction(bDocument_prototype.createEl
let tempKey;
defineDontEnumProperty(
InnerConstructor_prototype,
DOMOperation_prototype,
tempKey="attributesSetter",
instanceMethodDecorator0_DOMOperation(isElement,attributesSetter)
);
......@@ -1428,7 +1448,7 @@ defineDontEnumProperty(
objectToExport[tempKey]=attributesSetter;
defineDontEnumProperty(
InnerConstructor_prototype,
DOMOperation_prototype,
tempKey="smartSetDOMProperties",
instanceMethodDecorator0_DOMOperation(isObjectType,smartSetDOMProperties)
);
......@@ -1468,20 +1488,25 @@ const functionToReturn=function(num){
objectToExport.isValidNodeType=functionToReturn;
functionToReturn.validValues=[
ELEMENT_NODE_nodeType,
ATTRIBUTE_NODE_nodeType,
TEXT_NODE_nodeType,
CDATA_SECTION_NODE_nodeType,
ENTITY_REFERENCE_NODE_nodeType,
ENTITY_NODE_nodeType,
PROCESSING_INSTRUCTION_NODE_nodeType,
COMMENT_NODE_nodeType,
DOCUMENT_NODE_nodeType,
DOCUMENT_TYPE_NODE_nodeType,
DOCUMENT_FRAGMENT_NODE_nodeType,
NOTATION_NODE_nodeType
];
functionToReturn.validValues=Function_call[call_key](
Function_apply,
createNullPrototypeArrayLikeObject,
null,
[
ELEMENT_NODE_nodeType,
ATTRIBUTE_NODE_nodeType,
TEXT_NODE_nodeType,
CDATA_SECTION_NODE_nodeType,
ENTITY_REFERENCE_NODE_nodeType,
ENTITY_NODE_nodeType,
PROCESSING_INSTRUCTION_NODE_nodeType,
COMMENT_NODE_nodeType,
DOCUMENT_NODE_nodeType,
DOCUMENT_TYPE_NODE_nodeType,
DOCUMENT_FRAGMENT_NODE_nodeType,
NOTATION_NODE_nodeType
]
);
return functionToReturn;
}();
......@@ -1719,7 +1744,7 @@ const removeSiblings=function(targetNode,spareLeft,spareRight){
let tempKey;
defineDontEnumProperty(
InnerConstructor_prototype,
DOMOperation_prototype,
tempKey="removeAllChildren",
instanceMethodDecorator1_DOMOperation(isNode,removeAllChildren)
);
......@@ -1750,16 +1775,21 @@ const tempValue0=instanceMethodDecorator0_DOMOperation(
);
const tempValue1=function(){
return [
TEXT_NODE_nodeType,
CDATA_SECTION_NODE_nodeType,
COMMENT_NODE_nodeType,
ATTRIBUTE_NODE_nodeType,
PROCESSING_INSTRUCTION_NODE_nodeType,
ELEMENT_NODE_nodeType,
DOCUMENT_FRAGMENT_NODE_nodeType,
DOCUMENT_NODE_nodeType
];
return Function_call[call_key](
Function_apply,
createNullPrototypeArrayLikeObject,
null,
[
TEXT_NODE_nodeType,
CDATA_SECTION_NODE_nodeType,
COMMENT_NODE_nodeType,
ATTRIBUTE_NODE_nodeType,
PROCESSING_INSTRUCTION_NODE_nodeType,
ELEMENT_NODE_nodeType,
DOCUMENT_FRAGMENT_NODE_nodeType,
DOCUMENT_NODE_nodeType
]
);
};
tempKey0="validValues";
......@@ -1768,7 +1798,7 @@ tempValue0[tempKey0]=tempValue1();
safeModifyNodeText[tempKey0]=tempValue1();
defineDontEnumProperty(
InnerConstructor_prototype,
DOMOperation_prototype,
tempKey0="safeModifyNodeText",
tempValue0
);
......@@ -1779,7 +1809,7 @@ objectToExport[tempKey0]=safeModifyNodeText;
})();
defineDontEnumProperty(
InnerConstructor_prototype,
DOMOperation_prototype,
tempKey="removeSelfFromParentNode",
instanceMethodDecorator1_DOMOperation(isNode,removeSelfFromParentNode)
);
......@@ -1787,7 +1817,7 @@ defineDontEnumProperty(
objectToExport[tempKey]=removeSelfFromParentNode;
defineDontEnumProperty(
InnerConstructor_prototype,
DOMOperation_prototype,
tempKey="removeSiblings",
instanceMethodDecorator0_DOMOperation(isNode,removeSiblings)
);
......@@ -1876,7 +1906,7 @@ objectToExport.smartStopPropagation=function(eventObject){
let tempKey;
defineDontEnumProperty(
InnerConstructor_prototype,
DOMOperation_prototype,
tempKey="smartAddEventListener",
instanceMethodDecorator0_DOMOperation(isObjectType,smartAddEventListener)
);
......@@ -1884,7 +1914,7 @@ defineDontEnumProperty(
objectToExport[tempKey]=smartAddEventListener;
defineDontEnumProperty(
InnerConstructor_prototype,
DOMOperation_prototype,
tempKey="smartPreventDefault",
instanceMethodDecorator0_DOMOperation(isObjectType,smartPreventDefault)
);
......@@ -2150,7 +2180,7 @@ const instanceMethodDecorator2_DOMOperation=(function decorator(checkFunction,op
let tempKey;
defineDontEnumProperty(
InnerConstructor_prototype,
DOMOperation_prototype,
tempKey="smartAddClasses",
instanceMethodDecorator2_DOMOperation(isObjectType,smartAddClasses)
);
......@@ -2158,7 +2188,7 @@ defineDontEnumProperty(
objectToExport[tempKey]=smartAddClasses;
defineDontEnumProperty(
InnerConstructor_prototype,
DOMOperation_prototype,
tempKey="removeAllClasses",
instanceMethodDecorator1_DOMOperation(isObjectType,removeAllClasses)
);
......@@ -2166,7 +2196,7 @@ defineDontEnumProperty(
objectToExport[tempKey]=removeAllClasses;
defineDontEnumProperty(
InnerConstructor_prototype,
DOMOperation_prototype,
tempKey="smartRemoveClasses",
instanceMethodDecorator2_DOMOperation(isObjectType,smartRemoveClasses)
);
......@@ -2174,7 +2204,7 @@ defineDontEnumProperty(
objectToExport[tempKey]=smartRemoveClasses;
defineDontEnumProperty(
InnerConstructor_prototype,
DOMOperation_prototype,
tempKey="setClassAttribute",
instanceMethodDecorator0_DOMOperation(isObjectType,setClassAttribute)
);
......@@ -2186,25 +2216,31 @@ objectToExport[tempKey]=setClassAttribute;
(function(){ /* module: element style manipulation */
const changeElementStyle=staticMethodDecorator0(function(target,propertyName,value){
let temp;
const changeElementStyle=function(){
const helperFunction=staticMethodDecorator0(function(target,key,value){
(
(temp="style") in returnOrThrowObjectType(target)&&
isObjectType(temp=target[temp])&&
propertyName in temp&&
(
temp[propertyName]=(
isFunction(value)?value(target,propertyName):value
)
)
key in returnOrThrowObjectType(target)&&
(target[key]=value)
);
return;
});
return function(target,keys,values){
let temp;
(
(temp="style") in returnOrThrowObjectType(target)&&
isObjectType(temp=target[temp])&&
helperFunction(temp,keys,values)
);
return target;
};
}();
const tempKey="changeElementStyle";
defineDontEnumProperty(
InnerConstructor_prototype,
DOMOperation_prototype,
tempKey,
instanceMethodDecorator0_DOMOperation(isObjectType,changeElementStyle)
);
......@@ -2247,7 +2283,7 @@ hence this must be checked before other operations.
})();
defineDontEnumProperty(
InnerConstructor_prototype,
DOMOperation_prototype,
"toArray",
function(){
return Function_call[call_key](Array_slice,this);
......@@ -2255,73 +2291,73 @@ defineDontEnumProperty(
);
defineDontEnumProperty(
InnerConstructor_prototype,
DOMOperation_prototype,
valueOf_key,
function(){
const self=this;
return isNumber(self)?self:toUint32(
new Object_constructor(self)[length_key]
return forceToInteger(
isObjectType(self)?self[length_key]:self
);
}
);
defineDontEnumProperty(
InnerConstructor_prototype,
DOMOperation_prototype,
"findIndex",arrayLikeFindIndex
);
defineDontEnumProperty(
InnerConstructor_prototype,
DOMOperation_prototype,
"filter",arrayLikeFilter
);
defineDontEnumProperty(
InnerConstructor_prototype,
DOMOperation_prototype,
"map",arrayLikeMap
);
defineDontEnumProperty(
InnerConstructor_prototype,
DOMOperation_prototype,
"forEach",arrayLikeForEach
);
defineDontEnumProperty(
InnerConstructor_prototype,
DOMOperation_prototype,
"indexOf",arrayLikeIndexOf
);
defineDontEnumProperty(
InnerConstructor_prototype,
DOMOperation_prototype,
"every",arrayLikeEvery
);
defineDontEnumProperty(
InnerConstructor_prototype,
DOMOperation_prototype,
"some",arrayLikeSome
);
defineDontEnumProperty(
InnerConstructor_prototype,
DOMOperation_prototype,
"entries",arrayLikeEntries
);
defineDontEnumProperty(
InnerConstructor_prototype,
DOMOperation_prototype,
"keys",arrayLikeKeys
);
defineDontEnumProperty(
InnerConstructor_prototype,
DOMOperation_prototype,
"values",arrayLikeValues
);
defineDontEnumProperty(
InnerConstructor_prototype,
DOMOperation_prototype,
iterator_wellKnownSymbol,arrayLikeValues
);
defineDontEnumProperty(
InnerConstructor_prototype,
DOMOperation_prototype,
isConcatSpreadable_wellKnownSymbol,True
);
......@@ -2331,7 +2367,7 @@ objectToExport.createTextNode=createTextNode;
objectToExport.isNode=isNode;
objectToExport.isNotANodeError=isNotANodeError;
objectToExport.DOMOperation=InnerConstructor;
objectToExport.DOMOperation=DOMOperation;
objectToExport.IteratorResult=IteratorResult;
objectToExport.ArrayIterator=ArrayIterator;
......@@ -2391,19 +2427,20 @@ objectToExport.arrayLikeEntries=arrayLikeEntries;
objectToExport.arrayLikeKeys=arrayLikeKeys;
objectToExport.arrayLikeValues=arrayLikeValues;
objectToExport.createNullPrototypeArrayLikeObject=createNullPrototypeArrayLikeObject;
objectToExport.assignMultipleProperties=assignMultipleProperties;
assignMultipleProperties(
objectToExport,
[
createNullPrototypeArrayLikeObject(
"author",
"date"
],
[
),
createNullPrototypeArrayLikeObject(
"Bright_Leader",
1694313016757
],
1696129594811
),
True,False,True
);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册