@lwc/synthetic-shadow 3.0.2 → 3.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/faux-shadow/legacy-shadow-token.d.ts +2 -0
- package/dist/index.cjs.js +51 -7
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +51 -7
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
@@ -109,10 +109,13 @@ const KEY__SHADOW_STATIC = '$shadowStaticNode$';
|
|
109
109
|
const KEY__SHADOW_STATIC_PRIVATE = '$shadowStaticNodeKey$';
|
110
110
|
const KEY__SHADOW_TOKEN = '$shadowToken$';
|
111
111
|
const KEY__SHADOW_TOKEN_PRIVATE = '$$ShadowTokenKey$$';
|
112
|
+
// TODO [#3733]: remove support for legacy scope tokens
|
113
|
+
const KEY__LEGACY_SHADOW_TOKEN = '$legacyShadowToken$';
|
114
|
+
const KEY__LEGACY_SHADOW_TOKEN_PRIVATE = '$$LegacyShadowTokenKey$$';
|
112
115
|
const KEY__SYNTHETIC_MODE = '$$lwc-synthetic-mode';
|
113
116
|
const KEY__NATIVE_GET_ELEMENT_BY_ID = '$nativeGetElementById$';
|
114
117
|
const KEY__NATIVE_QUERY_SELECTOR_ALL = '$nativeQuerySelectorAll$';
|
115
|
-
/** version: 3.0.
|
118
|
+
/** version: 3.0.4 */
|
116
119
|
|
117
120
|
/**
|
118
121
|
* Copyright (C) 2023 salesforce.com, inc.
|
@@ -121,7 +124,7 @@ const KEY__NATIVE_QUERY_SELECTOR_ALL = '$nativeQuerySelectorAll$';
|
|
121
124
|
if (!_globalThis.lwcRuntimeFlags) {
|
122
125
|
Object.defineProperty(_globalThis, 'lwcRuntimeFlags', { value: create(null) });
|
123
126
|
}
|
124
|
-
/** version: 3.0.
|
127
|
+
/** version: 3.0.4 */
|
125
128
|
|
126
129
|
/*
|
127
130
|
* Copyright (c) 2018, salesforce.com, inc.
|
@@ -4351,6 +4354,40 @@ defineProperty(Element.prototype, KEY__SHADOW_STATIC, {
|
|
4351
4354
|
configurable: true,
|
4352
4355
|
});
|
4353
4356
|
|
4357
|
+
/*
|
4358
|
+
* Copyright (c) 2023, salesforce.com, inc.
|
4359
|
+
* All rights reserved.
|
4360
|
+
* SPDX-License-Identifier: MIT
|
4361
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
4362
|
+
*/
|
4363
|
+
// TODO [#3733]: remove this entire file when we can remove legacy scope tokens
|
4364
|
+
function getLegacyShadowToken(node) {
|
4365
|
+
return node[KEY__LEGACY_SHADOW_TOKEN];
|
4366
|
+
}
|
4367
|
+
function setLegacyShadowToken(node, shadowToken) {
|
4368
|
+
node[KEY__LEGACY_SHADOW_TOKEN] = shadowToken;
|
4369
|
+
}
|
4370
|
+
/**
|
4371
|
+
* Patching Element.prototype.$legacyShadowToken$ to mark elements a portal:
|
4372
|
+
* Same as $shadowToken$ but for legacy CSS scope tokens.
|
4373
|
+
**/
|
4374
|
+
defineProperty(Element.prototype, KEY__LEGACY_SHADOW_TOKEN, {
|
4375
|
+
set(shadowToken) {
|
4376
|
+
const oldShadowToken = this[KEY__LEGACY_SHADOW_TOKEN_PRIVATE];
|
4377
|
+
if (!isUndefined(oldShadowToken) && oldShadowToken !== shadowToken) {
|
4378
|
+
removeAttribute.call(this, oldShadowToken);
|
4379
|
+
}
|
4380
|
+
if (!isUndefined(shadowToken)) {
|
4381
|
+
setAttribute.call(this, shadowToken, '');
|
4382
|
+
}
|
4383
|
+
this[KEY__LEGACY_SHADOW_TOKEN_PRIVATE] = shadowToken;
|
4384
|
+
},
|
4385
|
+
get() {
|
4386
|
+
return this[KEY__LEGACY_SHADOW_TOKEN_PRIVATE];
|
4387
|
+
},
|
4388
|
+
configurable: true,
|
4389
|
+
});
|
4390
|
+
|
4354
4391
|
/*
|
4355
4392
|
* Copyright (c) 2018, salesforce.com, inc.
|
4356
4393
|
* All rights reserved.
|
@@ -4368,7 +4405,8 @@ let portalObserver;
|
|
4368
4405
|
const portalObserverConfig = {
|
4369
4406
|
childList: true,
|
4370
4407
|
};
|
4371
|
-
|
4408
|
+
// TODO [#3733]: remove support for legacy scope tokens
|
4409
|
+
function adoptChildNode(node, fn, shadowToken, legacyShadowToken) {
|
4372
4410
|
const previousNodeShadowResolver = getShadowRootResolver(node);
|
4373
4411
|
if (previousNodeShadowResolver === fn) {
|
4374
4412
|
return; // nothing to do here, it is already correctly patched
|
@@ -4376,6 +4414,9 @@ function adoptChildNode(node, fn, shadowToken) {
|
|
4376
4414
|
setShadowRootResolver(node, fn);
|
4377
4415
|
if (node instanceof Element) {
|
4378
4416
|
setShadowToken(node, shadowToken);
|
4417
|
+
if (lwcRuntimeFlags.ENABLE_LEGACY_SCOPE_TOKENS) {
|
4418
|
+
setLegacyShadowToken(node, legacyShadowToken);
|
4419
|
+
}
|
4379
4420
|
if (isSyntheticShadowHost(node)) {
|
4380
4421
|
// Root LWC elements can't get content slotted into them, therefore we don't observe their children.
|
4381
4422
|
return;
|
@@ -4387,7 +4428,7 @@ function adoptChildNode(node, fn, shadowToken) {
|
|
4387
4428
|
// recursively patching all children as well
|
4388
4429
|
const childNodes = childNodesGetter.call(node);
|
4389
4430
|
for (let i = 0, len = childNodes.length; i < len; i += 1) {
|
4390
|
-
adoptChildNode(childNodes[i], fn, shadowToken);
|
4431
|
+
adoptChildNode(childNodes[i], fn, shadowToken, legacyShadowToken);
|
4391
4432
|
}
|
4392
4433
|
}
|
4393
4434
|
}
|
@@ -4408,17 +4449,20 @@ function initPortalObserver() {
|
|
4408
4449
|
// the target of the mutation should always have a ShadowRootResolver attached to it
|
4409
4450
|
const fn = getShadowRootResolver(elm);
|
4410
4451
|
const shadowToken = getShadowToken(elm);
|
4452
|
+
const legacyShadowToken = lwcRuntimeFlags.ENABLE_LEGACY_SCOPE_TOKENS
|
4453
|
+
? getLegacyShadowToken(elm)
|
4454
|
+
: undefined;
|
4411
4455
|
// Process removals first to handle the case where an element is removed and reinserted
|
4412
4456
|
for (let i = 0, len = removedNodes.length; i < len; i += 1) {
|
4413
4457
|
const node = removedNodes[i];
|
4414
4458
|
if (!(compareDocumentPosition.call(elm, node) & _Node.DOCUMENT_POSITION_CONTAINED_BY)) {
|
4415
|
-
adoptChildNode(node, DocumentResolverFn, undefined);
|
4459
|
+
adoptChildNode(node, DocumentResolverFn, undefined, undefined);
|
4416
4460
|
}
|
4417
4461
|
}
|
4418
4462
|
for (let i = 0, len = addedNodes.length; i < len; i += 1) {
|
4419
4463
|
const node = addedNodes[i];
|
4420
4464
|
if (compareDocumentPosition.call(elm, node) & _Node.DOCUMENT_POSITION_CONTAINED_BY) {
|
4421
|
-
adoptChildNode(node, fn, shadowToken);
|
4465
|
+
adoptChildNode(node, fn, shadowToken, legacyShadowToken);
|
4422
4466
|
}
|
4423
4467
|
}
|
4424
4468
|
});
|
@@ -4465,5 +4509,5 @@ defineProperty(Element.prototype, '$domManual$', {
|
|
4465
4509
|
},
|
4466
4510
|
configurable: true,
|
4467
4511
|
});
|
4468
|
-
/** version: 3.0.
|
4512
|
+
/** version: 3.0.4 */
|
4469
4513
|
//# sourceMappingURL=index.js.map
|