@lwc/synthetic-shadow 3.0.1 → 3.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@ declare const DocumentPrototypeActiveElement: (this: Document) => Element | null
2
2
  declare const elementFromPoint: (x: number, y: number) => Element | null;
3
3
  declare const elementsFromPoint: (x: number, y: number) => Element[];
4
4
  declare const defaultViewGetter: (this: Document) => Window | null;
5
- declare const createComment: (data: string) => Comment, querySelectorAll: {
5
+ declare const querySelectorAll: {
6
6
  <K extends keyof HTMLElementTagNameMap>(selectors: K): NodeListOf<HTMLElementTagNameMap[K]>;
7
7
  <K_1 extends keyof SVGElementTagNameMap>(selectors: K_1): NodeListOf<SVGElementTagNameMap[K_1]>;
8
8
  <K_2 extends keyof MathMLElementTagNameMap>(selectors: K_2): NodeListOf<MathMLElementTagNameMap[K_2]>;
@@ -21,4 +21,4 @@ declare const createComment: (data: string) => Comment, querySelectorAll: {
21
21
  (namespace: string | null, localName: string): HTMLCollectionOf<Element>;
22
22
  };
23
23
  declare const getElementsByName: (elementName: string) => NodeListOf<HTMLElement>;
24
- export { elementFromPoint, elementsFromPoint, createComment, DocumentPrototypeActiveElement, querySelectorAll, getElementById, getElementsByClassName, getElementsByName, getElementsByTagName, getElementsByTagNameNS, defaultViewGetter, };
24
+ export { elementFromPoint, elementsFromPoint, DocumentPrototypeActiveElement, querySelectorAll, getElementById, getElementsByClassName, getElementsByName, getElementsByTagName, getElementsByTagNameNS, defaultViewGetter, };
@@ -0,0 +1,2 @@
1
+ export declare function getLegacyShadowToken(node: Node): string | undefined;
2
+ export declare function setLegacyShadowToken(node: Node, shadowToken: string | undefined): void;
@@ -5,11 +5,4 @@
5
5
  * because we don't want to patch the children getters for those elements.
6
6
  */
7
7
  export declare function hasMountedChildren(node: Node): boolean;
8
- /**
9
- * These 2 methods are providing a machinery to understand who is accessing the
10
- * .childNodes member property of a node. If it is used from inside the synthetic shadow
11
- * or from an external invoker. This helps to produce the right output in one very peculiar
12
- * case, the IE11 debugging comment for shadowRoot representation on the devtool.
13
- */
14
- export declare function isExternalChildNodeAccessorFlagOn(): boolean;
15
8
  export declare const getInternalChildNodes: (node: Node) => NodeListOf<ChildNode>;
@@ -13,10 +13,3 @@ export declare function SyntheticShadowRoot(): void;
13
13
  export declare namespace SyntheticShadowRoot {
14
14
  var prototype: any;
15
15
  }
16
- /**
17
- * This method is only intended to be used in non-production mode in IE11
18
- * and its role is to produce a 1-1 mapping between a shadowRoot instance
19
- * and a comment node that is intended to use to trick the IE11 DevTools
20
- * to show the content of the shadowRoot in the DOM Explorer.
21
- */
22
- export declare function getIE11FakeShadowRootPlaceholder(host: Element): Comment;
package/dist/index.cjs.js CHANGED
@@ -111,20 +111,13 @@ const KEY__SHADOW_STATIC = '$shadowStaticNode$';
111
111
  const KEY__SHADOW_STATIC_PRIVATE = '$shadowStaticNodeKey$';
112
112
  const KEY__SHADOW_TOKEN = '$shadowToken$';
113
113
  const KEY__SHADOW_TOKEN_PRIVATE = '$$ShadowTokenKey$$';
114
+ // TODO [#3733]: remove support for legacy scope tokens
115
+ const KEY__LEGACY_SHADOW_TOKEN = '$legacyShadowToken$';
116
+ const KEY__LEGACY_SHADOW_TOKEN_PRIVATE = '$$LegacyShadowTokenKey$$';
114
117
  const KEY__SYNTHETIC_MODE = '$$lwc-synthetic-mode';
115
118
  const KEY__NATIVE_GET_ELEMENT_BY_ID = '$nativeGetElementById$';
116
119
  const KEY__NATIVE_QUERY_SELECTOR_ALL = '$nativeQuerySelectorAll$';
117
-
118
- /*
119
- * Copyright (c) 2018, salesforce.com, inc.
120
- * All rights reserved.
121
- * SPDX-License-Identifier: MIT
122
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
123
- */
124
- // We use this to detect symbol support in order to avoid the expensive symbol polyfill. Note that
125
- // we can't use typeof since it will fail when transpiling.
126
- const hasNativeSymbolSupport = /*@__PURE__*/ (() => Symbol('x').toString() === 'Symbol(x)')();
127
- /** version: 3.0.1 */
120
+ /** version: 3.0.3 */
128
121
 
129
122
  /**
130
123
  * Copyright (C) 2023 salesforce.com, inc.
@@ -133,7 +126,7 @@ const hasNativeSymbolSupport = /*@__PURE__*/ (() => Symbol('x').toString() === '
133
126
  if (!_globalThis.lwcRuntimeFlags) {
134
127
  Object.defineProperty(_globalThis, 'lwcRuntimeFlags', { value: create(null) });
135
128
  }
136
- /** version: 3.0.1 */
129
+ /** version: 3.0.3 */
137
130
 
138
131
  /*
139
132
  * Copyright (c) 2018, salesforce.com, inc.
@@ -153,13 +146,9 @@ const lastChildGetter = getOwnPropertyDescriptor(nodePrototype, 'lastChild').get
153
146
  const textContentGetter = getOwnPropertyDescriptor(nodePrototype, 'textContent').get;
154
147
  const parentNodeGetter = getOwnPropertyDescriptor(nodePrototype, 'parentNode').get;
155
148
  const ownerDocumentGetter = getOwnPropertyDescriptor(nodePrototype, 'ownerDocument').get;
156
- const parentElementGetter = hasOwnProperty.call(nodePrototype, 'parentElement')
157
- ? getOwnPropertyDescriptor(nodePrototype, 'parentElement').get
158
- : getOwnPropertyDescriptor(HTMLElement.prototype, 'parentElement').get; // IE11
149
+ const parentElementGetter = getOwnPropertyDescriptor(nodePrototype, 'parentElement').get;
159
150
  const textContextSetter = getOwnPropertyDescriptor(nodePrototype, 'textContent').set;
160
- const childNodesGetter = hasOwnProperty.call(nodePrototype, 'childNodes')
161
- ? getOwnPropertyDescriptor(nodePrototype, 'childNodes').get
162
- : getOwnPropertyDescriptor(HTMLElement.prototype, 'childNodes').get; // IE11
151
+ const childNodesGetter = getOwnPropertyDescriptor(nodePrototype, 'childNodes').get;
163
152
  const isConnected = hasOwnProperty.call(nodePrototype, 'isConnected')
164
153
  ? getOwnPropertyDescriptor(nodePrototype, 'isConnected').get
165
154
  : function () {
@@ -202,26 +191,18 @@ const outerTextGetter = outerTextDescriptor
202
191
  const outerTextSetter = outerTextDescriptor
203
192
  ? outerTextDescriptor.set
204
193
  : null;
205
- const innerHTMLDescriptor = hasOwnProperty.call(Element.prototype, 'innerHTML')
206
- ? getOwnPropertyDescriptor(Element.prototype, 'innerHTML')
207
- : getOwnPropertyDescriptor(HTMLElement.prototype, 'innerHTML'); // IE11
194
+ const innerHTMLDescriptor = getOwnPropertyDescriptor(Element.prototype, 'innerHTML');
208
195
  const innerHTMLGetter = innerHTMLDescriptor.get;
209
196
  const innerHTMLSetter = innerHTMLDescriptor.set;
210
- const outerHTMLDescriptor = hasOwnProperty.call(Element.prototype, 'outerHTML')
211
- ? getOwnPropertyDescriptor(Element.prototype, 'outerHTML')
212
- : getOwnPropertyDescriptor(HTMLElement.prototype, 'outerHTML'); // IE11
197
+ const outerHTMLDescriptor = getOwnPropertyDescriptor(Element.prototype, 'outerHTML');
213
198
  const outerHTMLGetter = outerHTMLDescriptor.get;
214
199
  const outerHTMLSetter = outerHTMLDescriptor.set;
215
200
  const tagNameGetter = getOwnPropertyDescriptor(Element.prototype, 'tagName').get;
216
201
  const tabIndexDescriptor = getOwnPropertyDescriptor(HTMLElement.prototype, 'tabIndex');
217
202
  const tabIndexGetter = tabIndexDescriptor.get;
218
203
  const tabIndexSetter = tabIndexDescriptor.set;
219
- const matches = hasOwnProperty.call(Element.prototype, 'matches')
220
- ? Element.prototype.matches
221
- : Element.prototype.msMatchesSelector; // IE11
222
- const childrenGetter = hasOwnProperty.call(Element.prototype, 'children')
223
- ? getOwnPropertyDescriptor(Element.prototype, 'children').get
224
- : getOwnPropertyDescriptor(HTMLElement.prototype, 'children').get; // IE11
204
+ const matches = Element.prototype.matches;
205
+ const childrenGetter = getOwnPropertyDescriptor(Element.prototype, 'children').get;
225
206
  // for IE11, access from HTMLElement
226
207
  // for all other browsers access the method from the parent Element interface
227
208
  const { getElementsByClassName: getElementsByClassName$1 } = HTMLElement.prototype;
@@ -275,16 +256,12 @@ const composedPath = hasOwnProperty.call(Event.prototype, 'composedPath')
275
256
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
276
257
  */
277
258
  const DocumentPrototypeActiveElement = getOwnPropertyDescriptor(Document.prototype, 'activeElement').get;
278
- const elementFromPoint = hasOwnProperty.call(Document.prototype, 'elementFromPoint')
279
- ? Document.prototype.elementFromPoint
280
- : Document.prototype.msElementFromPoint; // IE11
281
- const elementsFromPoint = hasOwnProperty.call(Document.prototype, 'elementsFromPoint')
282
- ? Document.prototype.elementsFromPoint
283
- : Document.prototype.msElementsFromPoint; // IE11
259
+ const elementFromPoint = Document.prototype.elementFromPoint;
260
+ const elementsFromPoint = Document.prototype.elementsFromPoint;
284
261
  // defaultView can be null when a document has no browsing context. For example, the owner document
285
262
  // of a node in a template doesn't have a default view: https://jsfiddle.net/hv9z0q5a/
286
263
  const defaultViewGetter = getOwnPropertyDescriptor(Document.prototype, 'defaultView').get;
287
- const { createComment, querySelectorAll, getElementById, getElementsByClassName, getElementsByTagName, getElementsByTagNameNS, } = Document.prototype;
264
+ const { querySelectorAll, getElementById, getElementsByClassName, getElementsByTagName, getElementsByTagNameNS, } = Document.prototype;
288
265
  // In Firefox v57 and lower, getElementsByName is defined on HTMLDocument.prototype
289
266
  // In all other browsers have the method on Document.prototype
290
267
  const { getElementsByName } = HTMLDocument.prototype;
@@ -330,7 +307,7 @@ const isInstanceOfNativeShadowRoot = isNull(NativeShadowRoot)
330
307
  * SPDX-License-Identifier: MIT
331
308
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
332
309
  */
333
- function detect$4 () {
310
+ function detect$2 () {
334
311
  return typeof HTMLSlotElement === 'undefined';
335
312
  }
336
313
 
@@ -345,7 +322,7 @@ const CHAR_S = 115;
345
322
  const CHAR_L = 108;
346
323
  const CHAR_O = 111;
347
324
  const CHAR_T = 116;
348
- function apply$4() {
325
+ function apply$2() {
349
326
  // IE11 does not have this element definition
350
327
  // we don't care much about the construction phase, just the prototype
351
328
  class HTMLSlotElement {
@@ -380,8 +357,8 @@ function apply$4() {
380
357
  * SPDX-License-Identifier: MIT
381
358
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
382
359
  */
383
- if (detect$4()) {
384
- apply$4();
360
+ if (detect$2()) {
361
+ apply$2();
385
362
  }
386
363
 
387
364
  /*
@@ -1282,15 +1259,6 @@ function childNodesGetterPatched() {
1282
1259
  if (isSyntheticShadowHost(this)) {
1283
1260
  const owner = getNodeOwner(this);
1284
1261
  const childNodes = isNull(owner) ? [] : getAllMatches(owner, getFilteredChildNodes(this));
1285
- if (process.env.NODE_ENV !== 'production' &&
1286
- isFalse(hasNativeSymbolSupport) &&
1287
- isExternalChildNodeAccessorFlagOn()) {
1288
- // inserting a comment node as the first childNode to trick the IE11
1289
- // DevTool to show the content of the shadowRoot, this should only happen
1290
- // in dev-mode and in IE11 (which we detect by looking at the symbol).
1291
- // Plus it should only be in place if we know it is an external invoker.
1292
- ArrayUnshift.call(childNodes, getIE11FakeShadowRootPlaceholder(this));
1293
- }
1294
1262
  return createStaticNodeList(childNodes);
1295
1263
  }
1296
1264
  // nothing to do here since this does not have a synthetic shadow attached to it
@@ -1505,40 +1473,9 @@ defineProperties(_Node.prototype, {
1505
1473
  },
1506
1474
  },
1507
1475
  });
1508
- let internalChildNodeAccessorFlag = false;
1509
- /**
1510
- * These 2 methods are providing a machinery to understand who is accessing the
1511
- * .childNodes member property of a node. If it is used from inside the synthetic shadow
1512
- * or from an external invoker. This helps to produce the right output in one very peculiar
1513
- * case, the IE11 debugging comment for shadowRoot representation on the devtool.
1514
- */
1515
- function isExternalChildNodeAccessorFlagOn() {
1516
- return !internalChildNodeAccessorFlag;
1517
- }
1518
- const getInternalChildNodes = process.env.NODE_ENV !== 'production' && isFalse(hasNativeSymbolSupport)
1519
- ? function (node) {
1520
- internalChildNodeAccessorFlag = true;
1521
- let childNodes;
1522
- let error = null;
1523
- try {
1524
- childNodes = node.childNodes;
1525
- }
1526
- catch (e) {
1527
- // childNodes accessor should never throw, but just in case!
1528
- error = e;
1529
- }
1530
- finally {
1531
- internalChildNodeAccessorFlag = false;
1532
- if (!isNull(error)) {
1533
- // re-throwing after restoring the state machinery for setInternalChildNodeAccessorFlag
1534
- throw error; // eslint-disable-line no-unsafe-finally
1535
- }
1536
- }
1537
- return childNodes;
1538
- }
1539
- : function (node) {
1540
- return node.childNodes;
1541
- };
1476
+ const getInternalChildNodes = function (node) {
1477
+ return node.childNodes;
1478
+ };
1542
1479
  // IE11 extra patches for wrong prototypes
1543
1480
  if (hasOwnProperty.call(HTMLElement.prototype, 'contains')) {
1544
1481
  defineProperty(HTMLElement.prototype, 'contains', getOwnPropertyDescriptor(_Node.prototype, 'contains'));
@@ -2346,42 +2283,6 @@ defineProperty(SyntheticShadowRoot, Symbol.hasInstance, {
2346
2283
  getPrototypeOf(object) === SyntheticShadowRoot.prototype));
2347
2284
  },
2348
2285
  });
2349
- /**
2350
- * This method is only intended to be used in non-production mode in IE11
2351
- * and its role is to produce a 1-1 mapping between a shadowRoot instance
2352
- * and a comment node that is intended to use to trick the IE11 DevTools
2353
- * to show the content of the shadowRoot in the DOM Explorer.
2354
- */
2355
- function getIE11FakeShadowRootPlaceholder(host) {
2356
- const shadowRoot = getShadowRoot(host);
2357
- // @ts-ignore this $$placeholder$$ is not a security issue because you must
2358
- // have access to the shadowRoot in order to extract the fake node, which give
2359
- // you access to the same childNodes of the shadowRoot, so, who cares.
2360
- let c = shadowRoot.$$placeholder$$;
2361
- if (!isUndefined(c)) {
2362
- return c;
2363
- }
2364
- const doc = getOwnerDocument(host);
2365
- // @ts-ignore $$placeholder$$ is fine, read the node above.
2366
- c = shadowRoot.$$placeholder$$ = createComment.call(doc, '');
2367
- defineProperties(c, {
2368
- childNodes: {
2369
- get() {
2370
- return shadowRoot.childNodes;
2371
- },
2372
- enumerable: true,
2373
- configurable: true,
2374
- },
2375
- tagName: {
2376
- get() {
2377
- return `#shadow-root (${shadowRoot.mode})`;
2378
- },
2379
- enumerable: true,
2380
- configurable: true,
2381
- },
2382
- });
2383
- return c;
2384
- }
2385
2286
 
2386
2287
  /*
2387
2288
  * Copyright (c) 2018, salesforce.com, inc.
@@ -2660,7 +2561,7 @@ Object.defineProperty(window, 'ShadowRoot', {
2660
2561
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2661
2562
  */
2662
2563
  const composedDescriptor = Object.getOwnPropertyDescriptor(Event.prototype, 'composed');
2663
- function detect$3() {
2564
+ function detect$1() {
2664
2565
  if (!composedDescriptor) {
2665
2566
  // No need to apply this polyfill if this client completely lacks
2666
2567
  // support for the composed property.
@@ -2692,7 +2593,7 @@ function handleClick(event) {
2692
2593
  },
2693
2594
  });
2694
2595
  }
2695
- function apply$3() {
2596
+ function apply$1() {
2696
2597
  HTMLElement.prototype.click = function () {
2697
2598
  addEventListener.call(this, 'click', handleClick);
2698
2599
  try {
@@ -2710,8 +2611,8 @@ function apply$3() {
2710
2611
  * SPDX-License-Identifier: MIT
2711
2612
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2712
2613
  */
2713
- if (detect$3()) {
2714
- apply$3();
2614
+ if (detect$1()) {
2615
+ apply$1();
2715
2616
  }
2716
2617
 
2717
2618
  /*
@@ -2720,7 +2621,7 @@ if (detect$3()) {
2720
2621
  * SPDX-License-Identifier: MIT
2721
2622
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2722
2623
  */
2723
- function detect$2() {
2624
+ function detect() {
2724
2625
  return new Event('test', { composed: true }).composed !== true;
2725
2626
  }
2726
2627
 
@@ -2730,7 +2631,7 @@ function detect$2() {
2730
2631
  * SPDX-License-Identifier: MIT
2731
2632
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2732
2633
  */
2733
- function apply$2() {
2634
+ function apply() {
2734
2635
  // https://github.com/w3c/webcomponents/issues/513#issuecomment-224183937
2735
2636
  const composedEvents = assign(create(null), {
2736
2637
  beforeinput: 1,
@@ -2824,8 +2725,8 @@ function apply$2() {
2824
2725
  * SPDX-License-Identifier: MIT
2825
2726
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2826
2727
  */
2827
- if (detect$2()) {
2828
- apply$2();
2728
+ if (detect()) {
2729
+ apply();
2829
2730
  }
2830
2731
 
2831
2732
  /*
@@ -2877,121 +2778,6 @@ if (typeof ClipboardEvent !== 'undefined') {
2877
2778
  });
2878
2779
  }
2879
2780
 
2880
- /*
2881
- * Copyright (c) 2018, salesforce.com, inc.
2882
- * All rights reserved.
2883
- * SPDX-License-Identifier: MIT
2884
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2885
- */
2886
- function detect$1() {
2887
- // Note: when using this in mobile apps, we might have a DOM that does not support iframes.
2888
- const hasIframe = typeof HTMLIFrameElement !== 'undefined';
2889
- // This polyfill should only apply in compat mode; see https://github.com/salesforce/lwc/issues/1513
2890
- const isCompat = typeof Proxy !== 'undefined' && isTrue(Proxy.isCompat);
2891
- return hasIframe && isCompat;
2892
- }
2893
-
2894
- /*
2895
- * Copyright (c) 2018, salesforce.com, inc.
2896
- * All rights reserved.
2897
- * SPDX-License-Identifier: MIT
2898
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2899
- */
2900
- function apply$1() {
2901
- // the iframe property descriptor for `contentWindow` should always be available, otherwise this method should never be called
2902
- const desc = getOwnPropertyDescriptor(HTMLIFrameElement.prototype, 'contentWindow');
2903
- const { get: originalGetter } = desc;
2904
- desc.get = function () {
2905
- const original = originalGetter.call(this);
2906
- // If the original iframe element is not a keyed node, then do not wrap it
2907
- if (isNull(original) || isUndefined(getNodeOwnerKey(this))) {
2908
- return original;
2909
- }
2910
- // only if the element is an iframe inside a shadowRoot, we care about this problem
2911
- // because in that case, the code that is accessing the iframe, is very likely code
2912
- // compiled with proxy-compat transformation. It is true that other code without those
2913
- // transformations might also access an iframe from within a shadowRoot, but in that,
2914
- // case, which is more rare, we still return the wrapper, and it should work the same,
2915
- // this part is just an optimization.
2916
- return wrapIframeWindow(original);
2917
- };
2918
- defineProperty(HTMLIFrameElement.prototype, 'contentWindow', desc);
2919
- }
2920
- function wrapIframeWindow(win) {
2921
- return {
2922
- addEventListener() {
2923
- // Typescript does not like it when you treat the `arguments` object as an array
2924
- // @ts-ignore type-mismatch
2925
- return win.addEventListener.apply(win, arguments);
2926
- },
2927
- blur() {
2928
- // Typescript does not like it when you treat the `arguments` object as an array
2929
- // @ts-ignore type-mismatch
2930
- return win.blur.apply(win, arguments);
2931
- },
2932
- close() {
2933
- // Typescript does not like it when you treat the `arguments` object as an array
2934
- // @ts-ignore type-mismatch
2935
- return win.close.apply(win, arguments);
2936
- },
2937
- focus() {
2938
- // Typescript does not like it when you treat the `arguments` object as an array
2939
- // @ts-ignore type-mismatch
2940
- return win.focus.apply(win, arguments);
2941
- },
2942
- postMessage() {
2943
- // Typescript does not like it when you treat the `arguments` object as an array
2944
- // @ts-ignore type-mismatch
2945
- return win.postMessage.apply(win, arguments);
2946
- },
2947
- removeEventListener() {
2948
- // Typescript does not like it when you treat the `arguments` object as an array
2949
- // @ts-ignore type-mismatch
2950
- return win.removeEventListener.apply(win, arguments);
2951
- },
2952
- get closed() {
2953
- return win.closed;
2954
- },
2955
- get frames() {
2956
- return win.frames;
2957
- },
2958
- get length() {
2959
- return win.length;
2960
- },
2961
- get location() {
2962
- return win.location;
2963
- },
2964
- set location(value) {
2965
- win.location = value;
2966
- },
2967
- get opener() {
2968
- return win.opener;
2969
- },
2970
- get parent() {
2971
- return win.parent;
2972
- },
2973
- get self() {
2974
- return win.self;
2975
- },
2976
- get top() {
2977
- return win.top;
2978
- },
2979
- get window() {
2980
- return win.window;
2981
- },
2982
- }; // this is limited
2983
- }
2984
-
2985
- /*
2986
- * Copyright (c) 2018, salesforce.com, inc.
2987
- * All rights reserved.
2988
- * SPDX-License-Identifier: MIT
2989
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2990
- */
2991
- if (detect$1()) {
2992
- apply$1();
2993
- }
2994
-
2995
2781
  /*
2996
2782
  * Copyright (c) 2018, salesforce.com, inc.
2997
2783
  * All rights reserved.
@@ -3233,7 +3019,7 @@ defineProperty(window, 'MutationObserver', {
3233
3019
  * SPDX-License-Identifier: MIT
3234
3020
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3235
3021
  */
3236
- function patchedAddEventListener$1(type, listener, optionsOrCapture) {
3022
+ function patchedAddEventListener(type, listener, optionsOrCapture) {
3237
3023
  if (isSyntheticShadowHost(this)) {
3238
3024
  // Typescript does not like it when you treat the `arguments` object as an array
3239
3025
  // @ts-ignore type-mismatch
@@ -3256,7 +3042,7 @@ function patchedAddEventListener$1(type, listener, optionsOrCapture) {
3256
3042
  // The third argument is optional, so passing in `undefined` for `optionsOrCapture` gives capture=false
3257
3043
  return addEventListener.call(this, type, wrappedListener, optionsOrCapture);
3258
3044
  }
3259
- function patchedRemoveEventListener$1(_type, _listener, _optionsOrCapture) {
3045
+ function patchedRemoveEventListener(_type, _listener, _optionsOrCapture) {
3260
3046
  if (isSyntheticShadowHost(this)) {
3261
3047
  // Typescript does not like it when you treat the `arguments` object as an array
3262
3048
  // @ts-ignore type-mismatch
@@ -3276,87 +3062,19 @@ function patchedRemoveEventListener$1(_type, _listener, _optionsOrCapture) {
3276
3062
  }
3277
3063
  defineProperties(eventTargetPrototype, {
3278
3064
  addEventListener: {
3279
- value: patchedAddEventListener$1,
3065
+ value: patchedAddEventListener,
3280
3066
  enumerable: true,
3281
3067
  writable: true,
3282
3068
  configurable: true,
3283
3069
  },
3284
3070
  removeEventListener: {
3285
- value: patchedRemoveEventListener$1,
3071
+ value: patchedRemoveEventListener,
3286
3072
  enumerable: true,
3287
3073
  writable: true,
3288
3074
  configurable: true,
3289
3075
  },
3290
3076
  });
3291
3077
 
3292
- /*
3293
- * Copyright (c) 2018, salesforce.com, inc.
3294
- * All rights reserved.
3295
- * SPDX-License-Identifier: MIT
3296
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3297
- */
3298
- function detect() {
3299
- return typeof EventTarget === 'undefined';
3300
- }
3301
-
3302
- /*
3303
- * Copyright (c) 2018, salesforce.com, inc.
3304
- * All rights reserved.
3305
- * SPDX-License-Identifier: MIT
3306
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3307
- */
3308
- function patchedAddEventListener(_type, _listener, _options) {
3309
- if (arguments.length > 1) {
3310
- const args = ArraySlice.call(arguments);
3311
- args[1] = getEventListenerWrapper(args[1]);
3312
- // Ignore types because we're passing through to native method
3313
- // @ts-ignore type-mismatch
3314
- return windowAddEventListener.apply(this, args);
3315
- }
3316
- // Typescript does not like it when you treat the `arguments` object as an array
3317
- // @ts-ignore type-mismatch
3318
- return windowAddEventListener.apply(this, arguments);
3319
- }
3320
- function patchedRemoveEventListener(_type, _listener, _options) {
3321
- if (arguments.length > 1) {
3322
- const args = ArraySlice.call(arguments);
3323
- args[1] = getEventListenerWrapper(args[1]);
3324
- // Ignore types because we're passing through to native method
3325
- // @ts-ignore type-mismatch
3326
- windowRemoveEventListener.apply(this, args);
3327
- }
3328
- // Account for listeners that were added before this polyfill was applied
3329
- // Typescript does not like it when you treat the `arguments` object as an array
3330
- // @ts-ignore type-mismatch
3331
- windowRemoveEventListener.apply(this, arguments);
3332
- }
3333
- function apply() {
3334
- defineProperties(Window.prototype, {
3335
- addEventListener: {
3336
- value: patchedAddEventListener,
3337
- enumerable: true,
3338
- writable: true,
3339
- configurable: true,
3340
- },
3341
- removeEventListener: {
3342
- value: patchedRemoveEventListener,
3343
- enumerable: true,
3344
- writable: true,
3345
- configurable: true,
3346
- },
3347
- });
3348
- }
3349
-
3350
- /*
3351
- * Copyright (c) 2018, salesforce.com, inc.
3352
- * All rights reserved.
3353
- * SPDX-License-Identifier: MIT
3354
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3355
- */
3356
- if (detect()) {
3357
- apply();
3358
- }
3359
-
3360
3078
  /*
3361
3079
  * Copyright (c) 2018, salesforce.com, inc.
3362
3080
  * All rights reserved.
@@ -4638,6 +4356,40 @@ defineProperty(Element.prototype, KEY__SHADOW_STATIC, {
4638
4356
  configurable: true,
4639
4357
  });
4640
4358
 
4359
+ /*
4360
+ * Copyright (c) 2023, salesforce.com, inc.
4361
+ * All rights reserved.
4362
+ * SPDX-License-Identifier: MIT
4363
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4364
+ */
4365
+ // TODO [#3733]: remove this entire file when we can remove legacy scope tokens
4366
+ function getLegacyShadowToken(node) {
4367
+ return node[KEY__LEGACY_SHADOW_TOKEN];
4368
+ }
4369
+ function setLegacyShadowToken(node, shadowToken) {
4370
+ node[KEY__LEGACY_SHADOW_TOKEN] = shadowToken;
4371
+ }
4372
+ /**
4373
+ * Patching Element.prototype.$legacyShadowToken$ to mark elements a portal:
4374
+ * Same as $shadowToken$ but for legacy CSS scope tokens.
4375
+ **/
4376
+ defineProperty(Element.prototype, KEY__LEGACY_SHADOW_TOKEN, {
4377
+ set(shadowToken) {
4378
+ const oldShadowToken = this[KEY__LEGACY_SHADOW_TOKEN_PRIVATE];
4379
+ if (!isUndefined(oldShadowToken) && oldShadowToken !== shadowToken) {
4380
+ removeAttribute.call(this, oldShadowToken);
4381
+ }
4382
+ if (!isUndefined(shadowToken)) {
4383
+ setAttribute.call(this, shadowToken, '');
4384
+ }
4385
+ this[KEY__LEGACY_SHADOW_TOKEN_PRIVATE] = shadowToken;
4386
+ },
4387
+ get() {
4388
+ return this[KEY__LEGACY_SHADOW_TOKEN_PRIVATE];
4389
+ },
4390
+ configurable: true,
4391
+ });
4392
+
4641
4393
  /*
4642
4394
  * Copyright (c) 2018, salesforce.com, inc.
4643
4395
  * All rights reserved.
@@ -4655,7 +4407,8 @@ let portalObserver;
4655
4407
  const portalObserverConfig = {
4656
4408
  childList: true,
4657
4409
  };
4658
- function adoptChildNode(node, fn, shadowToken) {
4410
+ // TODO [#3733]: remove support for legacy scope tokens
4411
+ function adoptChildNode(node, fn, shadowToken, legacyShadowToken) {
4659
4412
  const previousNodeShadowResolver = getShadowRootResolver(node);
4660
4413
  if (previousNodeShadowResolver === fn) {
4661
4414
  return; // nothing to do here, it is already correctly patched
@@ -4663,6 +4416,9 @@ function adoptChildNode(node, fn, shadowToken) {
4663
4416
  setShadowRootResolver(node, fn);
4664
4417
  if (node instanceof Element) {
4665
4418
  setShadowToken(node, shadowToken);
4419
+ if (lwcRuntimeFlags.ENABLE_LEGACY_SCOPE_TOKENS) {
4420
+ setLegacyShadowToken(node, legacyShadowToken);
4421
+ }
4666
4422
  if (isSyntheticShadowHost(node)) {
4667
4423
  // Root LWC elements can't get content slotted into them, therefore we don't observe their children.
4668
4424
  return;
@@ -4674,7 +4430,7 @@ function adoptChildNode(node, fn, shadowToken) {
4674
4430
  // recursively patching all children as well
4675
4431
  const childNodes = childNodesGetter.call(node);
4676
4432
  for (let i = 0, len = childNodes.length; i < len; i += 1) {
4677
- adoptChildNode(childNodes[i], fn, shadowToken);
4433
+ adoptChildNode(childNodes[i], fn, shadowToken, legacyShadowToken);
4678
4434
  }
4679
4435
  }
4680
4436
  }
@@ -4695,17 +4451,20 @@ function initPortalObserver() {
4695
4451
  // the target of the mutation should always have a ShadowRootResolver attached to it
4696
4452
  const fn = getShadowRootResolver(elm);
4697
4453
  const shadowToken = getShadowToken(elm);
4454
+ const legacyShadowToken = lwcRuntimeFlags.ENABLE_LEGACY_SCOPE_TOKENS
4455
+ ? getLegacyShadowToken(elm)
4456
+ : undefined;
4698
4457
  // Process removals first to handle the case where an element is removed and reinserted
4699
4458
  for (let i = 0, len = removedNodes.length; i < len; i += 1) {
4700
4459
  const node = removedNodes[i];
4701
4460
  if (!(compareDocumentPosition.call(elm, node) & _Node.DOCUMENT_POSITION_CONTAINED_BY)) {
4702
- adoptChildNode(node, DocumentResolverFn, undefined);
4461
+ adoptChildNode(node, DocumentResolverFn, undefined, undefined);
4703
4462
  }
4704
4463
  }
4705
4464
  for (let i = 0, len = addedNodes.length; i < len; i += 1) {
4706
4465
  const node = addedNodes[i];
4707
4466
  if (compareDocumentPosition.call(elm, node) & _Node.DOCUMENT_POSITION_CONTAINED_BY) {
4708
- adoptChildNode(node, fn, shadowToken);
4467
+ adoptChildNode(node, fn, shadowToken, legacyShadowToken);
4709
4468
  }
4710
4469
  }
4711
4470
  });
@@ -4752,5 +4511,5 @@ defineProperty(Element.prototype, '$domManual$', {
4752
4511
  },
4753
4512
  configurable: true,
4754
4513
  });
4755
- /** version: 3.0.1 */
4514
+ /** version: 3.0.3 */
4756
4515
  //# sourceMappingURL=index.cjs.js.map