How to use the @lwc/features.ENABLE_NODE_LIST_PATCH function in @lwc/features

To help you get started, we’ve selected a few @lwc/features examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github salesforce / lwc / packages / @lwc / synthetic-shadow / src / faux-shadow / element.ts View on Github external
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;
    }
}
github salesforce / lwc / packages / @lwc / synthetic-shadow / src / faux-shadow / element.ts View on Github external
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>