@lwc/synthetic-shadow 6.3.3 → 6.4.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/env/node.d.ts +2 -1
- package/dist/index.cjs.js +23 -8
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +23 -8
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/env/node.d.ts
CHANGED
@@ -31,5 +31,6 @@ declare const ownerDocumentGetter: (this: Node) => Document | null;
|
|
31
31
|
declare const parentElementGetter: (this: Node) => Element | null;
|
32
32
|
declare const textContextSetter: (this: Node, s: string) => void;
|
33
33
|
declare const childNodesGetter: (this: Node) => NodeListOf<Node & Element>;
|
34
|
+
declare const nextSiblingGetter: (this: Node) => ChildNode | null;
|
34
35
|
declare const isConnected: () => any;
|
35
|
-
export { _Node as Node, appendChild, childNodesGetter, cloneNode, compareDocumentPosition, insertBefore, isConnected, parentElementGetter, parentNodeGetter, removeChild, replaceChild, textContextSetter, ownerDocumentGetter, hasChildNodes, contains, firstChildGetter, lastChildGetter, textContentGetter, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_PRECEDING, DOCUMENT_POSITION_FOLLOWING, ELEMENT_NODE, TEXT_NODE, CDATA_SECTION_NODE, PROCESSING_INSTRUCTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, };
|
36
|
+
export { _Node as Node, appendChild, childNodesGetter, cloneNode, compareDocumentPosition, insertBefore, isConnected, parentElementGetter, parentNodeGetter, removeChild, replaceChild, textContextSetter, ownerDocumentGetter, hasChildNodes, contains, firstChildGetter, lastChildGetter, textContentGetter, nextSiblingGetter, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_PRECEDING, DOCUMENT_POSITION_FOLLOWING, ELEMENT_NODE, TEXT_NODE, CDATA_SECTION_NODE, PROCESSING_INSTRUCTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, };
|
package/dist/index.cjs.js
CHANGED
@@ -210,7 +210,7 @@ const KEY__LEGACY_SHADOW_TOKEN_PRIVATE = '$$LegacyShadowTokenKey$$';
|
|
210
210
|
const KEY__SYNTHETIC_MODE = '$$lwc-synthetic-mode';
|
211
211
|
const KEY__NATIVE_GET_ELEMENT_BY_ID = '$nativeGetElementById$';
|
212
212
|
const KEY__NATIVE_QUERY_SELECTOR_ALL = '$nativeQuerySelectorAll$';
|
213
|
-
/** version: 6.
|
213
|
+
/** version: 6.4.0 */
|
214
214
|
|
215
215
|
/**
|
216
216
|
* Copyright (c) 2024 Salesforce, Inc.
|
@@ -218,7 +218,7 @@ const KEY__NATIVE_QUERY_SELECTOR_ALL = '$nativeQuerySelectorAll$';
|
|
218
218
|
if (!globalThis.lwcRuntimeFlags) {
|
219
219
|
Object.defineProperty(globalThis, 'lwcRuntimeFlags', { value: create(null) });
|
220
220
|
}
|
221
|
-
/** version: 6.
|
221
|
+
/** version: 6.4.0 */
|
222
222
|
|
223
223
|
/*
|
224
224
|
* Copyright (c) 2018, salesforce.com, inc.
|
@@ -241,6 +241,7 @@ const ownerDocumentGetter = getOwnPropertyDescriptor(nodePrototype, 'ownerDocume
|
|
241
241
|
const parentElementGetter = getOwnPropertyDescriptor(nodePrototype, 'parentElement').get;
|
242
242
|
const textContextSetter = getOwnPropertyDescriptor(nodePrototype, 'textContent').set;
|
243
243
|
const childNodesGetter = getOwnPropertyDescriptor(nodePrototype, 'childNodes').get;
|
244
|
+
const nextSiblingGetter = getOwnPropertyDescriptor(nodePrototype, 'nextSibling').get;
|
244
245
|
const isConnected = hasOwnProperty.call(nodePrototype, 'isConnected')
|
245
246
|
? getOwnPropertyDescriptor(nodePrototype, 'isConnected').get
|
246
247
|
: function () {
|
@@ -427,6 +428,8 @@ function getNodeNearestOwnerKey(node) {
|
|
427
428
|
return hostKey;
|
428
429
|
}
|
429
430
|
host = parentNodeGetter.call(host);
|
431
|
+
// Elements slotted from top level light DOM into synthetic shadow
|
432
|
+
// reach the slot tag from the shadow element first
|
430
433
|
if (!isNull(host) && isSyntheticSlotElement(host)) {
|
431
434
|
return undefined;
|
432
435
|
}
|
@@ -1227,7 +1230,11 @@ function cloneNodePatched(deep) {
|
|
1227
1230
|
function childNodesGetterPatched() {
|
1228
1231
|
if (isSyntheticShadowHost(this)) {
|
1229
1232
|
const owner = getNodeOwner(this);
|
1230
|
-
const
|
1233
|
+
const filteredChildNodes = getFilteredChildNodes(this);
|
1234
|
+
// No need to filter by owner for non-shadowed nodes
|
1235
|
+
const childNodes = isNull(owner)
|
1236
|
+
? filteredChildNodes
|
1237
|
+
: getAllMatches(owner, filteredChildNodes);
|
1231
1238
|
return createStaticNodeList(childNodes);
|
1232
1239
|
}
|
1233
1240
|
// nothing to do here since this does not have a synthetic shadow attached to it
|
@@ -3356,7 +3363,11 @@ function shadowRootGetterPatched() {
|
|
3356
3363
|
}
|
3357
3364
|
function childrenGetterPatched() {
|
3358
3365
|
const owner = getNodeOwner(this);
|
3359
|
-
const
|
3366
|
+
const filteredChildNodes = getFilteredChildNodes(this);
|
3367
|
+
// No need to filter by owner for non-shadowed nodes
|
3368
|
+
const childNodes = isNull(owner)
|
3369
|
+
? filteredChildNodes
|
3370
|
+
: getAllMatches(owner, filteredChildNodes);
|
3360
3371
|
return createStaticHTMLCollection(ArrayFilter.call(childNodes, (node) => node instanceof Element));
|
3361
3372
|
}
|
3362
3373
|
function childElementCountGetterPatched() {
|
@@ -4192,9 +4203,13 @@ defineProperty(Element.prototype, KEY__SHADOW_TOKEN, {
|
|
4192
4203
|
});
|
4193
4204
|
function recursivelySetShadowResolver(node, fn) {
|
4194
4205
|
node[KEY__SHADOW_RESOLVER] = fn;
|
4195
|
-
|
4196
|
-
|
4197
|
-
|
4206
|
+
// Recurse using firstChild/nextSibling because browsers use a linked list under the hood to
|
4207
|
+
// represent the DOM, so childNodes/children would cause an unnecessary array allocation.
|
4208
|
+
// https://viethung.space/blog/2020/09/01/Browser-from-Scratch-DOM-API/#Choosing-DOM-tree-data-structure
|
4209
|
+
let child = firstChildGetter.call(node);
|
4210
|
+
while (!isNull(child)) {
|
4211
|
+
recursivelySetShadowResolver(child, fn);
|
4212
|
+
child = nextSiblingGetter.call(child);
|
4198
4213
|
}
|
4199
4214
|
}
|
4200
4215
|
defineProperty(Element.prototype, KEY__SHADOW_STATIC, {
|
@@ -4363,6 +4378,6 @@ defineProperty(Element.prototype, '$domManual$', {
|
|
4363
4378
|
},
|
4364
4379
|
configurable: true,
|
4365
4380
|
});
|
4366
|
-
/** version: 6.
|
4381
|
+
/** version: 6.4.0 */
|
4367
4382
|
}
|
4368
4383
|
//# sourceMappingURL=index.cjs.js.map
|