@lwc/synthetic-shadow 6.2.0 → 6.3.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/faux-shadow/events.d.ts +1 -0
- package/dist/faux-shadow/no-patch-utils.d.ts +2 -0
- package/dist/faux-shadow/node.d.ts +1 -0
- package/dist/index.cjs.js +170 -66
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +170 -66
- package/dist/index.js.map +1 -1
- package/dist/shared/node-ownership.d.ts +1 -0
- package/dist/shared/utils.d.ts +1 -0
- package/package.json +3 -3
package/dist/index.js
CHANGED
@@ -14,21 +14,40 @@ if (!lwcRuntimeFlags.ENABLE_FORCE_SHADOW_MIGRATE_MODE) {
|
|
14
14
|
* SPDX-License-Identifier: MIT
|
15
15
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
16
16
|
*/
|
17
|
+
/**
|
18
|
+
*
|
19
|
+
* @param value
|
20
|
+
* @param msg
|
21
|
+
*/
|
17
22
|
function invariant(value, msg) {
|
18
23
|
if (!value) {
|
19
24
|
throw new Error(`Invariant Violation: ${msg}`);
|
20
25
|
}
|
21
26
|
}
|
27
|
+
/**
|
28
|
+
*
|
29
|
+
* @param value
|
30
|
+
* @param msg
|
31
|
+
*/
|
22
32
|
function isTrue$1(value, msg) {
|
23
33
|
if (!value) {
|
24
34
|
throw new Error(`Assert Violation: ${msg}`);
|
25
35
|
}
|
26
36
|
}
|
37
|
+
/**
|
38
|
+
*
|
39
|
+
* @param value
|
40
|
+
* @param msg
|
41
|
+
*/
|
27
42
|
function isFalse$1(value, msg) {
|
28
43
|
if (value) {
|
29
44
|
throw new Error(`Assert Violation: ${msg}`);
|
30
45
|
}
|
31
46
|
}
|
47
|
+
/**
|
48
|
+
*
|
49
|
+
* @param msg
|
50
|
+
*/
|
32
51
|
function fail(msg) {
|
33
52
|
throw new Error(msg);
|
34
53
|
}
|
@@ -42,50 +61,132 @@ var assert = /*#__PURE__*/Object.freeze({
|
|
42
61
|
});
|
43
62
|
|
44
63
|
/*
|
45
|
-
* Copyright (c)
|
64
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
46
65
|
* All rights reserved.
|
47
66
|
* SPDX-License-Identifier: MIT
|
48
67
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
49
68
|
*/
|
50
|
-
const {
|
69
|
+
const {
|
70
|
+
/** Detached {@linkcode Object.assign}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign MDN Reference}. */
|
71
|
+
assign,
|
72
|
+
/** Detached {@linkcode Object.create}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create MDN Reference}. */
|
73
|
+
create,
|
74
|
+
/** Detached {@linkcode Object.defineProperties}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperties MDN Reference}. */
|
75
|
+
defineProperties,
|
76
|
+
/** Detached {@linkcode Object.defineProperty}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty MDN Reference}. */
|
77
|
+
defineProperty,
|
78
|
+
/** Detached {@linkcode Object.entries}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries MDN Reference}. */
|
79
|
+
entries,
|
80
|
+
/** Detached {@linkcode Object.freeze}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze MDN Reference}. */
|
81
|
+
freeze,
|
82
|
+
/** Detached {@linkcode Object.getOwnPropertyDescriptor}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor MDN Reference}. */
|
83
|
+
getOwnPropertyDescriptor,
|
84
|
+
/** Detached {@linkcode Object.getOwnPropertyDescriptors}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptors MDN Reference}. */
|
85
|
+
getOwnPropertyDescriptors,
|
86
|
+
/** Detached {@linkcode Object.getOwnPropertyNames}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames MDN Reference}. */
|
87
|
+
getOwnPropertyNames,
|
88
|
+
/** Detached {@linkcode Object.getPrototypeOf}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf MDN Reference}. */
|
89
|
+
getPrototypeOf,
|
90
|
+
/** Detached {@linkcode Object.hasOwnProperty}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty MDN Reference}. */
|
91
|
+
hasOwnProperty,
|
92
|
+
/** Detached {@linkcode Object.isFrozen}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isFrozen MDN Reference}. */
|
93
|
+
isFrozen,
|
94
|
+
/** Detached {@linkcode Object.keys}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys MDN Reference}. */
|
95
|
+
keys,
|
96
|
+
/** Detached {@linkcode Object.seal}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/seal MDN Reference}. */
|
97
|
+
seal,
|
98
|
+
/** Detached {@linkcode Object.setPrototypeOf}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf MDN Reference}. */
|
99
|
+
setPrototypeOf, } = Object;
|
100
|
+
/** Detached {@linkcode Array.isArray}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray MDN Reference}. */
|
51
101
|
const { isArray } = Array;
|
52
|
-
|
102
|
+
// For some reason, JSDoc don't get picked up for multiple renamed destructured constants (even
|
103
|
+
// though it works fine for one, e.g. isArray), so comments for these are added to the export
|
104
|
+
// statement, rather than this declaration.
|
105
|
+
const { concat: ArrayConcat, copyWithin: ArrayCopyWithin, every: ArrayEvery, fill: ArrayFill, filter: ArrayFilter, find: ArrayFind, findIndex: ArrayFindIndex, includes: ArrayIncludes, indexOf: ArrayIndexOf, join: ArrayJoin, map: ArrayMap, pop: ArrayPop, push: ArrayPush, reduce: ArrayReduce, reverse: ArrayReverse, shift: ArrayShift, slice: ArraySlice, some: ArraySome, sort: ArraySort, splice: ArraySplice, unshift: ArrayUnshift, forEach, // Weird anomaly!
|
106
|
+
} = Array.prototype;
|
107
|
+
/**
|
108
|
+
* Determines whether the argument is `undefined`.
|
109
|
+
* @param obj Value to test
|
110
|
+
* @returns `true` if the value is `undefined`.
|
111
|
+
*/
|
53
112
|
function isUndefined(obj) {
|
54
113
|
return obj === undefined;
|
55
114
|
}
|
115
|
+
/**
|
116
|
+
* Determines whether the argument is `null`.
|
117
|
+
* @param obj Value to test
|
118
|
+
* @returns `true` if the value is `null`.
|
119
|
+
*/
|
56
120
|
function isNull(obj) {
|
57
121
|
return obj === null;
|
58
122
|
}
|
123
|
+
/**
|
124
|
+
* Determines whether the argument is `true`.
|
125
|
+
* @param obj Value to test
|
126
|
+
* @returns `true` if the value is `true`.
|
127
|
+
*/
|
59
128
|
function isTrue(obj) {
|
60
129
|
return obj === true;
|
61
130
|
}
|
131
|
+
/**
|
132
|
+
* Determines whether the argument is `false`.
|
133
|
+
* @param obj Value to test
|
134
|
+
* @returns `true` if the value is `false`.
|
135
|
+
*/
|
62
136
|
function isFalse(obj) {
|
63
137
|
return obj === false;
|
64
138
|
}
|
139
|
+
/**
|
140
|
+
* Determines whether the argument is a function.
|
141
|
+
* @param obj Value to test
|
142
|
+
* @returns `true` if the value is a function.
|
143
|
+
*/
|
65
144
|
// Replacing `Function` with a narrower type that works for all our use cases is tricky...
|
66
145
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
67
146
|
function isFunction(obj) {
|
68
147
|
return typeof obj === 'function';
|
69
148
|
}
|
149
|
+
/**
|
150
|
+
* Determines whether the argument is an object or null.
|
151
|
+
* @param obj Value to test
|
152
|
+
* @returns `true` if the value is an object or null.
|
153
|
+
*/
|
70
154
|
function isObject(obj) {
|
71
155
|
return typeof obj === 'object';
|
72
156
|
}
|
73
157
|
const OtS = {}.toString;
|
158
|
+
/**
|
159
|
+
* Converts the argument to a string, safely accounting for objects with "null" prototype.
|
160
|
+
* Note that `toString(null)` returns `"[object Null]"` rather than `"null"`.
|
161
|
+
* @param obj Value to convert to a string.
|
162
|
+
* @returns String representation of the value.
|
163
|
+
*/
|
74
164
|
function toString(obj) {
|
75
|
-
if (obj
|
165
|
+
if (obj?.toString) {
|
76
166
|
// Arrays might hold objects with "null" prototype So using
|
77
167
|
// Array.prototype.toString directly will cause an error Iterate through
|
78
168
|
// all the items and handle individually.
|
79
169
|
if (isArray(obj)) {
|
170
|
+
// This behavior is slightly different from Array#toString:
|
171
|
+
// 1. Array#toString calls `this.join`, rather than Array#join
|
172
|
+
// Ex: arr = []; arr.join = () => 1; arr.toString() === 1; toString(arr) === ''
|
173
|
+
// 2. Array#toString delegates to Object#toString if `this.join` is not a function
|
174
|
+
// Ex: arr = []; arr.join = 'no'; arr.toString() === '[object Array]; toString(arr) = ''
|
175
|
+
// 3. Array#toString converts null/undefined to ''
|
176
|
+
// Ex: arr = [null, undefined]; arr.toString() === ','; toString(arr) === '[object Null],undefined'
|
177
|
+
// 4. Array#toString converts recursive references to arrays to ''
|
178
|
+
// Ex: arr = [1]; arr.push(arr, 2); arr.toString() === '1,,2'; toString(arr) throws
|
179
|
+
// Ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toString
|
80
180
|
return ArrayJoin.call(ArrayMap.call(obj, toString), ',');
|
81
181
|
}
|
82
182
|
return obj.toString();
|
83
183
|
}
|
84
184
|
else if (typeof obj === 'object') {
|
185
|
+
// This catches null and returns "[object Null]". Weird, but kept for backwards compatibility.
|
85
186
|
return OtS.call(obj);
|
86
187
|
}
|
87
188
|
else {
|
88
|
-
return obj
|
189
|
+
return String(obj);
|
89
190
|
}
|
90
191
|
}
|
91
192
|
|
@@ -107,7 +208,7 @@ const KEY__LEGACY_SHADOW_TOKEN_PRIVATE = '$$LegacyShadowTokenKey$$';
|
|
107
208
|
const KEY__SYNTHETIC_MODE = '$$lwc-synthetic-mode';
|
108
209
|
const KEY__NATIVE_GET_ELEMENT_BY_ID = '$nativeGetElementById$';
|
109
210
|
const KEY__NATIVE_QUERY_SELECTOR_ALL = '$nativeQuerySelectorAll$';
|
110
|
-
/** version: 6.
|
211
|
+
/** version: 6.3.0 */
|
111
212
|
|
112
213
|
/**
|
113
214
|
* Copyright (c) 2024 Salesforce, Inc.
|
@@ -115,7 +216,7 @@ const KEY__NATIVE_QUERY_SELECTOR_ALL = '$nativeQuerySelectorAll$';
|
|
115
216
|
if (!globalThis.lwcRuntimeFlags) {
|
116
217
|
Object.defineProperty(globalThis, 'lwcRuntimeFlags', { value: create(null) });
|
117
218
|
}
|
118
|
-
/** version: 6.
|
219
|
+
/** version: 6.3.0 */
|
119
220
|
|
120
221
|
/*
|
121
222
|
* Copyright (c) 2018, salesforce.com, inc.
|
@@ -384,6 +485,7 @@ function getNodeKey(node) {
|
|
384
485
|
* This function does not traverse up for performance reasons, but is sufficient for most use
|
385
486
|
* cases. If we need to traverse up and verify those nodes that don't have owner key, use
|
386
487
|
* isNodeDeepShadowed instead.
|
488
|
+
* @param node
|
387
489
|
*/
|
388
490
|
function isNodeShadowed(node) {
|
389
491
|
return !isUndefined(getNodeOwnerKey(node));
|
@@ -440,7 +542,7 @@ function isNodeSlotted(host, node) {
|
|
440
542
|
// have different owner key. for slotted elements, this is possible
|
441
543
|
// if the parent happens to be a slot.
|
442
544
|
if (isSlotElement(parent)) {
|
443
|
-
|
545
|
+
/*
|
444
546
|
* the slot parent might be allocated inside another slot, think of:
|
445
547
|
* <x-root> (<--- root element)
|
446
548
|
* <x-parent> (<--- own by x-root)
|
@@ -595,7 +697,7 @@ function getFilteredChildNodes(node) {
|
|
595
697
|
const resolver = getShadowRootResolver(getShadowRoot(node));
|
596
698
|
// Typescript is inferring the wrong function type for this particular
|
597
699
|
// overloaded method: https://github.com/Microsoft/TypeScript/issues/27972
|
598
|
-
// @ts-
|
700
|
+
// @ts-expect-error type-mismatch
|
599
701
|
return ArrayReduce.call(slots, (seed, slot) => {
|
600
702
|
if (resolver === getShadowRootResolver(slot)) {
|
601
703
|
ArrayPush.apply(seed, getFilteredSlotAssignedNodes(slot));
|
@@ -1064,6 +1166,7 @@ function createStaticHTMLCollection(items) {
|
|
1064
1166
|
* based on the light-dom slotting mechanism. This applies to synthetic slot elements
|
1065
1167
|
* and elements with shadow dom attached to them. It doesn't apply to native slot elements
|
1066
1168
|
* because we don't want to patch the children getters for those elements.
|
1169
|
+
* @param node
|
1067
1170
|
*/
|
1068
1171
|
function hasMountedChildren(node) {
|
1069
1172
|
return isSyntheticSlotElement(node) || isSyntheticShadowHost(node);
|
@@ -1198,10 +1301,10 @@ const getDocumentOrRootNode = !isUndefined(nativeGetRootNode)
|
|
1198
1301
|
* Get the shadow root
|
1199
1302
|
* getNodeOwner() returns the host element that owns the given node
|
1200
1303
|
* Note: getNodeOwner() returns null when running in native-shadow mode.
|
1201
|
-
*
|
1202
|
-
*
|
1203
|
-
*
|
1204
|
-
* @param
|
1304
|
+
* Fallback to using the native getRootNode() to discover the root node.
|
1305
|
+
* This is because, it is not possible to inspect the node and decide if it is part
|
1306
|
+
* of a native shadow or the synthetic shadow.
|
1307
|
+
* @param node
|
1205
1308
|
*/
|
1206
1309
|
function getNearestRoot(node) {
|
1207
1310
|
const ownerNode = getNodeOwner(node);
|
@@ -1219,17 +1322,17 @@ function getNearestRoot(node) {
|
|
1219
1322
|
*
|
1220
1323
|
* If looking for a shadow root of a node by calling `node.getRootNode({composed: false})` or `node.getRootNode()`,
|
1221
1324
|
*
|
1222
|
-
*
|
1223
|
-
*
|
1224
|
-
*
|
1225
|
-
*
|
1226
|
-
*
|
1227
|
-
*
|
1228
|
-
*
|
1325
|
+
* 1. Try to identify the host element that owns the give node.
|
1326
|
+
* i. Identify the shadow tree that the node belongs to
|
1327
|
+
* ii. If the node belongs to a shadow tree created by engine, return the shadowRoot of the host element that owns the shadow tree
|
1328
|
+
* 2. The host identification logic returns null in two cases:
|
1329
|
+
* i. The node does not belong to a shadow tree created by engine
|
1330
|
+
* ii. The engine is running in native shadow dom mode
|
1331
|
+
* If so, use the original Node.prototype.getRootNode to fetch the root node(or manually climb up the dom tree where getRootNode() is unsupported)
|
1229
1332
|
*
|
1230
1333
|
* _Spec_: https://dom.spec.whatwg.org/#dom-node-getrootnode
|
1231
|
-
*
|
1232
|
-
|
1334
|
+
* @param options
|
1335
|
+
*/
|
1233
1336
|
function getRootNodePatched(options) {
|
1234
1337
|
const composed = isUndefined(options) ? false : !!options.composed;
|
1235
1338
|
return isTrue(composed) ? getDocumentOrRootNode.call(this, options) : getNearestRoot(this);
|
@@ -1481,6 +1584,7 @@ function getEventMap(elm) {
|
|
1481
1584
|
* Events dispatched on shadow roots actually end up being dispatched on their hosts. This means that the event.target
|
1482
1585
|
* property of events dispatched on shadow roots always resolve to their host. This function understands this
|
1483
1586
|
* abstraction and properly returns a reference to the shadow root when appropriate.
|
1587
|
+
* @param event
|
1484
1588
|
*/
|
1485
1589
|
function getActualTarget(event) {
|
1486
1590
|
return eventToShadowRootMap.get(event) ?? eventTargetGetter.call(event);
|
@@ -1912,7 +2016,7 @@ const NodePatchDescriptors = {
|
|
1912
2016
|
value(evt) {
|
1913
2017
|
eventToShadowRootMap.set(evt, this);
|
1914
2018
|
// Typescript does not like it when you treat the `arguments` object as an array
|
1915
|
-
// @ts-
|
2019
|
+
// @ts-expect-error type-mismatch
|
1916
2020
|
return dispatchEvent.apply(getHost(this), arguments);
|
1917
2021
|
},
|
1918
2022
|
},
|
@@ -2288,7 +2392,7 @@ function retarget(refNode, path) {
|
|
2288
2392
|
rootIdx = refNodePath.indexOf(root);
|
2289
2393
|
lastRoot = root;
|
2290
2394
|
}
|
2291
|
-
if (!
|
2395
|
+
if (!isUndefined(rootIdx) && rootIdx > -1) {
|
2292
2396
|
return ancestor;
|
2293
2397
|
}
|
2294
2398
|
}
|
@@ -2534,7 +2638,7 @@ function setNodeObservers(node, observers) {
|
|
2534
2638
|
}
|
2535
2639
|
/**
|
2536
2640
|
* Retarget the mutation record's target value to its shadowRoot
|
2537
|
-
* @param
|
2641
|
+
* @param originalRecord
|
2538
2642
|
*/
|
2539
2643
|
function retargetMutationRecord(originalRecord) {
|
2540
2644
|
const { addedNodes, removedNodes, target, type } = originalRecord;
|
@@ -2574,8 +2678,8 @@ function retargetMutationRecord(originalRecord) {
|
|
2574
2678
|
/**
|
2575
2679
|
* Utility to identify if a target node is being observed by the given observer
|
2576
2680
|
* Start at the current node, if the observer is registered to observe the current node, the mutation qualifies
|
2577
|
-
* @param
|
2578
|
-
* @param
|
2681
|
+
* @param observer
|
2682
|
+
* @param target
|
2579
2683
|
*/
|
2580
2684
|
function isQualifiedObserver(observer, target) {
|
2581
2685
|
let parentNode = target;
|
@@ -2596,8 +2700,8 @@ function isQualifiedObserver(observer, target) {
|
|
2596
2700
|
* The key logic here is to determine if a given observer has been registered to observe any nodes
|
2597
2701
|
* between the target node of a mutation record to the target's root node.
|
2598
2702
|
* This function also retargets records when mutations occur directly under the shadow root
|
2599
|
-
* @param
|
2600
|
-
* @param
|
2703
|
+
* @param mutations
|
2704
|
+
* @param observer
|
2601
2705
|
*/
|
2602
2706
|
function filterMutationRecords(mutations, observer) {
|
2603
2707
|
const result = [];
|
@@ -2679,7 +2783,7 @@ function getWrappedCallback(callback) {
|
|
2679
2783
|
* Patched MutationObserver constructor.
|
2680
2784
|
* 1. Wrap the callback to filter out MutationRecords based on dom ownership
|
2681
2785
|
* 2. Add a property field to track all observed targets of the observer instance
|
2682
|
-
* @param
|
2786
|
+
* @param callback
|
2683
2787
|
*/
|
2684
2788
|
function PatchedMutationObserver(callback) {
|
2685
2789
|
const wrappedCallback = getWrappedCallback(callback);
|
@@ -2706,8 +2810,8 @@ function patchedDisconnect() {
|
|
2706
2810
|
/**
|
2707
2811
|
* A single mutation observer can observe multiple nodes(target).
|
2708
2812
|
* Maintain a list of all targets that the observer chooses to observe
|
2709
|
-
* @param
|
2710
|
-
* @param
|
2813
|
+
* @param target
|
2814
|
+
* @param options
|
2711
2815
|
*/
|
2712
2816
|
function patchedObserve(target, options) {
|
2713
2817
|
let targetObservers = getNodeObservers(target);
|
@@ -2761,9 +2865,14 @@ defineProperty(window, 'MutationObserver', {
|
|
2761
2865
|
function patchedAddEventListener(type, listener, optionsOrCapture) {
|
2762
2866
|
if (isSyntheticShadowHost(this)) {
|
2763
2867
|
// Typescript does not like it when you treat the `arguments` object as an array
|
2764
|
-
// @ts-
|
2868
|
+
// @ts-expect-error type-mismatch
|
2765
2869
|
return addCustomElementEventListener.apply(this, arguments);
|
2766
2870
|
}
|
2871
|
+
if (this instanceof _Node && isInstanceOfNativeShadowRoot(this.getRootNode())) {
|
2872
|
+
// Typescript does not like it when you treat the `arguments` object as an array
|
2873
|
+
// @ts-expect-error type-mismatch
|
2874
|
+
return addEventListener.apply(this, arguments);
|
2875
|
+
}
|
2767
2876
|
if (arguments.length < 2) {
|
2768
2877
|
// Slow path, unlikely to be called frequently. We expect modern browsers to throw:
|
2769
2878
|
// https://googlechrome.github.io/samples/event-listeners-mandatory-arguments/
|
@@ -2772,7 +2881,7 @@ function patchedAddEventListener(type, listener, optionsOrCapture) {
|
|
2772
2881
|
args[1] = getEventListenerWrapper(args[1]);
|
2773
2882
|
}
|
2774
2883
|
// Ignore types because we're passing through to native method
|
2775
|
-
// @ts-
|
2884
|
+
// @ts-expect-error type-mismatch
|
2776
2885
|
return addEventListener.apply(this, args);
|
2777
2886
|
}
|
2778
2887
|
// Fast path. This function is optimized to avoid ArraySlice because addEventListener is called
|
@@ -2784,7 +2893,7 @@ function patchedAddEventListener(type, listener, optionsOrCapture) {
|
|
2784
2893
|
function patchedRemoveEventListener(_type, _listener, _optionsOrCapture) {
|
2785
2894
|
if (isSyntheticShadowHost(this)) {
|
2786
2895
|
// Typescript does not like it when you treat the `arguments` object as an array
|
2787
|
-
// @ts-
|
2896
|
+
// @ts-expect-error type-mismatch
|
2788
2897
|
return removeCustomElementEventListener.apply(this, arguments);
|
2789
2898
|
}
|
2790
2899
|
const args = ArraySlice.call(arguments);
|
@@ -2792,11 +2901,11 @@ function patchedRemoveEventListener(_type, _listener, _optionsOrCapture) {
|
|
2792
2901
|
args[1] = getEventListenerWrapper(args[1]);
|
2793
2902
|
}
|
2794
2903
|
// Ignore types because we're passing through to native method
|
2795
|
-
// @ts-
|
2904
|
+
// @ts-expect-error type-mismatch
|
2796
2905
|
removeEventListener.apply(this, args);
|
2797
2906
|
// Account for listeners that were added before this polyfill was applied
|
2798
2907
|
// Typescript does not like it when you treat the `arguments` object as an array
|
2799
|
-
// @ts-
|
2908
|
+
// @ts-expect-error type-mismatch
|
2800
2909
|
removeEventListener.apply(this, arguments);
|
2801
2910
|
}
|
2802
2911
|
defineProperties(eventTargetPrototype, {
|
@@ -3020,7 +3129,7 @@ function getFilteredSlotFlattenNodes(slot) {
|
|
3020
3129
|
const childNodes = arrayFromCollection(childNodesGetter.call(slot));
|
3021
3130
|
// Typescript is inferring the wrong function type for this particular
|
3022
3131
|
// overloaded method: https://github.com/Microsoft/TypeScript/issues/27972
|
3023
|
-
// @ts-
|
3132
|
+
// @ts-expect-error type-mismatch
|
3024
3133
|
return ArrayReduce.call(childNodes, (seed, child) => {
|
3025
3134
|
if (child instanceof Element && isSlotElement(child)) {
|
3026
3135
|
ArrayPush.apply(seed, getFilteredSlotFlattenNodes(child));
|
@@ -3045,9 +3154,8 @@ function assignedSlotGetterPatched() {
|
|
3045
3154
|
}
|
3046
3155
|
/**
|
3047
3156
|
* The node is assigned to a slot if:
|
3048
|
-
*
|
3049
|
-
*
|
3050
|
-
*
|
3157
|
+
* - it has a parent and its parent is a slot element
|
3158
|
+
* - and if the slot owner key is different than the node owner key.
|
3051
3159
|
* When the slot and the slotted node are 2 different shadow trees, the owner keys will be
|
3052
3160
|
* different. When the slot is in a shadow tree and the slotted content is a light DOM node,
|
3053
3161
|
* the light DOM node doesn't have an owner key and therefor the slot owner key will be
|
@@ -3162,6 +3270,8 @@ defineProperties(Text.prototype, {
|
|
3162
3270
|
/**
|
3163
3271
|
* This methods filters out elements that are not in the same shadow root of context.
|
3164
3272
|
* It does not enforce shadow dom semantics if $context is not managed by LWC
|
3273
|
+
* @param context
|
3274
|
+
* @param unfilteredNodes
|
3165
3275
|
*/
|
3166
3276
|
function getNonPatchedFilteredArrayOfNodes(context, unfilteredNodes) {
|
3167
3277
|
let filtered;
|
@@ -3573,7 +3683,7 @@ function hostElementFocus() {
|
|
3573
3683
|
// observable differences for component authors between synthetic and native.
|
3574
3684
|
const focusable = querySelector.call(this, FocusableSelector);
|
3575
3685
|
if (!isNull(focusable)) {
|
3576
|
-
// @ts-
|
3686
|
+
// @ts-expect-error type-mismatch
|
3577
3687
|
focusable.focus.apply(focusable, arguments);
|
3578
3688
|
}
|
3579
3689
|
return;
|
@@ -3589,7 +3699,7 @@ function hostElementFocus() {
|
|
3589
3699
|
let didFocus = false;
|
3590
3700
|
while (!didFocus && focusables.length !== 0) {
|
3591
3701
|
const focusable = focusables.shift();
|
3592
|
-
// @ts-
|
3702
|
+
// @ts-expect-error type-mismatch
|
3593
3703
|
focusable.focus.apply(focusable, arguments);
|
3594
3704
|
// Get the root node of the current focusable in case it was slotted.
|
3595
3705
|
const currentRootNode = focusable.getRootNode();
|
@@ -3870,6 +3980,7 @@ function tabIndexGetterPatched() {
|
|
3870
3980
|
}
|
3871
3981
|
/**
|
3872
3982
|
* This method only applies to elements with a shadow attached to them
|
3983
|
+
* @param value
|
3873
3984
|
*/
|
3874
3985
|
function tabIndexSetterPatched(value) {
|
3875
3986
|
// This tabIndex setter might be confusing unless it is understood that HTML
|
@@ -3951,7 +4062,7 @@ function focusPatched() {
|
|
3951
4062
|
return;
|
3952
4063
|
}
|
3953
4064
|
// Typescript does not like it when you treat the `arguments` object as an array
|
3954
|
-
// @ts-
|
4065
|
+
// @ts-expect-error type-mismatch
|
3955
4066
|
focus.apply(this, arguments);
|
3956
4067
|
// Restore state by enabling if originally enabled
|
3957
4068
|
if (originallyEnabled) {
|
@@ -3991,7 +4102,7 @@ defineProperties(HTMLElement.prototype, {
|
|
3991
4102
|
focus: {
|
3992
4103
|
value() {
|
3993
4104
|
// Typescript does not like it when you treat the `arguments` object as an array
|
3994
|
-
// @ts-
|
4105
|
+
// @ts-expect-error type-mismatch
|
3995
4106
|
focusPatched.apply(this, arguments);
|
3996
4107
|
},
|
3997
4108
|
enumerable: true,
|
@@ -4050,13 +4161,10 @@ function setShadowToken(node, shadowToken) {
|
|
4050
4161
|
}
|
4051
4162
|
/**
|
4052
4163
|
* Patching Element.prototype.$shadowToken$ to mark elements a portal:
|
4053
|
-
*
|
4054
|
-
*
|
4055
|
-
*
|
4056
|
-
|
4057
|
-
* - this custom attribute must be unique.
|
4058
|
-
*
|
4059
|
-
**/
|
4164
|
+
* - we use a property to allow engines to set a custom attribute that should be
|
4165
|
+
* placed into the element to sandbox the css rules defined for the template.
|
4166
|
+
* - this custom attribute must be unique.
|
4167
|
+
*/
|
4060
4168
|
defineProperty(Element.prototype, KEY__SHADOW_TOKEN, {
|
4061
4169
|
set(shadowToken) {
|
4062
4170
|
const oldShadowToken = this[KEY__SHADOW_TOKEN_PRIVATE];
|
@@ -4111,7 +4219,7 @@ function setLegacyShadowToken(node, shadowToken) {
|
|
4111
4219
|
/**
|
4112
4220
|
* Patching Element.prototype.$legacyShadowToken$ to mark elements a portal:
|
4113
4221
|
* Same as $shadowToken$ but for legacy CSS scope tokens.
|
4114
|
-
|
4222
|
+
*/
|
4115
4223
|
defineProperty(Element.prototype, KEY__LEGACY_SHADOW_TOKEN, {
|
4116
4224
|
set(shadowToken) {
|
4117
4225
|
const oldShadowToken = this[KEY__LEGACY_SHADOW_TOKEN_PRIVATE];
|
@@ -4225,18 +4333,14 @@ function markElementAsPortal(elm) {
|
|
4225
4333
|
}
|
4226
4334
|
/**
|
4227
4335
|
* Patching Element.prototype.$domManual$ to mark elements as portal:
|
4228
|
-
*
|
4229
|
-
*
|
4230
|
-
*
|
4231
|
-
*
|
4232
|
-
*
|
4233
|
-
*
|
4234
|
-
*
|
4235
|
-
|
4236
|
-
* - at the moment, there is no way to undo this operation, once the element is
|
4237
|
-
* marked as $domManual$, setting it to false does nothing.
|
4238
|
-
*
|
4239
|
-
**/
|
4336
|
+
* - we use a property to allow engines to signal that a particular element in
|
4337
|
+
* a shadow supports manual insertion of child nodes.
|
4338
|
+
* - this signal comes as a boolean value, and we use it to install the MO instance
|
4339
|
+
* onto the element, to propagate the $ownerKey$ and $shadowToken$ to all new
|
4340
|
+
* child nodes.
|
4341
|
+
* - at the moment, there is no way to undo this operation, once the element is
|
4342
|
+
* marked as $domManual$, setting it to false does nothing.
|
4343
|
+
*/
|
4240
4344
|
// TODO [#1306]: rename this to $observerConnection$
|
4241
4345
|
defineProperty(Element.prototype, '$domManual$', {
|
4242
4346
|
set(v) {
|
@@ -4250,6 +4354,6 @@ defineProperty(Element.prototype, '$domManual$', {
|
|
4250
4354
|
},
|
4251
4355
|
configurable: true,
|
4252
4356
|
});
|
4253
|
-
/** version: 6.
|
4357
|
+
/** version: 6.3.0 */
|
4254
4358
|
}
|
4255
4359
|
//# sourceMappingURL=index.js.map
|