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