@lwc/synthetic-shadow 3.1.2 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/env/shadow-root.d.ts +0 -1
- package/dist/env/slot.d.ts +2 -2
- package/dist/index.cjs.js +17 -271
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.js +17 -271
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/dist/polyfills/HTMLSlotElement/detect.d.ts +0 -1
- package/dist/polyfills/HTMLSlotElement/main.d.ts +0 -1
- package/dist/polyfills/HTMLSlotElement/polyfill.d.ts +0 -1
- package/dist/polyfills/click-event-composed/detect.d.ts +0 -1
- package/dist/polyfills/click-event-composed/main.d.ts +0 -1
- package/dist/polyfills/click-event-composed/polyfill.d.ts +0 -1
- package/dist/polyfills/event-composed/detect.d.ts +0 -1
- package/dist/polyfills/event-composed/main.d.ts +0 -1
- package/dist/polyfills/event-composed/polyfill.d.ts +0 -1
package/dist/env/slot.d.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
declare
|
2
|
-
export
|
1
|
+
export declare const assignedNodes: (options?: AssignedNodesOptions | undefined) => Node[];
|
2
|
+
export declare const assignedElements: (options?: AssignedNodesOptions | undefined) => Element[];
|
package/dist/index.cjs.js
CHANGED
@@ -48,7 +48,6 @@ var assert = /*#__PURE__*/Object.freeze({
|
|
48
48
|
const { assign, create, defineProperties, defineProperty, freeze, getOwnPropertyDescriptor, getOwnPropertyNames, getPrototypeOf, hasOwnProperty, isFrozen, keys, seal, setPrototypeOf, } = Object;
|
49
49
|
const { isArray } = Array;
|
50
50
|
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, } = Array.prototype;
|
51
|
-
const { charCodeAt: StringCharCodeAt, replace: StringReplace, split: StringSplit, slice: StringSlice, toLowerCase: StringToLowerCase, } = String.prototype;
|
52
51
|
function isUndefined(obj) {
|
53
52
|
return obj === undefined;
|
54
53
|
}
|
@@ -99,12 +98,11 @@ function toString(obj) {
|
|
99
98
|
const _globalThis = typeof globalThis === 'object' ? globalThis : window;
|
100
99
|
|
101
100
|
/*
|
102
|
-
* Copyright (c)
|
101
|
+
* Copyright (c) 2023, Salesforce.com, inc.
|
103
102
|
* All rights reserved.
|
104
103
|
* SPDX-License-Identifier: MIT
|
105
104
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
106
105
|
*/
|
107
|
-
const KEY__IS_NATIVE_SHADOW_ROOT_DEFINED = '$isNativeShadowRootDefined$';
|
108
106
|
const KEY__SHADOW_RESOLVER = '$shadowResolver$';
|
109
107
|
const KEY__SHADOW_RESOLVER_PRIVATE = '$$ShadowResolverKey$$';
|
110
108
|
const KEY__SHADOW_STATIC = '$shadowStaticNode$';
|
@@ -114,7 +112,7 @@ const KEY__SHADOW_TOKEN_PRIVATE = '$$ShadowTokenKey$$';
|
|
114
112
|
const KEY__SYNTHETIC_MODE = '$$lwc-synthetic-mode';
|
115
113
|
const KEY__NATIVE_GET_ELEMENT_BY_ID = '$nativeGetElementById$';
|
116
114
|
const KEY__NATIVE_QUERY_SELECTOR_ALL = '$nativeQuerySelectorAll$';
|
117
|
-
/** version: 3.
|
115
|
+
/** version: 3.2.0 */
|
118
116
|
|
119
117
|
/**
|
120
118
|
* Copyright (C) 2023 salesforce.com, inc.
|
@@ -123,7 +121,7 @@ const KEY__NATIVE_QUERY_SELECTOR_ALL = '$nativeQuerySelectorAll$';
|
|
123
121
|
if (!_globalThis.lwcRuntimeFlags) {
|
124
122
|
Object.defineProperty(_globalThis, 'lwcRuntimeFlags', { value: create(null) });
|
125
123
|
}
|
126
|
-
/** version: 3.
|
124
|
+
/** version: 3.2.0 */
|
127
125
|
|
128
126
|
/*
|
129
127
|
* Copyright (c) 2018, salesforce.com, inc.
|
@@ -211,24 +209,13 @@ const assignedSlotGetter$1 = hasOwnProperty.call(Element.prototype, 'assignedSlo
|
|
211
209
|
: () => null;
|
212
210
|
|
213
211
|
/*
|
214
|
-
* Copyright (c)
|
212
|
+
* Copyright (c) 2023, Salesforce.com, inc.
|
215
213
|
* All rights reserved.
|
216
214
|
* SPDX-License-Identifier: MIT
|
217
215
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
218
216
|
*/
|
219
|
-
|
220
|
-
|
221
|
-
assignedNodes = HTMLSlotElement.prototype.assignedNodes;
|
222
|
-
assignedElements = HTMLSlotElement.prototype.assignedElements;
|
223
|
-
}
|
224
|
-
else {
|
225
|
-
assignedNodes = () => {
|
226
|
-
throw new TypeError("assignedNodes() is not supported in current browser. Load the @lwc/synthetic-shadow polyfill to start using <slot> elements in your Lightning Web Component's template");
|
227
|
-
};
|
228
|
-
assignedElements = () => {
|
229
|
-
throw new TypeError("assignedElements() is not supported in current browser. Load the @lwc/synthetic-shadow polyfill to start using <slot> elements in your Lightning Web Component's template");
|
230
|
-
};
|
231
|
-
}
|
217
|
+
const assignedNodes = HTMLSlotElement.prototype.assignedNodes;
|
218
|
+
const assignedElements = HTMLSlotElement.prototype.assignedElements;
|
232
219
|
|
233
220
|
/*
|
234
221
|
* Copyright (c) 2018, salesforce.com, inc.
|
@@ -284,79 +271,14 @@ const MO = MutationObserver;
|
|
284
271
|
const MutationObserverObserve = MO.prototype.observe;
|
285
272
|
|
286
273
|
/*
|
287
|
-
* Copyright (c)
|
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
|
-
let NativeShadowRoot = null;
|
293
|
-
if (typeof ShadowRoot !== 'undefined') {
|
294
|
-
NativeShadowRoot = ShadowRoot;
|
295
|
-
}
|
296
|
-
const isNativeShadowRootDefined = !isNull(NativeShadowRoot);
|
297
|
-
const isInstanceOfNativeShadowRoot = isNull(NativeShadowRoot)
|
298
|
-
? () => false
|
299
|
-
: (node) => node instanceof NativeShadowRoot;
|
300
|
-
|
301
|
-
/*
|
302
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
303
|
-
* All rights reserved.
|
304
|
-
* SPDX-License-Identifier: MIT
|
305
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
306
|
-
*/
|
307
|
-
function detect$2 () {
|
308
|
-
return typeof HTMLSlotElement === 'undefined';
|
309
|
-
}
|
310
|
-
|
311
|
-
/*
|
312
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
313
|
-
* All rights reserved.
|
314
|
-
* SPDX-License-Identifier: MIT
|
315
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
316
|
-
*/
|
317
|
-
const { createElement } = Document.prototype;
|
318
|
-
const CHAR_S = 115;
|
319
|
-
const CHAR_L = 108;
|
320
|
-
const CHAR_O = 111;
|
321
|
-
const CHAR_T = 116;
|
322
|
-
function apply$2() {
|
323
|
-
// IE11 does not have this element definition
|
324
|
-
// we don't care much about the construction phase, just the prototype
|
325
|
-
class HTMLSlotElement {
|
326
|
-
}
|
327
|
-
// prototype inheritance dance
|
328
|
-
setPrototypeOf(HTMLSlotElement, HTMLElement.constructor);
|
329
|
-
setPrototypeOf(HTMLSlotElement.prototype, HTMLElement.prototype);
|
330
|
-
Window.prototype.HTMLSlotElement = HTMLSlotElement;
|
331
|
-
// IE11 doesn't have HTMLSlotElement, in which case we
|
332
|
-
// need to patch Document.prototype.createElement to remap `slot`
|
333
|
-
// elements to the right prototype
|
334
|
-
defineProperty(Document.prototype, 'createElement', {
|
335
|
-
value: function (tagName, _options) {
|
336
|
-
const elm = createElement.apply(this, ArraySlice.call(arguments));
|
337
|
-
if (tagName.length === 4 &&
|
338
|
-
StringCharCodeAt.call(tagName, 0) === CHAR_S &&
|
339
|
-
StringCharCodeAt.call(tagName, 1) === CHAR_L &&
|
340
|
-
StringCharCodeAt.call(tagName, 2) === CHAR_O &&
|
341
|
-
StringCharCodeAt.call(tagName, 3) === CHAR_T) {
|
342
|
-
// the new element is the `slot`, resetting the proto chain
|
343
|
-
// the new newly created global HTMLSlotElement.prototype
|
344
|
-
setPrototypeOf(elm, HTMLSlotElement.prototype);
|
345
|
-
}
|
346
|
-
return elm;
|
347
|
-
},
|
348
|
-
});
|
349
|
-
}
|
350
|
-
|
351
|
-
/*
|
352
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
274
|
+
* Copyright (c) 2023, Salesforce.com, inc.
|
353
275
|
* All rights reserved.
|
354
276
|
* SPDX-License-Identifier: MIT
|
355
277
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
356
278
|
*/
|
357
|
-
|
358
|
-
|
359
|
-
|
279
|
+
// Capture the global `ShadowRoot` since synthetic shadow will override it later
|
280
|
+
const NativeShadowRoot = ShadowRoot;
|
281
|
+
const isInstanceOfNativeShadowRoot = (node) => node instanceof NativeShadowRoot;
|
360
282
|
|
361
283
|
/*
|
362
284
|
* Copyright (c) 2018, salesforce.com, inc.
|
@@ -407,12 +329,12 @@ function arrayFromCollection(collection) {
|
|
407
329
|
}
|
408
330
|
|
409
331
|
/*
|
410
|
-
* Copyright (c)
|
332
|
+
* Copyright (c) 2023, Salesforce.com, inc.
|
411
333
|
* All rights reserved.
|
412
334
|
* SPDX-License-Identifier: MIT
|
413
335
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
414
336
|
*/
|
415
|
-
const eventTargetPrototype =
|
337
|
+
const eventTargetPrototype = EventTarget.prototype;
|
416
338
|
const { addEventListener, dispatchEvent, removeEventListener } = eventTargetPrototype;
|
417
339
|
|
418
340
|
/*
|
@@ -1740,7 +1662,7 @@ function removeShadowRootEventListener(sr, type, listener, _options) {
|
|
1740
1662
|
}
|
1741
1663
|
|
1742
1664
|
/*
|
1743
|
-
* Copyright (c)
|
1665
|
+
* Copyright (c) 2023, Salesforce.com, inc.
|
1744
1666
|
* All rights reserved.
|
1745
1667
|
* SPDX-License-Identifier: MIT
|
1746
1668
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
@@ -1771,9 +1693,6 @@ defineProperty(_Node.prototype, KEY__SHADOW_RESOLVER, {
|
|
1771
1693
|
configurable: true,
|
1772
1694
|
enumerable: true,
|
1773
1695
|
});
|
1774
|
-
defineProperty(_globalThis, KEY__IS_NATIVE_SHADOW_ROOT_DEFINED, {
|
1775
|
-
value: isNativeShadowRootDefined,
|
1776
|
-
});
|
1777
1696
|
// The isUndefined check is because two copies of synthetic shadow may be loaded on the same page, and this
|
1778
1697
|
// would throw an error if we tried to redefine it. Plus the whole point is to expose the native method.
|
1779
1698
|
if (isUndefined(_globalThis[KEY__NATIVE_GET_ELEMENT_BY_ID])) {
|
@@ -2551,181 +2470,6 @@ Object.defineProperty(window, 'ShadowRoot', {
|
|
2551
2470
|
writable: true,
|
2552
2471
|
});
|
2553
2472
|
|
2554
|
-
/*
|
2555
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
2556
|
-
* All rights reserved.
|
2557
|
-
* SPDX-License-Identifier: MIT
|
2558
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
2559
|
-
*/
|
2560
|
-
const composedDescriptor = Object.getOwnPropertyDescriptor(Event.prototype, 'composed');
|
2561
|
-
function detect$1() {
|
2562
|
-
if (!composedDescriptor) {
|
2563
|
-
// No need to apply this polyfill if this client completely lacks
|
2564
|
-
// support for the composed property.
|
2565
|
-
return false;
|
2566
|
-
}
|
2567
|
-
// Assigning a throwaway click event here to suppress a ts error when we
|
2568
|
-
// pass clickEvent into the composed getter below. The error is:
|
2569
|
-
// [ts] Variable 'clickEvent' is used before being assigned.
|
2570
|
-
let clickEvent = new Event('click');
|
2571
|
-
const button = document.createElement('button');
|
2572
|
-
button.addEventListener('click', (event) => (clickEvent = event));
|
2573
|
-
button.click();
|
2574
|
-
return !composedDescriptor.get.call(clickEvent);
|
2575
|
-
}
|
2576
|
-
|
2577
|
-
/*
|
2578
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
2579
|
-
* All rights reserved.
|
2580
|
-
* SPDX-License-Identifier: MIT
|
2581
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
2582
|
-
*/
|
2583
|
-
const originalClickDescriptor = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'click');
|
2584
|
-
function handleClick(event) {
|
2585
|
-
Object.defineProperty(event, 'composed', {
|
2586
|
-
configurable: true,
|
2587
|
-
enumerable: true,
|
2588
|
-
get() {
|
2589
|
-
return true;
|
2590
|
-
},
|
2591
|
-
});
|
2592
|
-
}
|
2593
|
-
function apply$1() {
|
2594
|
-
HTMLElement.prototype.click = function () {
|
2595
|
-
addEventListener.call(this, 'click', handleClick);
|
2596
|
-
try {
|
2597
|
-
originalClickDescriptor.value.call(this);
|
2598
|
-
}
|
2599
|
-
finally {
|
2600
|
-
removeEventListener.call(this, 'click', handleClick);
|
2601
|
-
}
|
2602
|
-
};
|
2603
|
-
}
|
2604
|
-
|
2605
|
-
/*
|
2606
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
2607
|
-
* All rights reserved.
|
2608
|
-
* SPDX-License-Identifier: MIT
|
2609
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
2610
|
-
*/
|
2611
|
-
if (detect$1()) {
|
2612
|
-
apply$1();
|
2613
|
-
}
|
2614
|
-
|
2615
|
-
/*
|
2616
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
2617
|
-
* All rights reserved.
|
2618
|
-
* SPDX-License-Identifier: MIT
|
2619
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
2620
|
-
*/
|
2621
|
-
function detect() {
|
2622
|
-
return new Event('test', { composed: true }).composed !== true;
|
2623
|
-
}
|
2624
|
-
|
2625
|
-
/*
|
2626
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
2627
|
-
* All rights reserved.
|
2628
|
-
* SPDX-License-Identifier: MIT
|
2629
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
2630
|
-
*/
|
2631
|
-
function apply() {
|
2632
|
-
// https://github.com/w3c/webcomponents/issues/513#issuecomment-224183937
|
2633
|
-
const composedEvents = assign(create(null), {
|
2634
|
-
beforeinput: 1,
|
2635
|
-
blur: 1,
|
2636
|
-
click: 1,
|
2637
|
-
compositionend: 1,
|
2638
|
-
compositionstart: 1,
|
2639
|
-
compositionupdate: 1,
|
2640
|
-
copy: 1,
|
2641
|
-
cut: 1,
|
2642
|
-
dblclick: 1,
|
2643
|
-
DOMActivate: 1,
|
2644
|
-
DOMFocusIn: 1,
|
2645
|
-
DOMFocusOut: 1,
|
2646
|
-
drag: 1,
|
2647
|
-
dragend: 1,
|
2648
|
-
dragenter: 1,
|
2649
|
-
dragleave: 1,
|
2650
|
-
dragover: 1,
|
2651
|
-
dragstart: 1,
|
2652
|
-
drop: 1,
|
2653
|
-
focus: 1,
|
2654
|
-
focusin: 1,
|
2655
|
-
focusout: 1,
|
2656
|
-
gotpointercapture: 1,
|
2657
|
-
input: 1,
|
2658
|
-
keydown: 1,
|
2659
|
-
keypress: 1,
|
2660
|
-
keyup: 1,
|
2661
|
-
lostpointercapture: 1,
|
2662
|
-
mousedown: 1,
|
2663
|
-
mouseenter: 1,
|
2664
|
-
mouseleave: 1,
|
2665
|
-
mousemove: 1,
|
2666
|
-
mouseout: 1,
|
2667
|
-
mouseover: 1,
|
2668
|
-
mouseup: 1,
|
2669
|
-
paste: 1,
|
2670
|
-
pointercancel: 1,
|
2671
|
-
pointerdown: 1,
|
2672
|
-
pointerenter: 1,
|
2673
|
-
pointerleave: 1,
|
2674
|
-
pointermove: 1,
|
2675
|
-
pointerout: 1,
|
2676
|
-
pointerover: 1,
|
2677
|
-
pointerup: 1,
|
2678
|
-
touchcancel: 1,
|
2679
|
-
touchend: 1,
|
2680
|
-
touchmove: 1,
|
2681
|
-
touchstart: 1,
|
2682
|
-
wheel: 1,
|
2683
|
-
});
|
2684
|
-
const EventConstructor = Event;
|
2685
|
-
// Patch Event constructor to add the composed property on events created via new Event.
|
2686
|
-
function PatchedEvent(type, eventInitDict) {
|
2687
|
-
const event = new EventConstructor(type, eventInitDict);
|
2688
|
-
const isComposed = !!(eventInitDict && eventInitDict.composed);
|
2689
|
-
Object.defineProperties(event, {
|
2690
|
-
composed: {
|
2691
|
-
get() {
|
2692
|
-
return isComposed;
|
2693
|
-
},
|
2694
|
-
configurable: true,
|
2695
|
-
enumerable: true,
|
2696
|
-
},
|
2697
|
-
});
|
2698
|
-
return event;
|
2699
|
-
}
|
2700
|
-
PatchedEvent.prototype = EventConstructor.prototype;
|
2701
|
-
PatchedEvent.AT_TARGET = EventConstructor.AT_TARGET;
|
2702
|
-
PatchedEvent.BUBBLING_PHASE = EventConstructor.BUBBLING_PHASE;
|
2703
|
-
PatchedEvent.CAPTURING_PHASE = EventConstructor.CAPTURING_PHASE;
|
2704
|
-
PatchedEvent.NONE = EventConstructor.NONE;
|
2705
|
-
window.Event = PatchedEvent;
|
2706
|
-
// Patch the Event prototype to add the composed property on user agent dispatched event.
|
2707
|
-
Object.defineProperties(Event.prototype, {
|
2708
|
-
composed: {
|
2709
|
-
get() {
|
2710
|
-
const { type } = this;
|
2711
|
-
return composedEvents[type] === 1;
|
2712
|
-
},
|
2713
|
-
configurable: true,
|
2714
|
-
enumerable: true,
|
2715
|
-
},
|
2716
|
-
});
|
2717
|
-
}
|
2718
|
-
|
2719
|
-
/*
|
2720
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
2721
|
-
* All rights reserved.
|
2722
|
-
* SPDX-License-Identifier: MIT
|
2723
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
2724
|
-
*/
|
2725
|
-
if (detect()) {
|
2726
|
-
apply();
|
2727
|
-
}
|
2728
|
-
|
2729
2473
|
/*
|
2730
2474
|
* Copyright (c) 2018, salesforce.com, inc.
|
2731
2475
|
* All rights reserved.
|
@@ -2751,11 +2495,13 @@ PatchedCustomEvent.prototype = CustomEventConstructor.prototype;
|
|
2751
2495
|
window.CustomEvent = PatchedCustomEvent;
|
2752
2496
|
|
2753
2497
|
/*
|
2754
|
-
* Copyright (c)
|
2498
|
+
* Copyright (c) 2023, Salesforce.com, inc.
|
2755
2499
|
* All rights reserved.
|
2756
2500
|
* SPDX-License-Identifier: MIT
|
2757
2501
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
2758
2502
|
*/
|
2503
|
+
// Note that ClipboardEvent is undefined in Jest/jsdom
|
2504
|
+
// See: https://github.com/jsdom/jsdom/issues/1568
|
2759
2505
|
if (typeof ClipboardEvent !== 'undefined') {
|
2760
2506
|
const isComposedType = assign(create(null), {
|
2761
2507
|
copy: 1,
|
@@ -4467,5 +4213,5 @@ defineProperty(Element.prototype, '$domManual$', {
|
|
4467
4213
|
},
|
4468
4214
|
configurable: true,
|
4469
4215
|
});
|
4470
|
-
/** version: 3.
|
4216
|
+
/** version: 3.2.0 */
|
4471
4217
|
//# sourceMappingURL=index.cjs.js.map
|