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