Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
get(this: Element): string {
if (!featureFlags.ENABLE_ELEMENT_PATCH) {
if (isNodeShadowed(this) || isHostElement(this)) {
return innerHTMLGetterPatched.call(this);
}
return innerHTMLGetter.call(this);
}
// TODO [#1222]: remove global bypass
if (isGlobalPatchingSkipped(this)) {
return innerHTMLGetter.call(this);
}
return innerHTMLGetterPatched.call(this);
},
set(v: string) {
get(this: Element): string {
if (!featureFlags.ENABLE_ELEMENT_PATCH) {
if (isNodeShadowed(this) || isHostElement(this)) {
return outerHTMLGetterPatched.call(this);
}
return outerHTMLGetter.call(this);
}
// TODO [#1222]: remove global bypass
if (isGlobalPatchingSkipped(this)) {
return outerHTMLGetter.call(this);
}
return outerHTMLGetterPatched.call(this);
},
set(v: string) {
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;
}
}
get(this: Node): string {
if (!featureFlags.ENABLE_NODE_PATCH) {
if (isNodeShadowed(this) || isHostElement(this)) {
return textContentGetterPatched.call(this);
}
return textContentGetter.call(this);
}
// TODO [#1222]: remove global bypass
if (isGlobalPatchingSkipped(this)) {
return textContentGetter.call(this);
}
return textContentGetterPatched.call(this);
},
set: textContentSetterPatched,
value(this: Node, otherNode: Node): boolean {
if (!featureFlags.ENABLE_NODE_PATCH) {
if (otherNode == null) {
return false;
}
if (isNodeShadowed(this) || isHostElement(this)) {
return containsPatched.call(this, otherNode);
}
return contains.call(this, otherNode);
}
// TODO [#1222]: remove global bypass
if (isGlobalPatchingSkipped(this)) {
return contains.call(this, otherNode);
}
return containsPatched.call(this, otherNode);
const vmBeingRendered = getVMBeingRendered();
assert.invariant(
!isInvokingRender,
`${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString(
key
)}`
);
assert.invariant(
!isUpdatingTemplate,
`Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString(
key
)}`
);
}
if (set) {
if (features.ENABLE_REACTIVE_SETTER) {
let ro = vm.oar[key as any] as AccessorReactiveObserver;
if (isUndefined(ro)) {
ro = vm.oar[key as any] = new AccessorReactiveObserver(vm, set);
}
// every time we invoke this setter from outside (through this wrapper setter)
// we should reset the value and then debounce just in case there is a pending
// invocation the next tick that is not longer relevant since the value is changing
// from outside.
ro.reset(newValue);
ro.observe(() => {
set.call(this, newValue);
});
} else {
set.call(this, newValue);
}
} else if (process.env.NODE_ENV !== 'production') {
value(this: HTMLBodyElement): HTMLCollectionOf<element> {
const elements = arrayFromCollection(
elementGetElementsByClassName.apply(
this,
ArraySlice.call(arguments) as [string]
)
) as Element[];
if (!featureFlags.ENABLE_HTML_COLLECTIONS_PATCH) {
return createStaticHTMLCollection(
getNonPatchedFilteredArrayOfNodes(this, elements)
);
}
const filteredResults = getFilteredArrayOfNodes(
this,
elements,
ShadowDomSemantic.Enabled
);
return createStaticHTMLCollection(filteredResults);
},
writable: true,</element>
value(this: HTMLBodyElement): HTMLCollectionOf<element> {
const elements = arrayFromCollection(
elementGetElementsByTagName.apply(this, ArraySlice.call(arguments) as [string])
) as Element[];
if (!featureFlags.ENABLE_HTML_COLLECTIONS_PATCH) {
return createStaticHTMLCollection(
getNonPatchedFilteredArrayOfNodes(this, elements)
);
}
const filteredResults = getFilteredArrayOfNodes(
this,
elements,
ShadowDomSemantic.Enabled
);
return createStaticHTMLCollection(filteredResults);
},
writable: true,</element>
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>