【发布时间】:2022-01-05 04:37:17
【问题描述】:
有人可以从这个repository向我解释以下几行:
defineProperties(Element.prototype, {
querySelector: {
value: querySelectorPatched,
writable: true,
enumerable: true,
configurable: true,
},
querySelectorAll: {
value(this: HTMLBodyElement): NodeListOf<Element> {
const nodeList = arrayFromCollection(
elementQuerySelectorAll.apply(this, ArraySlice.call(arguments) as [string])
);
if (!featureFlags.ENABLE_NODE_LIST_PATCH) {
const filteredResults = getFilteredArrayOfNodes(
this,
nodeList,
ShadowDomSemantic.Disabled
);
return createStaticNodeList(filteredResults);
}
return createStaticNodeList(
getFilteredArrayOfNodes(this, nodeList, ShadowDomSemantic.Enabled)
);
},
writable: true,
enumerable: true,
configurable: true,
},
});
具体这部分:
value(this: HTMLBodyElement): NodeListOf<Element>
这是什么语法,有什么用途?
【问题讨论】:
-
这个语法是typescript
标签: javascript