Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (!featureFlags.ENABLE_NODE_LIST_PATCH) {
// `this` is a manually inserted element inside a shadowRoot, return the first element.
return nodeList.length === 0 ? null : nodeList[0];
}
// Element is inside a shadow but we dont know which one. Use the
// "nearest" owner key to filter by ownership.
const contextNearestOwnerKey = getNodeNearestOwnerKey(this);
const elm = ArrayFind.call(
nodeList,
elm => getNodeNearestOwnerKey(elm) === contextNearestOwnerKey
);
return isUndefined(elm) ? null : elm;
}
} else {
if (!featureFlags.ENABLE_NODE_LIST_PATCH) {
if (!(this instanceof HTMLBodyElement)) {
const elm = nodeList[0];
return isUndefined(elm) ? null : elm;
}
}
// element belonging to the document
const elm = ArrayFind.call(
nodeList,
// TODO [#1222]: remove global bypass
elm => isUndefined(getNodeOwnerKey(elm)) || isGlobalPatchingSkipped(this)
);
return isUndefined(elm) ? null : elm;
}
}
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,</element>