@lwc/synthetic-shadow 5.0.9 → 5.0.10
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.cjs.js +66 -54
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +66 -54
- package/dist/index.js.map +1 -1
- package/dist/shared/utils.d.ts +1 -0
- package/package.json +3 -3
package/dist/index.cjs.js
CHANGED
@@ -115,7 +115,7 @@ const KEY__LEGACY_SHADOW_TOKEN_PRIVATE = '$$LegacyShadowTokenKey$$';
|
|
115
115
|
const KEY__SYNTHETIC_MODE = '$$lwc-synthetic-mode';
|
116
116
|
const KEY__NATIVE_GET_ELEMENT_BY_ID = '$nativeGetElementById$';
|
117
117
|
const KEY__NATIVE_QUERY_SELECTOR_ALL = '$nativeQuerySelectorAll$';
|
118
|
-
/** version: 5.0.
|
118
|
+
/** version: 5.0.10 */
|
119
119
|
|
120
120
|
/**
|
121
121
|
* Copyright (C) 2023 salesforce.com, inc.
|
@@ -124,7 +124,7 @@ const KEY__NATIVE_QUERY_SELECTOR_ALL = '$nativeQuerySelectorAll$';
|
|
124
124
|
if (!_globalThis.lwcRuntimeFlags) {
|
125
125
|
Object.defineProperty(_globalThis, 'lwcRuntimeFlags', { value: create(null) });
|
126
126
|
}
|
127
|
-
/** version: 5.0.
|
127
|
+
/** version: 5.0.10 */
|
128
128
|
|
129
129
|
/*
|
130
130
|
* Copyright (c) 2018, salesforce.com, inc.
|
@@ -283,54 +283,6 @@ const MutationObserverObserve = MO.prototype.observe;
|
|
283
283
|
const NativeShadowRoot = ShadowRoot;
|
284
284
|
const isInstanceOfNativeShadowRoot = (node) => node instanceof NativeShadowRoot;
|
285
285
|
|
286
|
-
/*
|
287
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
288
|
-
* All rights reserved.
|
289
|
-
* SPDX-License-Identifier: MIT
|
290
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
291
|
-
*/
|
292
|
-
// Helpful for tests running with jsdom
|
293
|
-
function getOwnerDocument(node) {
|
294
|
-
const doc = ownerDocumentGetter.call(node);
|
295
|
-
// if doc is null, it means `this` is actually a document instance
|
296
|
-
return doc === null ? node : doc;
|
297
|
-
}
|
298
|
-
function getOwnerWindow(node) {
|
299
|
-
const doc = getOwnerDocument(node);
|
300
|
-
const win = defaultViewGetter.call(doc);
|
301
|
-
if (win === null) {
|
302
|
-
// this method should never be called with a node that is not part
|
303
|
-
// of a qualifying connected node.
|
304
|
-
throw new TypeError();
|
305
|
-
}
|
306
|
-
return win;
|
307
|
-
}
|
308
|
-
let skipGlobalPatching;
|
309
|
-
// Note: we deviate from native shadow here, but are not fixing
|
310
|
-
// due to backwards compat: https://github.com/salesforce/lwc/pull/3103
|
311
|
-
function isGlobalPatchingSkipped(node) {
|
312
|
-
// we lazily compute this value instead of doing it during evaluation, this helps
|
313
|
-
// for apps that are setting this after the engine code is evaluated.
|
314
|
-
if (isUndefined(skipGlobalPatching)) {
|
315
|
-
const ownerDocument = getOwnerDocument(node);
|
316
|
-
skipGlobalPatching =
|
317
|
-
ownerDocument.body &&
|
318
|
-
getAttribute.call(ownerDocument.body, 'data-global-patching-bypass') ===
|
319
|
-
'temporary-bypass';
|
320
|
-
}
|
321
|
-
return isTrue(skipGlobalPatching);
|
322
|
-
}
|
323
|
-
function arrayFromCollection(collection) {
|
324
|
-
const size = collection.length;
|
325
|
-
const cloned = [];
|
326
|
-
if (size > 0) {
|
327
|
-
for (let i = 0; i < size; i++) {
|
328
|
-
cloned[i] = collection[i];
|
329
|
-
}
|
330
|
-
}
|
331
|
-
return cloned;
|
332
|
-
}
|
333
|
-
|
334
286
|
/*
|
335
287
|
* Copyright (c) 2023, Salesforce.com, inc.
|
336
288
|
* All rights reserved.
|
@@ -2203,6 +2155,57 @@ defineProperty(SyntheticShadowRoot, Symbol.hasInstance, {
|
|
2203
2155
|
},
|
2204
2156
|
});
|
2205
2157
|
|
2158
|
+
/*
|
2159
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
2160
|
+
* All rights reserved.
|
2161
|
+
* SPDX-License-Identifier: MIT
|
2162
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
2163
|
+
*/
|
2164
|
+
function isSyntheticOrNativeShadowRoot(node) {
|
2165
|
+
return isSyntheticShadowRoot(node) || isInstanceOfNativeShadowRoot(node);
|
2166
|
+
}
|
2167
|
+
// Helpful for tests running with jsdom
|
2168
|
+
function getOwnerDocument(node) {
|
2169
|
+
const doc = ownerDocumentGetter.call(node);
|
2170
|
+
// if doc is null, it means `this` is actually a document instance
|
2171
|
+
return doc === null ? node : doc;
|
2172
|
+
}
|
2173
|
+
function getOwnerWindow(node) {
|
2174
|
+
const doc = getOwnerDocument(node);
|
2175
|
+
const win = defaultViewGetter.call(doc);
|
2176
|
+
if (win === null) {
|
2177
|
+
// this method should never be called with a node that is not part
|
2178
|
+
// of a qualifying connected node.
|
2179
|
+
throw new TypeError();
|
2180
|
+
}
|
2181
|
+
return win;
|
2182
|
+
}
|
2183
|
+
let skipGlobalPatching;
|
2184
|
+
// Note: we deviate from native shadow here, but are not fixing
|
2185
|
+
// due to backwards compat: https://github.com/salesforce/lwc/pull/3103
|
2186
|
+
function isGlobalPatchingSkipped(node) {
|
2187
|
+
// we lazily compute this value instead of doing it during evaluation, this helps
|
2188
|
+
// for apps that are setting this after the engine code is evaluated.
|
2189
|
+
if (isUndefined(skipGlobalPatching)) {
|
2190
|
+
const ownerDocument = getOwnerDocument(node);
|
2191
|
+
skipGlobalPatching =
|
2192
|
+
ownerDocument.body &&
|
2193
|
+
getAttribute.call(ownerDocument.body, 'data-global-patching-bypass') ===
|
2194
|
+
'temporary-bypass';
|
2195
|
+
}
|
2196
|
+
return isTrue(skipGlobalPatching);
|
2197
|
+
}
|
2198
|
+
function arrayFromCollection(collection) {
|
2199
|
+
const size = collection.length;
|
2200
|
+
const cloned = [];
|
2201
|
+
if (size > 0) {
|
2202
|
+
for (let i = 0; i < size; i++) {
|
2203
|
+
cloned[i] = collection[i];
|
2204
|
+
}
|
2205
|
+
}
|
2206
|
+
return cloned;
|
2207
|
+
}
|
2208
|
+
|
2206
2209
|
/*
|
2207
2210
|
* Copyright (c) 2018, salesforce.com, inc.
|
2208
2211
|
* All rights reserved.
|
@@ -2242,8 +2245,7 @@ function pathComposer(startNode, composed) {
|
|
2242
2245
|
current = current.parentNode;
|
2243
2246
|
}
|
2244
2247
|
}
|
2245
|
-
else if ((
|
2246
|
-
(composed || current !== startRoot)) {
|
2248
|
+
else if (isSyntheticOrNativeShadowRoot(current) && (composed || current !== startRoot)) {
|
2247
2249
|
current = current.host;
|
2248
2250
|
}
|
2249
2251
|
else if (current instanceof _Node) {
|
@@ -2294,11 +2296,16 @@ function retarget(refNode, path) {
|
|
2294
2296
|
for (let i = 0, ancestor, lastRoot, root, rootIdx; i < p$.length; i++) {
|
2295
2297
|
ancestor = p$[i];
|
2296
2298
|
root = ancestor instanceof Window ? ancestor : ancestor.getRootNode();
|
2299
|
+
// Retarget to ancestor if ancestor is not shadowed
|
2300
|
+
if (!isSyntheticOrNativeShadowRoot(root)) {
|
2301
|
+
return ancestor;
|
2302
|
+
}
|
2297
2303
|
if (root !== lastRoot) {
|
2298
2304
|
rootIdx = refNodePath.indexOf(root);
|
2299
2305
|
lastRoot = root;
|
2300
2306
|
}
|
2301
|
-
if
|
2307
|
+
// Retarget to ancestor if ancestor is shadowed by refNode's shadow root
|
2308
|
+
if (!isUndefined(rootIdx) && rootIdx > -1) {
|
2302
2309
|
return ancestor;
|
2303
2310
|
}
|
2304
2311
|
}
|
@@ -2774,6 +2781,11 @@ function patchedAddEventListener(type, listener, optionsOrCapture) {
|
|
2774
2781
|
// @ts-ignore type-mismatch
|
2775
2782
|
return addCustomElementEventListener.apply(this, arguments);
|
2776
2783
|
}
|
2784
|
+
if (this instanceof _Node && isInstanceOfNativeShadowRoot(this.getRootNode())) {
|
2785
|
+
// Typescript does not like it when you treat the `arguments` object as an array
|
2786
|
+
// @ts-expect-error type-mismatch
|
2787
|
+
return addEventListener.apply(this, arguments);
|
2788
|
+
}
|
2777
2789
|
if (arguments.length < 2) {
|
2778
2790
|
// Slow path, unlikely to be called frequently. We expect modern browsers to throw:
|
2779
2791
|
// https://googlechrome.github.io/samples/event-listeners-mandatory-arguments/
|
@@ -4260,5 +4272,5 @@ defineProperty(Element.prototype, '$domManual$', {
|
|
4260
4272
|
},
|
4261
4273
|
configurable: true,
|
4262
4274
|
});
|
4263
|
-
/** version: 5.0.
|
4275
|
+
/** version: 5.0.10 */
|
4264
4276
|
//# sourceMappingURL=index.cjs.js.map
|