@lwc/synthetic-shadow 6.1.1 → 6.2.1
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 +161 -61
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +161 -61
- 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,48 +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
|
+
*/
|
146
|
+
// Replacing `Function` with a narrower type that works for all our use cases is tricky...
|
147
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
67
148
|
function isFunction(obj) {
|
68
149
|
return typeof obj === 'function';
|
69
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
|
+
*/
|
70
156
|
function isObject(obj) {
|
71
157
|
return typeof obj === 'object';
|
72
158
|
}
|
73
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
|
+
*/
|
74
166
|
function toString(obj) {
|
75
|
-
if (obj
|
167
|
+
if (obj?.toString) {
|
76
168
|
// Arrays might hold objects with "null" prototype So using
|
77
169
|
// Array.prototype.toString directly will cause an error Iterate through
|
78
170
|
// all the items and handle individually.
|
79
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
|
80
182
|
return ArrayJoin.call(ArrayMap.call(obj, toString), ',');
|
81
183
|
}
|
82
184
|
return obj.toString();
|
83
185
|
}
|
84
186
|
else if (typeof obj === 'object') {
|
187
|
+
// This catches null and returns "[object Null]". Weird, but kept for backwards compatibility.
|
85
188
|
return OtS.call(obj);
|
86
189
|
}
|
87
190
|
else {
|
88
|
-
return obj
|
191
|
+
return String(obj);
|
89
192
|
}
|
90
193
|
}
|
91
194
|
|
@@ -107,7 +210,7 @@ const KEY__LEGACY_SHADOW_TOKEN_PRIVATE = '$$LegacyShadowTokenKey$$';
|
|
107
210
|
const KEY__SYNTHETIC_MODE = '$$lwc-synthetic-mode';
|
108
211
|
const KEY__NATIVE_GET_ELEMENT_BY_ID = '$nativeGetElementById$';
|
109
212
|
const KEY__NATIVE_QUERY_SELECTOR_ALL = '$nativeQuerySelectorAll$';
|
110
|
-
/** version: 6.
|
213
|
+
/** version: 6.2.1 */
|
111
214
|
|
112
215
|
/**
|
113
216
|
* Copyright (c) 2024 Salesforce, Inc.
|
@@ -115,7 +218,7 @@ const KEY__NATIVE_QUERY_SELECTOR_ALL = '$nativeQuerySelectorAll$';
|
|
115
218
|
if (!globalThis.lwcRuntimeFlags) {
|
116
219
|
Object.defineProperty(globalThis, 'lwcRuntimeFlags', { value: create(null) });
|
117
220
|
}
|
118
|
-
/** version: 6.
|
221
|
+
/** version: 6.2.1 */
|
119
222
|
|
120
223
|
/*
|
121
224
|
* Copyright (c) 2018, salesforce.com, inc.
|
@@ -384,6 +487,7 @@ function getNodeKey(node) {
|
|
384
487
|
* This function does not traverse up for performance reasons, but is sufficient for most use
|
385
488
|
* cases. If we need to traverse up and verify those nodes that don't have owner key, use
|
386
489
|
* isNodeDeepShadowed instead.
|
490
|
+
* @param node
|
387
491
|
*/
|
388
492
|
function isNodeShadowed(node) {
|
389
493
|
return !isUndefined(getNodeOwnerKey(node));
|
@@ -440,7 +544,7 @@ function isNodeSlotted(host, node) {
|
|
440
544
|
// have different owner key. for slotted elements, this is possible
|
441
545
|
// if the parent happens to be a slot.
|
442
546
|
if (isSlotElement(parent)) {
|
443
|
-
|
547
|
+
/*
|
444
548
|
* the slot parent might be allocated inside another slot, think of:
|
445
549
|
* <x-root> (<--- root element)
|
446
550
|
* <x-parent> (<--- own by x-root)
|
@@ -914,12 +1018,11 @@ function createStaticNodeList(items) {
|
|
914
1018
|
*/
|
915
1019
|
// Walk up the DOM tree, collecting all shadow roots plus the document root
|
916
1020
|
function getAllRootNodes(node) {
|
917
|
-
var _a;
|
918
1021
|
const rootNodes = [];
|
919
1022
|
let currentRootNode = node.getRootNode();
|
920
1023
|
while (!isUndefined(currentRootNode)) {
|
921
1024
|
rootNodes.push(currentRootNode);
|
922
|
-
currentRootNode =
|
1025
|
+
currentRootNode = currentRootNode.host?.getRootNode();
|
923
1026
|
}
|
924
1027
|
return rootNodes;
|
925
1028
|
}
|
@@ -1065,6 +1168,7 @@ function createStaticHTMLCollection(items) {
|
|
1065
1168
|
* based on the light-dom slotting mechanism. This applies to synthetic slot elements
|
1066
1169
|
* and elements with shadow dom attached to them. It doesn't apply to native slot elements
|
1067
1170
|
* because we don't want to patch the children getters for those elements.
|
1171
|
+
* @param node
|
1068
1172
|
*/
|
1069
1173
|
function hasMountedChildren(node) {
|
1070
1174
|
return isSyntheticSlotElement(node) || isSyntheticShadowHost(node);
|
@@ -1187,6 +1291,7 @@ const nativeGetRootNode = _Node.prototype.getRootNode;
|
|
1187
1291
|
const getDocumentOrRootNode = !isUndefined(nativeGetRootNode)
|
1188
1292
|
? nativeGetRootNode
|
1189
1293
|
: function () {
|
1294
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
1190
1295
|
let node = this;
|
1191
1296
|
let nodeParent;
|
1192
1297
|
while (!isNull((nodeParent = parentNodeGetter.call(node)))) {
|
@@ -1198,10 +1303,10 @@ const getDocumentOrRootNode = !isUndefined(nativeGetRootNode)
|
|
1198
1303
|
* Get the shadow root
|
1199
1304
|
* getNodeOwner() returns the host element that owns the given node
|
1200
1305
|
* Note: getNodeOwner() returns null when running in native-shadow mode.
|
1201
|
-
*
|
1202
|
-
*
|
1203
|
-
*
|
1204
|
-
* @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
|
1205
1310
|
*/
|
1206
1311
|
function getNearestRoot(node) {
|
1207
1312
|
const ownerNode = getNodeOwner(node);
|
@@ -1219,17 +1324,17 @@ function getNearestRoot(node) {
|
|
1219
1324
|
*
|
1220
1325
|
* If looking for a shadow root of a node by calling `node.getRootNode({composed: false})` or `node.getRootNode()`,
|
1221
1326
|
*
|
1222
|
-
*
|
1223
|
-
*
|
1224
|
-
*
|
1225
|
-
*
|
1226
|
-
*
|
1227
|
-
*
|
1228
|
-
*
|
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)
|
1229
1334
|
*
|
1230
1335
|
* _Spec_: https://dom.spec.whatwg.org/#dom-node-getrootnode
|
1231
|
-
*
|
1232
|
-
|
1336
|
+
* @param options
|
1337
|
+
*/
|
1233
1338
|
function getRootNodePatched(options) {
|
1234
1339
|
const composed = isUndefined(options) ? false : !!options.composed;
|
1235
1340
|
return isTrue(composed) ? getDocumentOrRootNode.call(this, options) : getNearestRoot(this);
|
@@ -1466,7 +1571,7 @@ function getEventHandler(listener) {
|
|
1466
1571
|
}
|
1467
1572
|
}
|
1468
1573
|
function isEventListenerOrEventListenerObject(listener) {
|
1469
|
-
return isFunction(listener) || isFunction(listener
|
1574
|
+
return isFunction(listener) || isFunction(listener?.handleEvent);
|
1470
1575
|
}
|
1471
1576
|
const customElementToWrappedListeners = new WeakMap();
|
1472
1577
|
function getEventMap(elm) {
|
@@ -1481,10 +1586,10 @@ function getEventMap(elm) {
|
|
1481
1586
|
* Events dispatched on shadow roots actually end up being dispatched on their hosts. This means that the event.target
|
1482
1587
|
* property of events dispatched on shadow roots always resolve to their host. This function understands this
|
1483
1588
|
* abstraction and properly returns a reference to the shadow root when appropriate.
|
1589
|
+
* @param event
|
1484
1590
|
*/
|
1485
1591
|
function getActualTarget(event) {
|
1486
|
-
|
1487
|
-
return (_a = eventToShadowRootMap.get(event)) !== null && _a !== void 0 ? _a : eventTargetGetter.call(event);
|
1592
|
+
return eventToShadowRootMap.get(event) ?? eventTargetGetter.call(event);
|
1488
1593
|
}
|
1489
1594
|
const shadowRootEventListenerMap = new WeakMap();
|
1490
1595
|
function getManagedShadowRootListener(listener) {
|
@@ -1621,7 +1726,7 @@ function detachDOMListener(elm, type, managedListener) {
|
|
1621
1726
|
function addCustomElementEventListener(type, listener, _options) {
|
1622
1727
|
if (process.env.NODE_ENV !== 'production') {
|
1623
1728
|
if (!isEventListenerOrEventListenerObject(listener)) {
|
1624
|
-
throw new TypeError(`Invalid second argument for Element.addEventListener() in ${toString(this)} for event "${type}". Expected EventListener or EventListenerObject but received ${listener}.`);
|
1729
|
+
throw new TypeError(`Invalid second argument for Element.addEventListener() in ${toString(this)} for event "${type}". Expected EventListener or EventListenerObject but received ${toString(listener)}.`);
|
1625
1730
|
}
|
1626
1731
|
}
|
1627
1732
|
if (isEventListenerOrEventListenerObject(listener)) {
|
@@ -1638,7 +1743,7 @@ function removeCustomElementEventListener(type, listener, _options) {
|
|
1638
1743
|
function addShadowRootEventListener(sr, type, listener, _options) {
|
1639
1744
|
if (process.env.NODE_ENV !== 'production') {
|
1640
1745
|
if (!isEventListenerOrEventListenerObject(listener)) {
|
1641
|
-
throw new TypeError(`Invalid second argument for ShadowRoot.addEventListener() in ${toString(sr)} for event "${type}". Expected EventListener or EventListenerObject but received ${listener}.`);
|
1746
|
+
throw new TypeError(`Invalid second argument for ShadowRoot.addEventListener() in ${toString(sr)} for event "${type}". Expected EventListener or EventListenerObject but received ${toString(listener)}.`);
|
1642
1747
|
}
|
1643
1748
|
}
|
1644
1749
|
if (isEventListenerOrEventListenerObject(listener)) {
|
@@ -2289,7 +2394,7 @@ function retarget(refNode, path) {
|
|
2289
2394
|
rootIdx = refNodePath.indexOf(root);
|
2290
2395
|
lastRoot = root;
|
2291
2396
|
}
|
2292
|
-
if (!
|
2397
|
+
if (!isUndefined(rootIdx) && rootIdx > -1) {
|
2293
2398
|
return ancestor;
|
2294
2399
|
}
|
2295
2400
|
}
|
@@ -2535,7 +2640,7 @@ function setNodeObservers(node, observers) {
|
|
2535
2640
|
}
|
2536
2641
|
/**
|
2537
2642
|
* Retarget the mutation record's target value to its shadowRoot
|
2538
|
-
* @param
|
2643
|
+
* @param originalRecord
|
2539
2644
|
*/
|
2540
2645
|
function retargetMutationRecord(originalRecord) {
|
2541
2646
|
const { addedNodes, removedNodes, target, type } = originalRecord;
|
@@ -2575,8 +2680,8 @@ function retargetMutationRecord(originalRecord) {
|
|
2575
2680
|
/**
|
2576
2681
|
* Utility to identify if a target node is being observed by the given observer
|
2577
2682
|
* Start at the current node, if the observer is registered to observe the current node, the mutation qualifies
|
2578
|
-
* @param
|
2579
|
-
* @param
|
2683
|
+
* @param observer
|
2684
|
+
* @param target
|
2580
2685
|
*/
|
2581
2686
|
function isQualifiedObserver(observer, target) {
|
2582
2687
|
let parentNode = target;
|
@@ -2597,8 +2702,8 @@ function isQualifiedObserver(observer, target) {
|
|
2597
2702
|
* The key logic here is to determine if a given observer has been registered to observe any nodes
|
2598
2703
|
* between the target node of a mutation record to the target's root node.
|
2599
2704
|
* This function also retargets records when mutations occur directly under the shadow root
|
2600
|
-
* @param
|
2601
|
-
* @param
|
2705
|
+
* @param mutations
|
2706
|
+
* @param observer
|
2602
2707
|
*/
|
2603
2708
|
function filterMutationRecords(mutations, observer) {
|
2604
2709
|
const result = [];
|
@@ -2680,7 +2785,7 @@ function getWrappedCallback(callback) {
|
|
2680
2785
|
* Patched MutationObserver constructor.
|
2681
2786
|
* 1. Wrap the callback to filter out MutationRecords based on dom ownership
|
2682
2787
|
* 2. Add a property field to track all observed targets of the observer instance
|
2683
|
-
* @param
|
2788
|
+
* @param callback
|
2684
2789
|
*/
|
2685
2790
|
function PatchedMutationObserver(callback) {
|
2686
2791
|
const wrappedCallback = getWrappedCallback(callback);
|
@@ -2707,8 +2812,8 @@ function patchedDisconnect() {
|
|
2707
2812
|
/**
|
2708
2813
|
* A single mutation observer can observe multiple nodes(target).
|
2709
2814
|
* Maintain a list of all targets that the observer chooses to observe
|
2710
|
-
* @param
|
2711
|
-
* @param
|
2815
|
+
* @param target
|
2816
|
+
* @param options
|
2712
2817
|
*/
|
2713
2818
|
function patchedObserve(target, options) {
|
2714
2819
|
let targetObservers = getNodeObservers(target);
|
@@ -3046,9 +3151,8 @@ function assignedSlotGetterPatched() {
|
|
3046
3151
|
}
|
3047
3152
|
/**
|
3048
3153
|
* The node is assigned to a slot if:
|
3049
|
-
*
|
3050
|
-
*
|
3051
|
-
*
|
3154
|
+
* - it has a parent and its parent is a slot element
|
3155
|
+
* - and if the slot owner key is different than the node owner key.
|
3052
3156
|
* When the slot and the slotted node are 2 different shadow trees, the owner keys will be
|
3053
3157
|
* different. When the slot is in a shadow tree and the slotted content is a light DOM node,
|
3054
3158
|
* the light DOM node doesn't have an owner key and therefor the slot owner key will be
|
@@ -3163,6 +3267,8 @@ defineProperties(Text.prototype, {
|
|
3163
3267
|
/**
|
3164
3268
|
* This methods filters out elements that are not in the same shadow root of context.
|
3165
3269
|
* It does not enforce shadow dom semantics if $context is not managed by LWC
|
3270
|
+
* @param context
|
3271
|
+
* @param unfilteredNodes
|
3166
3272
|
*/
|
3167
3273
|
function getNonPatchedFilteredArrayOfNodes(context, unfilteredNodes) {
|
3168
3274
|
let filtered;
|
@@ -3871,6 +3977,7 @@ function tabIndexGetterPatched() {
|
|
3871
3977
|
}
|
3872
3978
|
/**
|
3873
3979
|
* This method only applies to elements with a shadow attached to them
|
3980
|
+
* @param value
|
3874
3981
|
*/
|
3875
3982
|
function tabIndexSetterPatched(value) {
|
3876
3983
|
// This tabIndex setter might be confusing unless it is understood that HTML
|
@@ -4051,13 +4158,10 @@ function setShadowToken(node, shadowToken) {
|
|
4051
4158
|
}
|
4052
4159
|
/**
|
4053
4160
|
* Patching Element.prototype.$shadowToken$ to mark elements a portal:
|
4054
|
-
*
|
4055
|
-
*
|
4056
|
-
*
|
4057
|
-
|
4058
|
-
* - this custom attribute must be unique.
|
4059
|
-
*
|
4060
|
-
**/
|
4161
|
+
* - we use a property to allow engines to set a custom attribute that should be
|
4162
|
+
* placed into the element to sandbox the css rules defined for the template.
|
4163
|
+
* - this custom attribute must be unique.
|
4164
|
+
*/
|
4061
4165
|
defineProperty(Element.prototype, KEY__SHADOW_TOKEN, {
|
4062
4166
|
set(shadowToken) {
|
4063
4167
|
const oldShadowToken = this[KEY__SHADOW_TOKEN_PRIVATE];
|
@@ -4112,7 +4216,7 @@ function setLegacyShadowToken(node, shadowToken) {
|
|
4112
4216
|
/**
|
4113
4217
|
* Patching Element.prototype.$legacyShadowToken$ to mark elements a portal:
|
4114
4218
|
* Same as $shadowToken$ but for legacy CSS scope tokens.
|
4115
|
-
|
4219
|
+
*/
|
4116
4220
|
defineProperty(Element.prototype, KEY__LEGACY_SHADOW_TOKEN, {
|
4117
4221
|
set(shadowToken) {
|
4118
4222
|
const oldShadowToken = this[KEY__LEGACY_SHADOW_TOKEN_PRIVATE];
|
@@ -4226,18 +4330,14 @@ function markElementAsPortal(elm) {
|
|
4226
4330
|
}
|
4227
4331
|
/**
|
4228
4332
|
* Patching Element.prototype.$domManual$ to mark elements as portal:
|
4229
|
-
*
|
4230
|
-
*
|
4231
|
-
*
|
4232
|
-
*
|
4233
|
-
*
|
4234
|
-
*
|
4235
|
-
*
|
4236
|
-
|
4237
|
-
* - at the moment, there is no way to undo this operation, once the element is
|
4238
|
-
* marked as $domManual$, setting it to false does nothing.
|
4239
|
-
*
|
4240
|
-
**/
|
4333
|
+
* - we use a property to allow engines to signal that a particular element in
|
4334
|
+
* a shadow supports manual insertion of child nodes.
|
4335
|
+
* - this signal comes as a boolean value, and we use it to install the MO instance
|
4336
|
+
* onto the element, to propagate the $ownerKey$ and $shadowToken$ to all new
|
4337
|
+
* child nodes.
|
4338
|
+
* - at the moment, there is no way to undo this operation, once the element is
|
4339
|
+
* marked as $domManual$, setting it to false does nothing.
|
4340
|
+
*/
|
4241
4341
|
// TODO [#1306]: rename this to $observerConnection$
|
4242
4342
|
defineProperty(Element.prototype, '$domManual$', {
|
4243
4343
|
set(v) {
|
@@ -4251,6 +4351,6 @@ defineProperty(Element.prototype, '$domManual$', {
|
|
4251
4351
|
},
|
4252
4352
|
configurable: true,
|
4253
4353
|
});
|
4254
|
-
/** version: 6.
|
4354
|
+
/** version: 6.2.1 */
|
4255
4355
|
}
|
4256
4356
|
//# sourceMappingURL=index.cjs.js.map
|