@lwc/synthetic-shadow 3.0.1 → 3.0.3
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/env/document.d.ts +2 -2
- package/dist/faux-shadow/legacy-shadow-token.d.ts +2 -0
- package/dist/faux-shadow/node.d.ts +0 -7
- package/dist/faux-shadow/shadow-root.d.ts +0 -7
- package/dist/index.cjs.js +79 -320
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.js +79 -320
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/polyfills/iframe-content-window/detect.d.ts +0 -1
- package/dist/polyfills/iframe-content-window/main.d.ts +0 -1
- package/dist/polyfills/iframe-content-window/patch.d.ts +0 -1
- package/dist/polyfills/window-event-target/detect.d.ts +0 -1
- package/dist/polyfills/window-event-target/main.d.ts +0 -1
- package/dist/polyfills/window-event-target/polyfill.d.ts +0 -1
package/dist/index.d.ts
CHANGED
@@ -14,10 +14,8 @@ import './polyfills/click-event-composed/main';
|
|
14
14
|
import './polyfills/event-composed/main';
|
15
15
|
import './polyfills/custom-event-composed/main';
|
16
16
|
import './polyfills/clipboard-event-composed/main';
|
17
|
-
import './polyfills/iframe-content-window/main';
|
18
17
|
import './polyfills/mutation-observer/main';
|
19
18
|
import './polyfills/event-target/main';
|
20
|
-
import './polyfills/window-event-target/main';
|
21
19
|
import './polyfills/event/main';
|
22
20
|
import './polyfills/focus-event/main';
|
23
21
|
import './polyfills/mouse-event/main';
|
package/dist/index.js
CHANGED
@@ -109,20 +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
|
-
|
116
|
-
/*
|
117
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
118
|
-
* All rights reserved.
|
119
|
-
* SPDX-License-Identifier: MIT
|
120
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
121
|
-
*/
|
122
|
-
// We use this to detect symbol support in order to avoid the expensive symbol polyfill. Note that
|
123
|
-
// we can't use typeof since it will fail when transpiling.
|
124
|
-
const hasNativeSymbolSupport = /*@__PURE__*/ (() => Symbol('x').toString() === 'Symbol(x)')();
|
125
|
-
/** version: 3.0.1 */
|
118
|
+
/** version: 3.0.3 */
|
126
119
|
|
127
120
|
/**
|
128
121
|
* Copyright (C) 2023 salesforce.com, inc.
|
@@ -131,7 +124,7 @@ const hasNativeSymbolSupport = /*@__PURE__*/ (() => Symbol('x').toString() === '
|
|
131
124
|
if (!_globalThis.lwcRuntimeFlags) {
|
132
125
|
Object.defineProperty(_globalThis, 'lwcRuntimeFlags', { value: create(null) });
|
133
126
|
}
|
134
|
-
/** version: 3.0.
|
127
|
+
/** version: 3.0.3 */
|
135
128
|
|
136
129
|
/*
|
137
130
|
* Copyright (c) 2018, salesforce.com, inc.
|
@@ -151,13 +144,9 @@ const lastChildGetter = getOwnPropertyDescriptor(nodePrototype, 'lastChild').get
|
|
151
144
|
const textContentGetter = getOwnPropertyDescriptor(nodePrototype, 'textContent').get;
|
152
145
|
const parentNodeGetter = getOwnPropertyDescriptor(nodePrototype, 'parentNode').get;
|
153
146
|
const ownerDocumentGetter = getOwnPropertyDescriptor(nodePrototype, 'ownerDocument').get;
|
154
|
-
const parentElementGetter =
|
155
|
-
? getOwnPropertyDescriptor(nodePrototype, 'parentElement').get
|
156
|
-
: getOwnPropertyDescriptor(HTMLElement.prototype, 'parentElement').get; // IE11
|
147
|
+
const parentElementGetter = getOwnPropertyDescriptor(nodePrototype, 'parentElement').get;
|
157
148
|
const textContextSetter = getOwnPropertyDescriptor(nodePrototype, 'textContent').set;
|
158
|
-
const childNodesGetter =
|
159
|
-
? getOwnPropertyDescriptor(nodePrototype, 'childNodes').get
|
160
|
-
: getOwnPropertyDescriptor(HTMLElement.prototype, 'childNodes').get; // IE11
|
149
|
+
const childNodesGetter = getOwnPropertyDescriptor(nodePrototype, 'childNodes').get;
|
161
150
|
const isConnected = hasOwnProperty.call(nodePrototype, 'isConnected')
|
162
151
|
? getOwnPropertyDescriptor(nodePrototype, 'isConnected').get
|
163
152
|
: function () {
|
@@ -200,26 +189,18 @@ const outerTextGetter = outerTextDescriptor
|
|
200
189
|
const outerTextSetter = outerTextDescriptor
|
201
190
|
? outerTextDescriptor.set
|
202
191
|
: null;
|
203
|
-
const innerHTMLDescriptor =
|
204
|
-
? getOwnPropertyDescriptor(Element.prototype, 'innerHTML')
|
205
|
-
: getOwnPropertyDescriptor(HTMLElement.prototype, 'innerHTML'); // IE11
|
192
|
+
const innerHTMLDescriptor = getOwnPropertyDescriptor(Element.prototype, 'innerHTML');
|
206
193
|
const innerHTMLGetter = innerHTMLDescriptor.get;
|
207
194
|
const innerHTMLSetter = innerHTMLDescriptor.set;
|
208
|
-
const outerHTMLDescriptor =
|
209
|
-
? getOwnPropertyDescriptor(Element.prototype, 'outerHTML')
|
210
|
-
: getOwnPropertyDescriptor(HTMLElement.prototype, 'outerHTML'); // IE11
|
195
|
+
const outerHTMLDescriptor = getOwnPropertyDescriptor(Element.prototype, 'outerHTML');
|
211
196
|
const outerHTMLGetter = outerHTMLDescriptor.get;
|
212
197
|
const outerHTMLSetter = outerHTMLDescriptor.set;
|
213
198
|
const tagNameGetter = getOwnPropertyDescriptor(Element.prototype, 'tagName').get;
|
214
199
|
const tabIndexDescriptor = getOwnPropertyDescriptor(HTMLElement.prototype, 'tabIndex');
|
215
200
|
const tabIndexGetter = tabIndexDescriptor.get;
|
216
201
|
const tabIndexSetter = tabIndexDescriptor.set;
|
217
|
-
const matches =
|
218
|
-
|
219
|
-
: Element.prototype.msMatchesSelector; // IE11
|
220
|
-
const childrenGetter = hasOwnProperty.call(Element.prototype, 'children')
|
221
|
-
? getOwnPropertyDescriptor(Element.prototype, 'children').get
|
222
|
-
: getOwnPropertyDescriptor(HTMLElement.prototype, 'children').get; // IE11
|
202
|
+
const matches = Element.prototype.matches;
|
203
|
+
const childrenGetter = getOwnPropertyDescriptor(Element.prototype, 'children').get;
|
223
204
|
// for IE11, access from HTMLElement
|
224
205
|
// for all other browsers access the method from the parent Element interface
|
225
206
|
const { getElementsByClassName: getElementsByClassName$1 } = HTMLElement.prototype;
|
@@ -273,16 +254,12 @@ const composedPath = hasOwnProperty.call(Event.prototype, 'composedPath')
|
|
273
254
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
274
255
|
*/
|
275
256
|
const DocumentPrototypeActiveElement = getOwnPropertyDescriptor(Document.prototype, 'activeElement').get;
|
276
|
-
const elementFromPoint =
|
277
|
-
|
278
|
-
: Document.prototype.msElementFromPoint; // IE11
|
279
|
-
const elementsFromPoint = hasOwnProperty.call(Document.prototype, 'elementsFromPoint')
|
280
|
-
? Document.prototype.elementsFromPoint
|
281
|
-
: Document.prototype.msElementsFromPoint; // IE11
|
257
|
+
const elementFromPoint = Document.prototype.elementFromPoint;
|
258
|
+
const elementsFromPoint = Document.prototype.elementsFromPoint;
|
282
259
|
// defaultView can be null when a document has no browsing context. For example, the owner document
|
283
260
|
// of a node in a template doesn't have a default view: https://jsfiddle.net/hv9z0q5a/
|
284
261
|
const defaultViewGetter = getOwnPropertyDescriptor(Document.prototype, 'defaultView').get;
|
285
|
-
const {
|
262
|
+
const { querySelectorAll, getElementById, getElementsByClassName, getElementsByTagName, getElementsByTagNameNS, } = Document.prototype;
|
286
263
|
// In Firefox v57 and lower, getElementsByName is defined on HTMLDocument.prototype
|
287
264
|
// In all other browsers have the method on Document.prototype
|
288
265
|
const { getElementsByName } = HTMLDocument.prototype;
|
@@ -328,7 +305,7 @@ const isInstanceOfNativeShadowRoot = isNull(NativeShadowRoot)
|
|
328
305
|
* SPDX-License-Identifier: MIT
|
329
306
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
330
307
|
*/
|
331
|
-
function detect$
|
308
|
+
function detect$2 () {
|
332
309
|
return typeof HTMLSlotElement === 'undefined';
|
333
310
|
}
|
334
311
|
|
@@ -343,7 +320,7 @@ const CHAR_S = 115;
|
|
343
320
|
const CHAR_L = 108;
|
344
321
|
const CHAR_O = 111;
|
345
322
|
const CHAR_T = 116;
|
346
|
-
function apply$
|
323
|
+
function apply$2() {
|
347
324
|
// IE11 does not have this element definition
|
348
325
|
// we don't care much about the construction phase, just the prototype
|
349
326
|
class HTMLSlotElement {
|
@@ -378,8 +355,8 @@ function apply$4() {
|
|
378
355
|
* SPDX-License-Identifier: MIT
|
379
356
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
380
357
|
*/
|
381
|
-
if (detect$
|
382
|
-
apply$
|
358
|
+
if (detect$2()) {
|
359
|
+
apply$2();
|
383
360
|
}
|
384
361
|
|
385
362
|
/*
|
@@ -1280,15 +1257,6 @@ function childNodesGetterPatched() {
|
|
1280
1257
|
if (isSyntheticShadowHost(this)) {
|
1281
1258
|
const owner = getNodeOwner(this);
|
1282
1259
|
const childNodes = isNull(owner) ? [] : getAllMatches(owner, getFilteredChildNodes(this));
|
1283
|
-
if (process.env.NODE_ENV !== 'production' &&
|
1284
|
-
isFalse(hasNativeSymbolSupport) &&
|
1285
|
-
isExternalChildNodeAccessorFlagOn()) {
|
1286
|
-
// inserting a comment node as the first childNode to trick the IE11
|
1287
|
-
// DevTool to show the content of the shadowRoot, this should only happen
|
1288
|
-
// in dev-mode and in IE11 (which we detect by looking at the symbol).
|
1289
|
-
// Plus it should only be in place if we know it is an external invoker.
|
1290
|
-
ArrayUnshift.call(childNodes, getIE11FakeShadowRootPlaceholder(this));
|
1291
|
-
}
|
1292
1260
|
return createStaticNodeList(childNodes);
|
1293
1261
|
}
|
1294
1262
|
// nothing to do here since this does not have a synthetic shadow attached to it
|
@@ -1503,40 +1471,9 @@ defineProperties(_Node.prototype, {
|
|
1503
1471
|
},
|
1504
1472
|
},
|
1505
1473
|
});
|
1506
|
-
|
1507
|
-
|
1508
|
-
|
1509
|
-
* .childNodes member property of a node. If it is used from inside the synthetic shadow
|
1510
|
-
* or from an external invoker. This helps to produce the right output in one very peculiar
|
1511
|
-
* case, the IE11 debugging comment for shadowRoot representation on the devtool.
|
1512
|
-
*/
|
1513
|
-
function isExternalChildNodeAccessorFlagOn() {
|
1514
|
-
return !internalChildNodeAccessorFlag;
|
1515
|
-
}
|
1516
|
-
const getInternalChildNodes = process.env.NODE_ENV !== 'production' && isFalse(hasNativeSymbolSupport)
|
1517
|
-
? function (node) {
|
1518
|
-
internalChildNodeAccessorFlag = true;
|
1519
|
-
let childNodes;
|
1520
|
-
let error = null;
|
1521
|
-
try {
|
1522
|
-
childNodes = node.childNodes;
|
1523
|
-
}
|
1524
|
-
catch (e) {
|
1525
|
-
// childNodes accessor should never throw, but just in case!
|
1526
|
-
error = e;
|
1527
|
-
}
|
1528
|
-
finally {
|
1529
|
-
internalChildNodeAccessorFlag = false;
|
1530
|
-
if (!isNull(error)) {
|
1531
|
-
// re-throwing after restoring the state machinery for setInternalChildNodeAccessorFlag
|
1532
|
-
throw error; // eslint-disable-line no-unsafe-finally
|
1533
|
-
}
|
1534
|
-
}
|
1535
|
-
return childNodes;
|
1536
|
-
}
|
1537
|
-
: function (node) {
|
1538
|
-
return node.childNodes;
|
1539
|
-
};
|
1474
|
+
const getInternalChildNodes = function (node) {
|
1475
|
+
return node.childNodes;
|
1476
|
+
};
|
1540
1477
|
// IE11 extra patches for wrong prototypes
|
1541
1478
|
if (hasOwnProperty.call(HTMLElement.prototype, 'contains')) {
|
1542
1479
|
defineProperty(HTMLElement.prototype, 'contains', getOwnPropertyDescriptor(_Node.prototype, 'contains'));
|
@@ -2344,42 +2281,6 @@ defineProperty(SyntheticShadowRoot, Symbol.hasInstance, {
|
|
2344
2281
|
getPrototypeOf(object) === SyntheticShadowRoot.prototype));
|
2345
2282
|
},
|
2346
2283
|
});
|
2347
|
-
/**
|
2348
|
-
* This method is only intended to be used in non-production mode in IE11
|
2349
|
-
* and its role is to produce a 1-1 mapping between a shadowRoot instance
|
2350
|
-
* and a comment node that is intended to use to trick the IE11 DevTools
|
2351
|
-
* to show the content of the shadowRoot in the DOM Explorer.
|
2352
|
-
*/
|
2353
|
-
function getIE11FakeShadowRootPlaceholder(host) {
|
2354
|
-
const shadowRoot = getShadowRoot(host);
|
2355
|
-
// @ts-ignore this $$placeholder$$ is not a security issue because you must
|
2356
|
-
// have access to the shadowRoot in order to extract the fake node, which give
|
2357
|
-
// you access to the same childNodes of the shadowRoot, so, who cares.
|
2358
|
-
let c = shadowRoot.$$placeholder$$;
|
2359
|
-
if (!isUndefined(c)) {
|
2360
|
-
return c;
|
2361
|
-
}
|
2362
|
-
const doc = getOwnerDocument(host);
|
2363
|
-
// @ts-ignore $$placeholder$$ is fine, read the node above.
|
2364
|
-
c = shadowRoot.$$placeholder$$ = createComment.call(doc, '');
|
2365
|
-
defineProperties(c, {
|
2366
|
-
childNodes: {
|
2367
|
-
get() {
|
2368
|
-
return shadowRoot.childNodes;
|
2369
|
-
},
|
2370
|
-
enumerable: true,
|
2371
|
-
configurable: true,
|
2372
|
-
},
|
2373
|
-
tagName: {
|
2374
|
-
get() {
|
2375
|
-
return `#shadow-root (${shadowRoot.mode})`;
|
2376
|
-
},
|
2377
|
-
enumerable: true,
|
2378
|
-
configurable: true,
|
2379
|
-
},
|
2380
|
-
});
|
2381
|
-
return c;
|
2382
|
-
}
|
2383
2284
|
|
2384
2285
|
/*
|
2385
2286
|
* Copyright (c) 2018, salesforce.com, inc.
|
@@ -2658,7 +2559,7 @@ Object.defineProperty(window, 'ShadowRoot', {
|
|
2658
2559
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
2659
2560
|
*/
|
2660
2561
|
const composedDescriptor = Object.getOwnPropertyDescriptor(Event.prototype, 'composed');
|
2661
|
-
function detect$
|
2562
|
+
function detect$1() {
|
2662
2563
|
if (!composedDescriptor) {
|
2663
2564
|
// No need to apply this polyfill if this client completely lacks
|
2664
2565
|
// support for the composed property.
|
@@ -2690,7 +2591,7 @@ function handleClick(event) {
|
|
2690
2591
|
},
|
2691
2592
|
});
|
2692
2593
|
}
|
2693
|
-
function apply$
|
2594
|
+
function apply$1() {
|
2694
2595
|
HTMLElement.prototype.click = function () {
|
2695
2596
|
addEventListener.call(this, 'click', handleClick);
|
2696
2597
|
try {
|
@@ -2708,8 +2609,8 @@ function apply$3() {
|
|
2708
2609
|
* SPDX-License-Identifier: MIT
|
2709
2610
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
2710
2611
|
*/
|
2711
|
-
if (detect$
|
2712
|
-
apply$
|
2612
|
+
if (detect$1()) {
|
2613
|
+
apply$1();
|
2713
2614
|
}
|
2714
2615
|
|
2715
2616
|
/*
|
@@ -2718,7 +2619,7 @@ if (detect$3()) {
|
|
2718
2619
|
* SPDX-License-Identifier: MIT
|
2719
2620
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
2720
2621
|
*/
|
2721
|
-
function detect
|
2622
|
+
function detect() {
|
2722
2623
|
return new Event('test', { composed: true }).composed !== true;
|
2723
2624
|
}
|
2724
2625
|
|
@@ -2728,7 +2629,7 @@ function detect$2() {
|
|
2728
2629
|
* SPDX-License-Identifier: MIT
|
2729
2630
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
2730
2631
|
*/
|
2731
|
-
function apply
|
2632
|
+
function apply() {
|
2732
2633
|
// https://github.com/w3c/webcomponents/issues/513#issuecomment-224183937
|
2733
2634
|
const composedEvents = assign(create(null), {
|
2734
2635
|
beforeinput: 1,
|
@@ -2822,8 +2723,8 @@ function apply$2() {
|
|
2822
2723
|
* SPDX-License-Identifier: MIT
|
2823
2724
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
2824
2725
|
*/
|
2825
|
-
if (detect
|
2826
|
-
apply
|
2726
|
+
if (detect()) {
|
2727
|
+
apply();
|
2827
2728
|
}
|
2828
2729
|
|
2829
2730
|
/*
|
@@ -2875,121 +2776,6 @@ if (typeof ClipboardEvent !== 'undefined') {
|
|
2875
2776
|
});
|
2876
2777
|
}
|
2877
2778
|
|
2878
|
-
/*
|
2879
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
2880
|
-
* All rights reserved.
|
2881
|
-
* SPDX-License-Identifier: MIT
|
2882
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
2883
|
-
*/
|
2884
|
-
function detect$1() {
|
2885
|
-
// Note: when using this in mobile apps, we might have a DOM that does not support iframes.
|
2886
|
-
const hasIframe = typeof HTMLIFrameElement !== 'undefined';
|
2887
|
-
// This polyfill should only apply in compat mode; see https://github.com/salesforce/lwc/issues/1513
|
2888
|
-
const isCompat = typeof Proxy !== 'undefined' && isTrue(Proxy.isCompat);
|
2889
|
-
return hasIframe && isCompat;
|
2890
|
-
}
|
2891
|
-
|
2892
|
-
/*
|
2893
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
2894
|
-
* All rights reserved.
|
2895
|
-
* SPDX-License-Identifier: MIT
|
2896
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
2897
|
-
*/
|
2898
|
-
function apply$1() {
|
2899
|
-
// the iframe property descriptor for `contentWindow` should always be available, otherwise this method should never be called
|
2900
|
-
const desc = getOwnPropertyDescriptor(HTMLIFrameElement.prototype, 'contentWindow');
|
2901
|
-
const { get: originalGetter } = desc;
|
2902
|
-
desc.get = function () {
|
2903
|
-
const original = originalGetter.call(this);
|
2904
|
-
// If the original iframe element is not a keyed node, then do not wrap it
|
2905
|
-
if (isNull(original) || isUndefined(getNodeOwnerKey(this))) {
|
2906
|
-
return original;
|
2907
|
-
}
|
2908
|
-
// only if the element is an iframe inside a shadowRoot, we care about this problem
|
2909
|
-
// because in that case, the code that is accessing the iframe, is very likely code
|
2910
|
-
// compiled with proxy-compat transformation. It is true that other code without those
|
2911
|
-
// transformations might also access an iframe from within a shadowRoot, but in that,
|
2912
|
-
// case, which is more rare, we still return the wrapper, and it should work the same,
|
2913
|
-
// this part is just an optimization.
|
2914
|
-
return wrapIframeWindow(original);
|
2915
|
-
};
|
2916
|
-
defineProperty(HTMLIFrameElement.prototype, 'contentWindow', desc);
|
2917
|
-
}
|
2918
|
-
function wrapIframeWindow(win) {
|
2919
|
-
return {
|
2920
|
-
addEventListener() {
|
2921
|
-
// Typescript does not like it when you treat the `arguments` object as an array
|
2922
|
-
// @ts-ignore type-mismatch
|
2923
|
-
return win.addEventListener.apply(win, arguments);
|
2924
|
-
},
|
2925
|
-
blur() {
|
2926
|
-
// Typescript does not like it when you treat the `arguments` object as an array
|
2927
|
-
// @ts-ignore type-mismatch
|
2928
|
-
return win.blur.apply(win, arguments);
|
2929
|
-
},
|
2930
|
-
close() {
|
2931
|
-
// Typescript does not like it when you treat the `arguments` object as an array
|
2932
|
-
// @ts-ignore type-mismatch
|
2933
|
-
return win.close.apply(win, arguments);
|
2934
|
-
},
|
2935
|
-
focus() {
|
2936
|
-
// Typescript does not like it when you treat the `arguments` object as an array
|
2937
|
-
// @ts-ignore type-mismatch
|
2938
|
-
return win.focus.apply(win, arguments);
|
2939
|
-
},
|
2940
|
-
postMessage() {
|
2941
|
-
// Typescript does not like it when you treat the `arguments` object as an array
|
2942
|
-
// @ts-ignore type-mismatch
|
2943
|
-
return win.postMessage.apply(win, arguments);
|
2944
|
-
},
|
2945
|
-
removeEventListener() {
|
2946
|
-
// Typescript does not like it when you treat the `arguments` object as an array
|
2947
|
-
// @ts-ignore type-mismatch
|
2948
|
-
return win.removeEventListener.apply(win, arguments);
|
2949
|
-
},
|
2950
|
-
get closed() {
|
2951
|
-
return win.closed;
|
2952
|
-
},
|
2953
|
-
get frames() {
|
2954
|
-
return win.frames;
|
2955
|
-
},
|
2956
|
-
get length() {
|
2957
|
-
return win.length;
|
2958
|
-
},
|
2959
|
-
get location() {
|
2960
|
-
return win.location;
|
2961
|
-
},
|
2962
|
-
set location(value) {
|
2963
|
-
win.location = value;
|
2964
|
-
},
|
2965
|
-
get opener() {
|
2966
|
-
return win.opener;
|
2967
|
-
},
|
2968
|
-
get parent() {
|
2969
|
-
return win.parent;
|
2970
|
-
},
|
2971
|
-
get self() {
|
2972
|
-
return win.self;
|
2973
|
-
},
|
2974
|
-
get top() {
|
2975
|
-
return win.top;
|
2976
|
-
},
|
2977
|
-
get window() {
|
2978
|
-
return win.window;
|
2979
|
-
},
|
2980
|
-
}; // this is limited
|
2981
|
-
}
|
2982
|
-
|
2983
|
-
/*
|
2984
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
2985
|
-
* All rights reserved.
|
2986
|
-
* SPDX-License-Identifier: MIT
|
2987
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
2988
|
-
*/
|
2989
|
-
if (detect$1()) {
|
2990
|
-
apply$1();
|
2991
|
-
}
|
2992
|
-
|
2993
2779
|
/*
|
2994
2780
|
* Copyright (c) 2018, salesforce.com, inc.
|
2995
2781
|
* All rights reserved.
|
@@ -3231,7 +3017,7 @@ defineProperty(window, 'MutationObserver', {
|
|
3231
3017
|
* SPDX-License-Identifier: MIT
|
3232
3018
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
3233
3019
|
*/
|
3234
|
-
function patchedAddEventListener
|
3020
|
+
function patchedAddEventListener(type, listener, optionsOrCapture) {
|
3235
3021
|
if (isSyntheticShadowHost(this)) {
|
3236
3022
|
// Typescript does not like it when you treat the `arguments` object as an array
|
3237
3023
|
// @ts-ignore type-mismatch
|
@@ -3254,7 +3040,7 @@ function patchedAddEventListener$1(type, listener, optionsOrCapture) {
|
|
3254
3040
|
// The third argument is optional, so passing in `undefined` for `optionsOrCapture` gives capture=false
|
3255
3041
|
return addEventListener.call(this, type, wrappedListener, optionsOrCapture);
|
3256
3042
|
}
|
3257
|
-
function patchedRemoveEventListener
|
3043
|
+
function patchedRemoveEventListener(_type, _listener, _optionsOrCapture) {
|
3258
3044
|
if (isSyntheticShadowHost(this)) {
|
3259
3045
|
// Typescript does not like it when you treat the `arguments` object as an array
|
3260
3046
|
// @ts-ignore type-mismatch
|
@@ -3274,87 +3060,19 @@ function patchedRemoveEventListener$1(_type, _listener, _optionsOrCapture) {
|
|
3274
3060
|
}
|
3275
3061
|
defineProperties(eventTargetPrototype, {
|
3276
3062
|
addEventListener: {
|
3277
|
-
value: patchedAddEventListener
|
3063
|
+
value: patchedAddEventListener,
|
3278
3064
|
enumerable: true,
|
3279
3065
|
writable: true,
|
3280
3066
|
configurable: true,
|
3281
3067
|
},
|
3282
3068
|
removeEventListener: {
|
3283
|
-
value: patchedRemoveEventListener
|
3069
|
+
value: patchedRemoveEventListener,
|
3284
3070
|
enumerable: true,
|
3285
3071
|
writable: true,
|
3286
3072
|
configurable: true,
|
3287
3073
|
},
|
3288
3074
|
});
|
3289
3075
|
|
3290
|
-
/*
|
3291
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
3292
|
-
* All rights reserved.
|
3293
|
-
* SPDX-License-Identifier: MIT
|
3294
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
3295
|
-
*/
|
3296
|
-
function detect() {
|
3297
|
-
return typeof EventTarget === 'undefined';
|
3298
|
-
}
|
3299
|
-
|
3300
|
-
/*
|
3301
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
3302
|
-
* All rights reserved.
|
3303
|
-
* SPDX-License-Identifier: MIT
|
3304
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
3305
|
-
*/
|
3306
|
-
function patchedAddEventListener(_type, _listener, _options) {
|
3307
|
-
if (arguments.length > 1) {
|
3308
|
-
const args = ArraySlice.call(arguments);
|
3309
|
-
args[1] = getEventListenerWrapper(args[1]);
|
3310
|
-
// Ignore types because we're passing through to native method
|
3311
|
-
// @ts-ignore type-mismatch
|
3312
|
-
return windowAddEventListener.apply(this, args);
|
3313
|
-
}
|
3314
|
-
// Typescript does not like it when you treat the `arguments` object as an array
|
3315
|
-
// @ts-ignore type-mismatch
|
3316
|
-
return windowAddEventListener.apply(this, arguments);
|
3317
|
-
}
|
3318
|
-
function patchedRemoveEventListener(_type, _listener, _options) {
|
3319
|
-
if (arguments.length > 1) {
|
3320
|
-
const args = ArraySlice.call(arguments);
|
3321
|
-
args[1] = getEventListenerWrapper(args[1]);
|
3322
|
-
// Ignore types because we're passing through to native method
|
3323
|
-
// @ts-ignore type-mismatch
|
3324
|
-
windowRemoveEventListener.apply(this, args);
|
3325
|
-
}
|
3326
|
-
// Account for listeners that were added before this polyfill was applied
|
3327
|
-
// Typescript does not like it when you treat the `arguments` object as an array
|
3328
|
-
// @ts-ignore type-mismatch
|
3329
|
-
windowRemoveEventListener.apply(this, arguments);
|
3330
|
-
}
|
3331
|
-
function apply() {
|
3332
|
-
defineProperties(Window.prototype, {
|
3333
|
-
addEventListener: {
|
3334
|
-
value: patchedAddEventListener,
|
3335
|
-
enumerable: true,
|
3336
|
-
writable: true,
|
3337
|
-
configurable: true,
|
3338
|
-
},
|
3339
|
-
removeEventListener: {
|
3340
|
-
value: patchedRemoveEventListener,
|
3341
|
-
enumerable: true,
|
3342
|
-
writable: true,
|
3343
|
-
configurable: true,
|
3344
|
-
},
|
3345
|
-
});
|
3346
|
-
}
|
3347
|
-
|
3348
|
-
/*
|
3349
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
3350
|
-
* All rights reserved.
|
3351
|
-
* SPDX-License-Identifier: MIT
|
3352
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
3353
|
-
*/
|
3354
|
-
if (detect()) {
|
3355
|
-
apply();
|
3356
|
-
}
|
3357
|
-
|
3358
3076
|
/*
|
3359
3077
|
* Copyright (c) 2018, salesforce.com, inc.
|
3360
3078
|
* All rights reserved.
|
@@ -4636,6 +4354,40 @@ defineProperty(Element.prototype, KEY__SHADOW_STATIC, {
|
|
4636
4354
|
configurable: true,
|
4637
4355
|
});
|
4638
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
|
+
|
4639
4391
|
/*
|
4640
4392
|
* Copyright (c) 2018, salesforce.com, inc.
|
4641
4393
|
* All rights reserved.
|
@@ -4653,7 +4405,8 @@ let portalObserver;
|
|
4653
4405
|
const portalObserverConfig = {
|
4654
4406
|
childList: true,
|
4655
4407
|
};
|
4656
|
-
|
4408
|
+
// TODO [#3733]: remove support for legacy scope tokens
|
4409
|
+
function adoptChildNode(node, fn, shadowToken, legacyShadowToken) {
|
4657
4410
|
const previousNodeShadowResolver = getShadowRootResolver(node);
|
4658
4411
|
if (previousNodeShadowResolver === fn) {
|
4659
4412
|
return; // nothing to do here, it is already correctly patched
|
@@ -4661,6 +4414,9 @@ function adoptChildNode(node, fn, shadowToken) {
|
|
4661
4414
|
setShadowRootResolver(node, fn);
|
4662
4415
|
if (node instanceof Element) {
|
4663
4416
|
setShadowToken(node, shadowToken);
|
4417
|
+
if (lwcRuntimeFlags.ENABLE_LEGACY_SCOPE_TOKENS) {
|
4418
|
+
setLegacyShadowToken(node, legacyShadowToken);
|
4419
|
+
}
|
4664
4420
|
if (isSyntheticShadowHost(node)) {
|
4665
4421
|
// Root LWC elements can't get content slotted into them, therefore we don't observe their children.
|
4666
4422
|
return;
|
@@ -4672,7 +4428,7 @@ function adoptChildNode(node, fn, shadowToken) {
|
|
4672
4428
|
// recursively patching all children as well
|
4673
4429
|
const childNodes = childNodesGetter.call(node);
|
4674
4430
|
for (let i = 0, len = childNodes.length; i < len; i += 1) {
|
4675
|
-
adoptChildNode(childNodes[i], fn, shadowToken);
|
4431
|
+
adoptChildNode(childNodes[i], fn, shadowToken, legacyShadowToken);
|
4676
4432
|
}
|
4677
4433
|
}
|
4678
4434
|
}
|
@@ -4693,17 +4449,20 @@ function initPortalObserver() {
|
|
4693
4449
|
// the target of the mutation should always have a ShadowRootResolver attached to it
|
4694
4450
|
const fn = getShadowRootResolver(elm);
|
4695
4451
|
const shadowToken = getShadowToken(elm);
|
4452
|
+
const legacyShadowToken = lwcRuntimeFlags.ENABLE_LEGACY_SCOPE_TOKENS
|
4453
|
+
? getLegacyShadowToken(elm)
|
4454
|
+
: undefined;
|
4696
4455
|
// Process removals first to handle the case where an element is removed and reinserted
|
4697
4456
|
for (let i = 0, len = removedNodes.length; i < len; i += 1) {
|
4698
4457
|
const node = removedNodes[i];
|
4699
4458
|
if (!(compareDocumentPosition.call(elm, node) & _Node.DOCUMENT_POSITION_CONTAINED_BY)) {
|
4700
|
-
adoptChildNode(node, DocumentResolverFn, undefined);
|
4459
|
+
adoptChildNode(node, DocumentResolverFn, undefined, undefined);
|
4701
4460
|
}
|
4702
4461
|
}
|
4703
4462
|
for (let i = 0, len = addedNodes.length; i < len; i += 1) {
|
4704
4463
|
const node = addedNodes[i];
|
4705
4464
|
if (compareDocumentPosition.call(elm, node) & _Node.DOCUMENT_POSITION_CONTAINED_BY) {
|
4706
|
-
adoptChildNode(node, fn, shadowToken);
|
4465
|
+
adoptChildNode(node, fn, shadowToken, legacyShadowToken);
|
4707
4466
|
}
|
4708
4467
|
}
|
4709
4468
|
});
|
@@ -4750,5 +4509,5 @@ defineProperty(Element.prototype, '$domManual$', {
|
|
4750
4509
|
},
|
4751
4510
|
configurable: true,
|
4752
4511
|
});
|
4753
|
-
/** version: 3.0.
|
4512
|
+
/** version: 3.0.3 */
|
4754
4513
|
//# sourceMappingURL=index.js.map
|