lwc 2.13.0 → 2.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/engine-dom/esm/es2017/engine-dom.js +88 -88
- package/dist/engine-dom/iife/es2017/engine-dom.js +88 -88
- package/dist/engine-dom/iife/es2017/engine-dom.min.js +2 -2
- package/dist/engine-dom/iife/es2017/engine-dom_debug.js +76 -76
- package/dist/engine-dom/iife/es5/engine-dom.js +87 -87
- package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es5/engine-dom_debug.js +69 -69
- package/dist/engine-dom/umd/es2017/engine-dom.js +88 -88
- package/dist/engine-dom/umd/es2017/engine-dom.min.js +2 -2
- package/dist/engine-dom/umd/es2017/engine-dom_debug.js +76 -76
- package/dist/engine-dom/umd/es5/engine-dom.js +87 -87
- package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es5/engine-dom_debug.js +69 -69
- package/dist/engine-server/commonjs/es2017/engine-server.js +88 -88
- package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
- package/dist/engine-server/esm/es2017/engine-server.js +88 -88
- package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +693 -693
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +693 -693
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.min.js +2 -2
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +681 -681
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +686 -686
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow.min.js +1 -1
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +697 -697
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +693 -693
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.min.js +2 -2
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +681 -681
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +686 -686
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow.min.js +1 -1
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +697 -697
- package/dist/wire-service/esm/es2017/wire-service.js +2 -2
- package/dist/wire-service/iife/es2017/wire-service.js +2 -2
- package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
- package/dist/wire-service/iife/es5/wire-service.js +1 -1
- package/dist/wire-service/iife/es5/wire-service_debug.js +1 -1
- package/dist/wire-service/umd/es2017/wire-service.js +2 -2
- package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
- package/dist/wire-service/umd/es5/wire-service.js +1 -1
- package/dist/wire-service/umd/es5/wire-service_debug.js +1 -1
- package/package.json +7 -7
|
@@ -151,7 +151,7 @@
|
|
|
151
151
|
// We use this to detect symbol support in order to avoid the expensive symbol polyfill. Note that
|
|
152
152
|
// we can't use typeof since it will fail when transpiling.
|
|
153
153
|
const hasNativeSymbolSupport = /*@__PURE__*/ (() => Symbol('x').toString() === 'Symbol(x)')();
|
|
154
|
-
/** version: 2.13.
|
|
154
|
+
/** version: 2.13.1 */
|
|
155
155
|
|
|
156
156
|
/*
|
|
157
157
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -458,249 +458,6 @@
|
|
|
458
458
|
const eventTargetPrototype = typeof EventTarget !== 'undefined' ? EventTarget.prototype : _Node.prototype;
|
|
459
459
|
const { addEventListener, dispatchEvent, removeEventListener } = eventTargetPrototype;
|
|
460
460
|
|
|
461
|
-
/*
|
|
462
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
463
|
-
* All rights reserved.
|
|
464
|
-
* SPDX-License-Identifier: MIT
|
|
465
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
466
|
-
*/
|
|
467
|
-
const EventListenerMap = new WeakMap();
|
|
468
|
-
const ComposedPathMap = new WeakMap();
|
|
469
|
-
function isEventListenerOrEventListenerObject(fnOrObj) {
|
|
470
|
-
return (isFunction(fnOrObj) ||
|
|
471
|
-
(isObject(fnOrObj) &&
|
|
472
|
-
!isNull(fnOrObj) &&
|
|
473
|
-
isFunction(fnOrObj.handleEvent)));
|
|
474
|
-
}
|
|
475
|
-
function shouldInvokeListener(event, target, currentTarget) {
|
|
476
|
-
// Subsequent logic assumes that `currentTarget` must be contained in the composed path for the listener to be
|
|
477
|
-
// invoked, but this is not always the case. `composedPath()` will sometimes return an empty array, even when the
|
|
478
|
-
// listener should be invoked (e.g., a disconnected instance of EventTarget, an instance of XMLHttpRequest, etc).
|
|
479
|
-
if (target === currentTarget) {
|
|
480
|
-
return true;
|
|
481
|
-
}
|
|
482
|
-
let composedPath = ComposedPathMap.get(event);
|
|
483
|
-
if (isUndefined(composedPath)) {
|
|
484
|
-
composedPath = event.composedPath();
|
|
485
|
-
ComposedPathMap.set(event, composedPath);
|
|
486
|
-
}
|
|
487
|
-
return composedPath.includes(currentTarget);
|
|
488
|
-
}
|
|
489
|
-
function getEventListenerWrapper(fnOrObj) {
|
|
490
|
-
if (!isEventListenerOrEventListenerObject(fnOrObj)) {
|
|
491
|
-
return fnOrObj;
|
|
492
|
-
}
|
|
493
|
-
let wrapperFn = EventListenerMap.get(fnOrObj);
|
|
494
|
-
if (isUndefined(wrapperFn)) {
|
|
495
|
-
wrapperFn = function (event) {
|
|
496
|
-
// This function is invoked from an event listener and currentTarget is always defined.
|
|
497
|
-
const currentTarget = eventCurrentTargetGetter.call(event);
|
|
498
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
499
|
-
assert.invariant(isFalse(isSyntheticShadowHost(currentTarget)), 'This routine should not be used to wrap event listeners for host elements and shadow roots.');
|
|
500
|
-
}
|
|
501
|
-
const actualTarget = getActualTarget(event);
|
|
502
|
-
if (!shouldInvokeListener(event, actualTarget, currentTarget)) {
|
|
503
|
-
return;
|
|
504
|
-
}
|
|
505
|
-
return isFunction(fnOrObj)
|
|
506
|
-
? fnOrObj.call(this, event)
|
|
507
|
-
: fnOrObj.handleEvent && fnOrObj.handleEvent(event);
|
|
508
|
-
};
|
|
509
|
-
EventListenerMap.set(fnOrObj, wrapperFn);
|
|
510
|
-
}
|
|
511
|
-
return wrapperFn;
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
/*
|
|
515
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
516
|
-
* All rights reserved.
|
|
517
|
-
* SPDX-License-Identifier: MIT
|
|
518
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
519
|
-
*/
|
|
520
|
-
const eventToContextMap = new WeakMap();
|
|
521
|
-
const customElementToWrappedListeners = new WeakMap();
|
|
522
|
-
function getEventMap(elm) {
|
|
523
|
-
let listenerInfo = customElementToWrappedListeners.get(elm);
|
|
524
|
-
if (isUndefined(listenerInfo)) {
|
|
525
|
-
listenerInfo = create(null);
|
|
526
|
-
customElementToWrappedListeners.set(elm, listenerInfo);
|
|
527
|
-
}
|
|
528
|
-
return listenerInfo;
|
|
529
|
-
}
|
|
530
|
-
/**
|
|
531
|
-
* Events dispatched on shadow roots actually end up being dispatched on their hosts. This means that the event.target
|
|
532
|
-
* property of events dispatched on shadow roots always resolve to their host. This function understands this
|
|
533
|
-
* abstraction and properly returns a reference to the shadow root when appropriate.
|
|
534
|
-
*/
|
|
535
|
-
function getActualTarget(event) {
|
|
536
|
-
var _a;
|
|
537
|
-
return (_a = eventToShadowRootMap.get(event)) !== null && _a !== void 0 ? _a : eventTargetGetter.call(event);
|
|
538
|
-
}
|
|
539
|
-
const shadowRootEventListenerMap = new WeakMap();
|
|
540
|
-
function getWrappedShadowRootListener(listener) {
|
|
541
|
-
if (!isFunction(listener)) {
|
|
542
|
-
throw new TypeError(); // avoiding problems with non-valid listeners
|
|
543
|
-
}
|
|
544
|
-
let shadowRootWrappedListener = shadowRootEventListenerMap.get(listener);
|
|
545
|
-
if (isUndefined(shadowRootWrappedListener)) {
|
|
546
|
-
shadowRootWrappedListener = function (event) {
|
|
547
|
-
// currentTarget is always defined inside an event listener
|
|
548
|
-
let currentTarget = eventCurrentTargetGetter.call(event);
|
|
549
|
-
// If currentTarget is not an instance of a native shadow root then we're dealing with a
|
|
550
|
-
// host element whose synthetic shadow root must be accessed via getShadowRoot().
|
|
551
|
-
if (!isInstanceOfNativeShadowRoot(currentTarget)) {
|
|
552
|
-
currentTarget = getShadowRoot(currentTarget);
|
|
553
|
-
}
|
|
554
|
-
const actualTarget = getActualTarget(event);
|
|
555
|
-
if (shouldInvokeListener(event, actualTarget, currentTarget)) {
|
|
556
|
-
listener.call(currentTarget, event);
|
|
557
|
-
}
|
|
558
|
-
};
|
|
559
|
-
shadowRootWrappedListener.placement = 1 /* SHADOW_ROOT_LISTENER */;
|
|
560
|
-
shadowRootEventListenerMap.set(listener, shadowRootWrappedListener);
|
|
561
|
-
}
|
|
562
|
-
return shadowRootWrappedListener;
|
|
563
|
-
}
|
|
564
|
-
const customElementEventListenerMap = new WeakMap();
|
|
565
|
-
function getWrappedCustomElementListener(listener) {
|
|
566
|
-
if (!isFunction(listener)) {
|
|
567
|
-
throw new TypeError(); // avoiding problems with non-valid listeners
|
|
568
|
-
}
|
|
569
|
-
let customElementWrappedListener = customElementEventListenerMap.get(listener);
|
|
570
|
-
if (isUndefined(customElementWrappedListener)) {
|
|
571
|
-
customElementWrappedListener = function (event) {
|
|
572
|
-
// currentTarget is always defined inside an event listener
|
|
573
|
-
const currentTarget = eventCurrentTargetGetter.call(event);
|
|
574
|
-
const actualTarget = getActualTarget(event);
|
|
575
|
-
if (shouldInvokeListener(event, actualTarget, currentTarget)) {
|
|
576
|
-
listener.call(currentTarget, event);
|
|
577
|
-
}
|
|
578
|
-
};
|
|
579
|
-
customElementWrappedListener.placement = 0 /* CUSTOM_ELEMENT_LISTENER */;
|
|
580
|
-
customElementEventListenerMap.set(listener, customElementWrappedListener);
|
|
581
|
-
}
|
|
582
|
-
return customElementWrappedListener;
|
|
583
|
-
}
|
|
584
|
-
function domListener(evt) {
|
|
585
|
-
let immediatePropagationStopped = false;
|
|
586
|
-
let propagationStopped = false;
|
|
587
|
-
const { type, stopImmediatePropagation, stopPropagation } = evt;
|
|
588
|
-
// currentTarget is always defined
|
|
589
|
-
const currentTarget = eventCurrentTargetGetter.call(evt);
|
|
590
|
-
const listenerMap = getEventMap(currentTarget);
|
|
591
|
-
const listeners = listenerMap[type]; // it must have listeners at this point
|
|
592
|
-
defineProperty(evt, 'stopImmediatePropagation', {
|
|
593
|
-
value() {
|
|
594
|
-
immediatePropagationStopped = true;
|
|
595
|
-
stopImmediatePropagation.call(evt);
|
|
596
|
-
},
|
|
597
|
-
writable: true,
|
|
598
|
-
enumerable: true,
|
|
599
|
-
configurable: true,
|
|
600
|
-
});
|
|
601
|
-
defineProperty(evt, 'stopPropagation', {
|
|
602
|
-
value() {
|
|
603
|
-
propagationStopped = true;
|
|
604
|
-
stopPropagation.call(evt);
|
|
605
|
-
},
|
|
606
|
-
writable: true,
|
|
607
|
-
enumerable: true,
|
|
608
|
-
configurable: true,
|
|
609
|
-
});
|
|
610
|
-
// in case a listener adds or removes other listeners during invocation
|
|
611
|
-
const bookkeeping = ArraySlice.call(listeners);
|
|
612
|
-
function invokeListenersByPlacement(placement) {
|
|
613
|
-
forEach.call(bookkeeping, (listener) => {
|
|
614
|
-
if (isFalse(immediatePropagationStopped) && listener.placement === placement) {
|
|
615
|
-
// making sure that the listener was not removed from the original listener queue
|
|
616
|
-
if (ArrayIndexOf.call(listeners, listener) !== -1) {
|
|
617
|
-
// all handlers on the custom element should be called with undefined 'this'
|
|
618
|
-
listener.call(undefined, evt);
|
|
619
|
-
}
|
|
620
|
-
}
|
|
621
|
-
});
|
|
622
|
-
}
|
|
623
|
-
eventToContextMap.set(evt, 1 /* SHADOW_ROOT_LISTENER */);
|
|
624
|
-
invokeListenersByPlacement(1 /* SHADOW_ROOT_LISTENER */);
|
|
625
|
-
if (isFalse(immediatePropagationStopped) && isFalse(propagationStopped)) {
|
|
626
|
-
// doing the second iteration only if the first one didn't interrupt the event propagation
|
|
627
|
-
eventToContextMap.set(evt, 0 /* CUSTOM_ELEMENT_LISTENER */);
|
|
628
|
-
invokeListenersByPlacement(0 /* CUSTOM_ELEMENT_LISTENER */);
|
|
629
|
-
}
|
|
630
|
-
eventToContextMap.set(evt, 2 /* UNKNOWN_LISTENER */);
|
|
631
|
-
}
|
|
632
|
-
function attachDOMListener(elm, type, wrappedListener) {
|
|
633
|
-
const listenerMap = getEventMap(elm);
|
|
634
|
-
let cmpEventHandlers = listenerMap[type];
|
|
635
|
-
if (isUndefined(cmpEventHandlers)) {
|
|
636
|
-
cmpEventHandlers = listenerMap[type] = [];
|
|
637
|
-
}
|
|
638
|
-
// Prevent identical listeners from subscribing to the same event type.
|
|
639
|
-
// TODO [#1824]: Options will also play a factor when we introduce support for them (#1824).
|
|
640
|
-
if (ArrayIndexOf.call(cmpEventHandlers, wrappedListener) !== -1) {
|
|
641
|
-
return;
|
|
642
|
-
}
|
|
643
|
-
// only add to DOM if there is no other listener on the same placement yet
|
|
644
|
-
if (cmpEventHandlers.length === 0) {
|
|
645
|
-
// super.addEventListener() - this will not work on
|
|
646
|
-
addEventListener.call(elm, type, domListener);
|
|
647
|
-
}
|
|
648
|
-
ArrayPush.call(cmpEventHandlers, wrappedListener);
|
|
649
|
-
}
|
|
650
|
-
function detachDOMListener(elm, type, wrappedListener) {
|
|
651
|
-
const listenerMap = getEventMap(elm);
|
|
652
|
-
let p;
|
|
653
|
-
let listeners;
|
|
654
|
-
if (!isUndefined((listeners = listenerMap[type])) &&
|
|
655
|
-
(p = ArrayIndexOf.call(listeners, wrappedListener)) !== -1) {
|
|
656
|
-
ArraySplice.call(listeners, p, 1);
|
|
657
|
-
// only remove from DOM if there is no other listener on the same placement
|
|
658
|
-
if (listeners.length === 0) {
|
|
659
|
-
removeEventListener.call(elm, type, domListener);
|
|
660
|
-
}
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
function addCustomElementEventListener(type, listener, _options) {
|
|
664
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
665
|
-
if (!isFunction(listener)) {
|
|
666
|
-
throw new TypeError(`Invalid second argument for Element.addEventListener() in ${toString(this)} for event "${type}". Expected an EventListener but received ${listener}.`);
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
// TODO [#1824]: Lift this restriction on the option parameter
|
|
670
|
-
if (isFunction(listener)) {
|
|
671
|
-
const wrappedListener = getWrappedCustomElementListener(listener);
|
|
672
|
-
attachDOMListener(this, type, wrappedListener);
|
|
673
|
-
}
|
|
674
|
-
}
|
|
675
|
-
function removeCustomElementEventListener(type, listener, _options) {
|
|
676
|
-
// TODO [#1824]: Lift this restriction on the option parameter
|
|
677
|
-
if (isFunction(listener)) {
|
|
678
|
-
const wrappedListener = getWrappedCustomElementListener(listener);
|
|
679
|
-
detachDOMListener(this, type, wrappedListener);
|
|
680
|
-
}
|
|
681
|
-
}
|
|
682
|
-
function addShadowRootEventListener(sr, type, listener, _options) {
|
|
683
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
684
|
-
if (!isFunction(listener)) {
|
|
685
|
-
throw new TypeError(`Invalid second argument for ShadowRoot.addEventListener() in ${toString(sr)} for event "${type}". Expected an EventListener but received ${listener}.`);
|
|
686
|
-
}
|
|
687
|
-
}
|
|
688
|
-
// TODO [#1824]: Lift this restriction on the option parameter
|
|
689
|
-
if (isFunction(listener)) {
|
|
690
|
-
const elm = getHost(sr);
|
|
691
|
-
const wrappedListener = getWrappedShadowRootListener(listener);
|
|
692
|
-
attachDOMListener(elm, type, wrappedListener);
|
|
693
|
-
}
|
|
694
|
-
}
|
|
695
|
-
function removeShadowRootEventListener(sr, type, listener, _options) {
|
|
696
|
-
// TODO [#1824]: Lift this restriction on the option parameter
|
|
697
|
-
if (isFunction(listener)) {
|
|
698
|
-
const elm = getHost(sr);
|
|
699
|
-
const wrappedListener = getWrappedShadowRootListener(listener);
|
|
700
|
-
detachDOMListener(elm, type, wrappedListener);
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
|
-
|
|
704
461
|
/*
|
|
705
462
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
706
463
|
* All rights reserved.
|
|
@@ -964,19 +721,136 @@
|
|
|
964
721
|
* SPDX-License-Identifier: MIT
|
|
965
722
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
966
723
|
*/
|
|
967
|
-
function
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
724
|
+
function getInnerHTML(node) {
|
|
725
|
+
let s = '';
|
|
726
|
+
const childNodes = getFilteredChildNodes(node);
|
|
727
|
+
for (let i = 0, len = childNodes.length; i < len; i += 1) {
|
|
728
|
+
s += getOuterHTML(childNodes[i]);
|
|
729
|
+
}
|
|
730
|
+
return s;
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
/*
|
|
734
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
735
|
+
* All rights reserved.
|
|
736
|
+
* SPDX-License-Identifier: MIT
|
|
737
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
738
|
+
*/
|
|
739
|
+
// http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#escapingString
|
|
740
|
+
const escapeAttrRegExp = /[&\u00A0"]/g;
|
|
741
|
+
const escapeDataRegExp = /[&\u00A0<>]/g;
|
|
742
|
+
const { replace, toLowerCase } = String.prototype;
|
|
743
|
+
function escapeReplace(c) {
|
|
744
|
+
switch (c) {
|
|
745
|
+
case '&':
|
|
746
|
+
return '&';
|
|
747
|
+
case '<':
|
|
748
|
+
return '<';
|
|
749
|
+
case '>':
|
|
750
|
+
return '>';
|
|
751
|
+
case '"':
|
|
752
|
+
return '"';
|
|
753
|
+
case '\u00A0':
|
|
754
|
+
return ' ';
|
|
755
|
+
default:
|
|
756
|
+
return '';
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
function escapeAttr(s) {
|
|
760
|
+
return replace.call(s, escapeAttrRegExp, escapeReplace);
|
|
761
|
+
}
|
|
762
|
+
function escapeData(s) {
|
|
763
|
+
return replace.call(s, escapeDataRegExp, escapeReplace);
|
|
764
|
+
}
|
|
765
|
+
// http://www.whatwg.org/specs/web-apps/current-work/#void-elements
|
|
766
|
+
const voidElements = new Set([
|
|
767
|
+
'AREA',
|
|
768
|
+
'BASE',
|
|
769
|
+
'BR',
|
|
770
|
+
'COL',
|
|
771
|
+
'COMMAND',
|
|
772
|
+
'EMBED',
|
|
773
|
+
'HR',
|
|
774
|
+
'IMG',
|
|
775
|
+
'INPUT',
|
|
776
|
+
'KEYGEN',
|
|
777
|
+
'LINK',
|
|
778
|
+
'META',
|
|
779
|
+
'PARAM',
|
|
780
|
+
'SOURCE',
|
|
781
|
+
'TRACK',
|
|
782
|
+
'WBR',
|
|
783
|
+
]);
|
|
784
|
+
const plaintextParents = new Set([
|
|
785
|
+
'STYLE',
|
|
786
|
+
'SCRIPT',
|
|
787
|
+
'XMP',
|
|
788
|
+
'IFRAME',
|
|
789
|
+
'NOEMBED',
|
|
790
|
+
'NOFRAMES',
|
|
791
|
+
'PLAINTEXT',
|
|
792
|
+
'NOSCRIPT',
|
|
793
|
+
]);
|
|
794
|
+
function getOuterHTML(node) {
|
|
795
|
+
switch (node.nodeType) {
|
|
796
|
+
case ELEMENT_NODE: {
|
|
797
|
+
const { attributes: attrs } = node;
|
|
798
|
+
const tagName = tagNameGetter.call(node);
|
|
799
|
+
let s = '<' + toLowerCase.call(tagName);
|
|
800
|
+
for (let i = 0, attr; (attr = attrs[i]); i++) {
|
|
801
|
+
s += ' ' + attr.name + '="' + escapeAttr(attr.value) + '"';
|
|
802
|
+
}
|
|
803
|
+
s += '>';
|
|
804
|
+
if (voidElements.has(tagName)) {
|
|
805
|
+
return s;
|
|
806
|
+
}
|
|
807
|
+
return s + getInnerHTML(node) + '</' + toLowerCase.call(tagName) + '>';
|
|
808
|
+
}
|
|
809
|
+
case TEXT_NODE: {
|
|
810
|
+
const { data, parentNode } = node;
|
|
811
|
+
if (parentNode instanceof Element &&
|
|
812
|
+
plaintextParents.has(tagNameGetter.call(parentNode))) {
|
|
813
|
+
return data;
|
|
814
|
+
}
|
|
815
|
+
return escapeData(data);
|
|
816
|
+
}
|
|
817
|
+
case CDATA_SECTION_NODE: {
|
|
818
|
+
return `<!CDATA[[${node.data}]]>`;
|
|
819
|
+
}
|
|
820
|
+
case PROCESSING_INSTRUCTION_NODE: {
|
|
821
|
+
return `<?${node.target} ${node.data}?>`;
|
|
822
|
+
}
|
|
823
|
+
case COMMENT_NODE: {
|
|
824
|
+
return `<!--${node.data}-->`;
|
|
825
|
+
}
|
|
826
|
+
default: {
|
|
827
|
+
// intentionally ignoring unknown node types
|
|
828
|
+
// Note: since this routine is always invoked for childNodes
|
|
829
|
+
// we can safety ignore type 9, 10 and 99 (document, fragment and doctype)
|
|
830
|
+
return '';
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
/*
|
|
836
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
837
|
+
* All rights reserved.
|
|
838
|
+
* SPDX-License-Identifier: MIT
|
|
839
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
840
|
+
*/
|
|
841
|
+
function getTextContent(node) {
|
|
842
|
+
switch (node.nodeType) {
|
|
843
|
+
case ELEMENT_NODE: {
|
|
844
|
+
const childNodes = getFilteredChildNodes(node);
|
|
845
|
+
let content = '';
|
|
846
|
+
for (let i = 0, len = childNodes.length; i < len; i += 1) {
|
|
847
|
+
const currentNode = childNodes[i];
|
|
848
|
+
if (currentNode.nodeType !== COMMENT_NODE) {
|
|
849
|
+
content += getTextContent(currentNode);
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
return content;
|
|
853
|
+
}
|
|
980
854
|
default:
|
|
981
855
|
return node.nodeValue;
|
|
982
856
|
}
|
|
@@ -1098,6 +972,71 @@
|
|
|
1098
972
|
return nodeList;
|
|
1099
973
|
}
|
|
1100
974
|
|
|
975
|
+
/*
|
|
976
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
977
|
+
* All rights reserved.
|
|
978
|
+
* SPDX-License-Identifier: MIT
|
|
979
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
980
|
+
*/
|
|
981
|
+
// Walk up the DOM tree, collecting all shadow roots plus the document root
|
|
982
|
+
function getAllRootNodes(node) {
|
|
983
|
+
var _a;
|
|
984
|
+
const rootNodes = [];
|
|
985
|
+
let currentRootNode = node.getRootNode();
|
|
986
|
+
while (!isUndefined(currentRootNode)) {
|
|
987
|
+
rootNodes.push(currentRootNode);
|
|
988
|
+
currentRootNode = (_a = currentRootNode.host) === null || _a === void 0 ? void 0 : _a.getRootNode();
|
|
989
|
+
}
|
|
990
|
+
return rootNodes;
|
|
991
|
+
}
|
|
992
|
+
// Keep searching up the host tree until we find an element that is within the immediate shadow root
|
|
993
|
+
const findAncestorHostInImmediateShadowRoot = (rootNode, targetRootNode) => {
|
|
994
|
+
let host;
|
|
995
|
+
while (!isUndefined((host = rootNode.host))) {
|
|
996
|
+
const thisRootNode = host.getRootNode();
|
|
997
|
+
if (thisRootNode === targetRootNode) {
|
|
998
|
+
return host;
|
|
999
|
+
}
|
|
1000
|
+
rootNode = thisRootNode;
|
|
1001
|
+
}
|
|
1002
|
+
};
|
|
1003
|
+
function fauxElementsFromPoint(context, doc, left, top) {
|
|
1004
|
+
const elements = elementsFromPoint.call(doc, left, top);
|
|
1005
|
+
const result = [];
|
|
1006
|
+
const rootNodes = getAllRootNodes(context);
|
|
1007
|
+
// Filter the elements array to only include those elements that are in this shadow root or in one of its
|
|
1008
|
+
// ancestor roots. This matches Chrome and Safari's implementation (but not Firefox's, which only includes
|
|
1009
|
+
// elements in the immediate shadow root: https://crbug.com/1207863#c4).
|
|
1010
|
+
if (!isNull(elements)) {
|
|
1011
|
+
// can be null in IE https://developer.mozilla.org/en-US/docs/Web/API/Document/elementsFromPoint#browser_compatibility
|
|
1012
|
+
for (let i = 0; i < elements.length; i++) {
|
|
1013
|
+
const element = elements[i];
|
|
1014
|
+
if (isSyntheticSlotElement(element)) {
|
|
1015
|
+
continue;
|
|
1016
|
+
}
|
|
1017
|
+
const elementRootNode = element.getRootNode();
|
|
1018
|
+
if (ArrayIndexOf.call(rootNodes, elementRootNode) !== -1) {
|
|
1019
|
+
ArrayPush.call(result, element);
|
|
1020
|
+
continue;
|
|
1021
|
+
}
|
|
1022
|
+
// In cases where the host element is not visible but its shadow descendants are, then
|
|
1023
|
+
// we may get the shadow descendant instead of the host element here. (The
|
|
1024
|
+
// browser doesn't know the difference in synthetic shadow DOM.)
|
|
1025
|
+
// In native shadow DOM, however, elementsFromPoint would return the host but not
|
|
1026
|
+
// the child. So we need to detect if this shadow element's host is accessible from
|
|
1027
|
+
// the context's shadow root. Note we also need to be careful not to add the host
|
|
1028
|
+
// multiple times.
|
|
1029
|
+
const ancestorHost = findAncestorHostInImmediateShadowRoot(elementRootNode, rootNodes[0]);
|
|
1030
|
+
if (!isUndefined(ancestorHost) &&
|
|
1031
|
+
ArrayIndexOf.call(elements, ancestorHost) === -1 &&
|
|
1032
|
+
ArrayIndexOf.call(result, ancestorHost) === -1) {
|
|
1033
|
+
ArrayPush.call(result, ancestorHost);
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
return result;
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1101
1040
|
/*
|
|
1102
1041
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
1103
1042
|
* All rights reserved.
|
|
@@ -1135,167 +1074,50 @@
|
|
|
1135
1074
|
enumerable: true,
|
|
1136
1075
|
configurable: true,
|
|
1137
1076
|
value(name) {
|
|
1138
|
-
if (name === '') {
|
|
1139
|
-
return null;
|
|
1140
|
-
}
|
|
1141
|
-
const items = Items.get(this);
|
|
1142
|
-
for (let i = 0, len = items.length; i < len; i++) {
|
|
1143
|
-
const item = items[len];
|
|
1144
|
-
if (name === getAttribute.call(item, 'id') ||
|
|
1145
|
-
name === getAttribute.call(item, 'name')) {
|
|
1146
|
-
return item;
|
|
1147
|
-
}
|
|
1148
|
-
}
|
|
1149
|
-
return null;
|
|
1150
|
-
},
|
|
1151
|
-
},
|
|
1152
|
-
[Symbol.toStringTag]: {
|
|
1153
|
-
configurable: true,
|
|
1154
|
-
get() {
|
|
1155
|
-
return 'HTMLCollection';
|
|
1156
|
-
},
|
|
1157
|
-
},
|
|
1158
|
-
// IE11 doesn't support Symbol.toStringTag, in which case we
|
|
1159
|
-
// provide the regular toString method.
|
|
1160
|
-
toString: {
|
|
1161
|
-
writable: true,
|
|
1162
|
-
configurable: true,
|
|
1163
|
-
value() {
|
|
1164
|
-
return '[object HTMLCollection]';
|
|
1165
|
-
},
|
|
1166
|
-
},
|
|
1167
|
-
});
|
|
1168
|
-
// prototype inheritance dance
|
|
1169
|
-
setPrototypeOf(StaticHTMLCollection, HTMLCollection);
|
|
1170
|
-
function createStaticHTMLCollection(items) {
|
|
1171
|
-
const collection = create(StaticHTMLCollection.prototype);
|
|
1172
|
-
Items.set(collection, items);
|
|
1173
|
-
// setting static indexes
|
|
1174
|
-
forEach.call(items, (item, index) => {
|
|
1175
|
-
defineProperty(collection, index, {
|
|
1176
|
-
value: item,
|
|
1177
|
-
enumerable: true,
|
|
1178
|
-
configurable: true,
|
|
1179
|
-
});
|
|
1180
|
-
});
|
|
1181
|
-
return collection;
|
|
1182
|
-
}
|
|
1183
|
-
|
|
1184
|
-
/*
|
|
1185
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
1186
|
-
* All rights reserved.
|
|
1187
|
-
* SPDX-License-Identifier: MIT
|
|
1188
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1189
|
-
*/
|
|
1190
|
-
function getInnerHTML(node) {
|
|
1191
|
-
let s = '';
|
|
1192
|
-
const childNodes = getFilteredChildNodes(node);
|
|
1193
|
-
for (let i = 0, len = childNodes.length; i < len; i += 1) {
|
|
1194
|
-
s += getOuterHTML(childNodes[i]);
|
|
1195
|
-
}
|
|
1196
|
-
return s;
|
|
1197
|
-
}
|
|
1198
|
-
|
|
1199
|
-
/*
|
|
1200
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
1201
|
-
* All rights reserved.
|
|
1202
|
-
* SPDX-License-Identifier: MIT
|
|
1203
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1204
|
-
*/
|
|
1205
|
-
// http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#escapingString
|
|
1206
|
-
const escapeAttrRegExp = /[&\u00A0"]/g;
|
|
1207
|
-
const escapeDataRegExp = /[&\u00A0<>]/g;
|
|
1208
|
-
const { replace, toLowerCase } = String.prototype;
|
|
1209
|
-
function escapeReplace(c) {
|
|
1210
|
-
switch (c) {
|
|
1211
|
-
case '&':
|
|
1212
|
-
return '&';
|
|
1213
|
-
case '<':
|
|
1214
|
-
return '<';
|
|
1215
|
-
case '>':
|
|
1216
|
-
return '>';
|
|
1217
|
-
case '"':
|
|
1218
|
-
return '"';
|
|
1219
|
-
case '\u00A0':
|
|
1220
|
-
return ' ';
|
|
1221
|
-
default:
|
|
1222
|
-
return '';
|
|
1223
|
-
}
|
|
1224
|
-
}
|
|
1225
|
-
function escapeAttr(s) {
|
|
1226
|
-
return replace.call(s, escapeAttrRegExp, escapeReplace);
|
|
1227
|
-
}
|
|
1228
|
-
function escapeData(s) {
|
|
1229
|
-
return replace.call(s, escapeDataRegExp, escapeReplace);
|
|
1230
|
-
}
|
|
1231
|
-
// http://www.whatwg.org/specs/web-apps/current-work/#void-elements
|
|
1232
|
-
const voidElements = new Set([
|
|
1233
|
-
'AREA',
|
|
1234
|
-
'BASE',
|
|
1235
|
-
'BR',
|
|
1236
|
-
'COL',
|
|
1237
|
-
'COMMAND',
|
|
1238
|
-
'EMBED',
|
|
1239
|
-
'HR',
|
|
1240
|
-
'IMG',
|
|
1241
|
-
'INPUT',
|
|
1242
|
-
'KEYGEN',
|
|
1243
|
-
'LINK',
|
|
1244
|
-
'META',
|
|
1245
|
-
'PARAM',
|
|
1246
|
-
'SOURCE',
|
|
1247
|
-
'TRACK',
|
|
1248
|
-
'WBR',
|
|
1249
|
-
]);
|
|
1250
|
-
const plaintextParents = new Set([
|
|
1251
|
-
'STYLE',
|
|
1252
|
-
'SCRIPT',
|
|
1253
|
-
'XMP',
|
|
1254
|
-
'IFRAME',
|
|
1255
|
-
'NOEMBED',
|
|
1256
|
-
'NOFRAMES',
|
|
1257
|
-
'PLAINTEXT',
|
|
1258
|
-
'NOSCRIPT',
|
|
1259
|
-
]);
|
|
1260
|
-
function getOuterHTML(node) {
|
|
1261
|
-
switch (node.nodeType) {
|
|
1262
|
-
case ELEMENT_NODE: {
|
|
1263
|
-
const { attributes: attrs } = node;
|
|
1264
|
-
const tagName = tagNameGetter.call(node);
|
|
1265
|
-
let s = '<' + toLowerCase.call(tagName);
|
|
1266
|
-
for (let i = 0, attr; (attr = attrs[i]); i++) {
|
|
1267
|
-
s += ' ' + attr.name + '="' + escapeAttr(attr.value) + '"';
|
|
1268
|
-
}
|
|
1269
|
-
s += '>';
|
|
1270
|
-
if (voidElements.has(tagName)) {
|
|
1271
|
-
return s;
|
|
1272
|
-
}
|
|
1273
|
-
return s + getInnerHTML(node) + '</' + toLowerCase.call(tagName) + '>';
|
|
1274
|
-
}
|
|
1275
|
-
case TEXT_NODE: {
|
|
1276
|
-
const { data, parentNode } = node;
|
|
1277
|
-
if (parentNode instanceof Element &&
|
|
1278
|
-
plaintextParents.has(tagNameGetter.call(parentNode))) {
|
|
1279
|
-
return data;
|
|
1280
|
-
}
|
|
1281
|
-
return escapeData(data);
|
|
1282
|
-
}
|
|
1283
|
-
case CDATA_SECTION_NODE: {
|
|
1284
|
-
return `<!CDATA[[${node.data}]]>`;
|
|
1285
|
-
}
|
|
1286
|
-
case PROCESSING_INSTRUCTION_NODE: {
|
|
1287
|
-
return `<?${node.target} ${node.data}?>`;
|
|
1288
|
-
}
|
|
1289
|
-
case COMMENT_NODE: {
|
|
1290
|
-
return `<!--${node.data}-->`;
|
|
1291
|
-
}
|
|
1292
|
-
default: {
|
|
1293
|
-
// intentionally ignoring unknown node types
|
|
1294
|
-
// Note: since this routine is always invoked for childNodes
|
|
1295
|
-
// we can safety ignore type 9, 10 and 99 (document, fragment and doctype)
|
|
1296
|
-
return '';
|
|
1297
|
-
}
|
|
1298
|
-
}
|
|
1077
|
+
if (name === '') {
|
|
1078
|
+
return null;
|
|
1079
|
+
}
|
|
1080
|
+
const items = Items.get(this);
|
|
1081
|
+
for (let i = 0, len = items.length; i < len; i++) {
|
|
1082
|
+
const item = items[len];
|
|
1083
|
+
if (name === getAttribute.call(item, 'id') ||
|
|
1084
|
+
name === getAttribute.call(item, 'name')) {
|
|
1085
|
+
return item;
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
return null;
|
|
1089
|
+
},
|
|
1090
|
+
},
|
|
1091
|
+
[Symbol.toStringTag]: {
|
|
1092
|
+
configurable: true,
|
|
1093
|
+
get() {
|
|
1094
|
+
return 'HTMLCollection';
|
|
1095
|
+
},
|
|
1096
|
+
},
|
|
1097
|
+
// IE11 doesn't support Symbol.toStringTag, in which case we
|
|
1098
|
+
// provide the regular toString method.
|
|
1099
|
+
toString: {
|
|
1100
|
+
writable: true,
|
|
1101
|
+
configurable: true,
|
|
1102
|
+
value() {
|
|
1103
|
+
return '[object HTMLCollection]';
|
|
1104
|
+
},
|
|
1105
|
+
},
|
|
1106
|
+
});
|
|
1107
|
+
// prototype inheritance dance
|
|
1108
|
+
setPrototypeOf(StaticHTMLCollection, HTMLCollection);
|
|
1109
|
+
function createStaticHTMLCollection(items) {
|
|
1110
|
+
const collection = create(StaticHTMLCollection.prototype);
|
|
1111
|
+
Items.set(collection, items);
|
|
1112
|
+
// setting static indexes
|
|
1113
|
+
forEach.call(items, (item, index) => {
|
|
1114
|
+
defineProperty(collection, index, {
|
|
1115
|
+
value: item,
|
|
1116
|
+
enumerable: true,
|
|
1117
|
+
configurable: true,
|
|
1118
|
+
});
|
|
1119
|
+
});
|
|
1120
|
+
return collection;
|
|
1299
1121
|
}
|
|
1300
1122
|
|
|
1301
1123
|
/**
|
|
@@ -1305,7 +1127,7 @@
|
|
|
1305
1127
|
Object.defineProperty(_globalThis, 'lwcRuntimeFlags', { value: create(null) });
|
|
1306
1128
|
}
|
|
1307
1129
|
const runtimeFlags = _globalThis.lwcRuntimeFlags;
|
|
1308
|
-
/** version: 2.13.
|
|
1130
|
+
/** version: 2.13.1 */
|
|
1309
1131
|
|
|
1310
1132
|
/*
|
|
1311
1133
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -1778,63 +1600,241 @@
|
|
|
1778
1600
|
* SPDX-License-Identifier: MIT
|
|
1779
1601
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1780
1602
|
*/
|
|
1781
|
-
|
|
1782
|
-
|
|
1603
|
+
const EventListenerMap = new WeakMap();
|
|
1604
|
+
const ComposedPathMap = new WeakMap();
|
|
1605
|
+
function isEventListenerOrEventListenerObject(fnOrObj) {
|
|
1606
|
+
return (isFunction(fnOrObj) ||
|
|
1607
|
+
(isObject(fnOrObj) &&
|
|
1608
|
+
!isNull(fnOrObj) &&
|
|
1609
|
+
isFunction(fnOrObj.handleEvent)));
|
|
1610
|
+
}
|
|
1611
|
+
function shouldInvokeListener(event, target, currentTarget) {
|
|
1612
|
+
// Subsequent logic assumes that `currentTarget` must be contained in the composed path for the listener to be
|
|
1613
|
+
// invoked, but this is not always the case. `composedPath()` will sometimes return an empty array, even when the
|
|
1614
|
+
// listener should be invoked (e.g., a disconnected instance of EventTarget, an instance of XMLHttpRequest, etc).
|
|
1615
|
+
if (target === currentTarget) {
|
|
1616
|
+
return true;
|
|
1617
|
+
}
|
|
1618
|
+
let composedPath = ComposedPathMap.get(event);
|
|
1619
|
+
if (isUndefined(composedPath)) {
|
|
1620
|
+
composedPath = event.composedPath();
|
|
1621
|
+
ComposedPathMap.set(event, composedPath);
|
|
1622
|
+
}
|
|
1623
|
+
return composedPath.includes(currentTarget);
|
|
1624
|
+
}
|
|
1625
|
+
function getEventListenerWrapper(fnOrObj) {
|
|
1626
|
+
if (!isEventListenerOrEventListenerObject(fnOrObj)) {
|
|
1627
|
+
return fnOrObj;
|
|
1628
|
+
}
|
|
1629
|
+
let wrapperFn = EventListenerMap.get(fnOrObj);
|
|
1630
|
+
if (isUndefined(wrapperFn)) {
|
|
1631
|
+
wrapperFn = function (event) {
|
|
1632
|
+
// This function is invoked from an event listener and currentTarget is always defined.
|
|
1633
|
+
const currentTarget = eventCurrentTargetGetter.call(event);
|
|
1634
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1635
|
+
assert.invariant(isFalse(isSyntheticShadowHost(currentTarget)), 'This routine should not be used to wrap event listeners for host elements and shadow roots.');
|
|
1636
|
+
}
|
|
1637
|
+
const actualTarget = getActualTarget(event);
|
|
1638
|
+
if (!shouldInvokeListener(event, actualTarget, currentTarget)) {
|
|
1639
|
+
return;
|
|
1640
|
+
}
|
|
1641
|
+
return isFunction(fnOrObj)
|
|
1642
|
+
? fnOrObj.call(this, event)
|
|
1643
|
+
: fnOrObj.handleEvent && fnOrObj.handleEvent(event);
|
|
1644
|
+
};
|
|
1645
|
+
EventListenerMap.set(fnOrObj, wrapperFn);
|
|
1646
|
+
}
|
|
1647
|
+
return wrapperFn;
|
|
1648
|
+
}
|
|
1649
|
+
|
|
1650
|
+
/*
|
|
1651
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
1652
|
+
* All rights reserved.
|
|
1653
|
+
* SPDX-License-Identifier: MIT
|
|
1654
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1655
|
+
*/
|
|
1656
|
+
const eventToContextMap = new WeakMap();
|
|
1657
|
+
const customElementToWrappedListeners = new WeakMap();
|
|
1658
|
+
function getEventMap(elm) {
|
|
1659
|
+
let listenerInfo = customElementToWrappedListeners.get(elm);
|
|
1660
|
+
if (isUndefined(listenerInfo)) {
|
|
1661
|
+
listenerInfo = create(null);
|
|
1662
|
+
customElementToWrappedListeners.set(elm, listenerInfo);
|
|
1663
|
+
}
|
|
1664
|
+
return listenerInfo;
|
|
1665
|
+
}
|
|
1666
|
+
/**
|
|
1667
|
+
* Events dispatched on shadow roots actually end up being dispatched on their hosts. This means that the event.target
|
|
1668
|
+
* property of events dispatched on shadow roots always resolve to their host. This function understands this
|
|
1669
|
+
* abstraction and properly returns a reference to the shadow root when appropriate.
|
|
1670
|
+
*/
|
|
1671
|
+
function getActualTarget(event) {
|
|
1783
1672
|
var _a;
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1673
|
+
return (_a = eventToShadowRootMap.get(event)) !== null && _a !== void 0 ? _a : eventTargetGetter.call(event);
|
|
1674
|
+
}
|
|
1675
|
+
const shadowRootEventListenerMap = new WeakMap();
|
|
1676
|
+
function getWrappedShadowRootListener(listener) {
|
|
1677
|
+
if (!isFunction(listener)) {
|
|
1678
|
+
throw new TypeError(); // avoiding problems with non-valid listeners
|
|
1679
|
+
}
|
|
1680
|
+
let shadowRootWrappedListener = shadowRootEventListenerMap.get(listener);
|
|
1681
|
+
if (isUndefined(shadowRootWrappedListener)) {
|
|
1682
|
+
shadowRootWrappedListener = function (event) {
|
|
1683
|
+
// currentTarget is always defined inside an event listener
|
|
1684
|
+
let currentTarget = eventCurrentTargetGetter.call(event);
|
|
1685
|
+
// If currentTarget is not an instance of a native shadow root then we're dealing with a
|
|
1686
|
+
// host element whose synthetic shadow root must be accessed via getShadowRoot().
|
|
1687
|
+
if (!isInstanceOfNativeShadowRoot(currentTarget)) {
|
|
1688
|
+
currentTarget = getShadowRoot(currentTarget);
|
|
1689
|
+
}
|
|
1690
|
+
const actualTarget = getActualTarget(event);
|
|
1691
|
+
if (shouldInvokeListener(event, actualTarget, currentTarget)) {
|
|
1692
|
+
listener.call(currentTarget, event);
|
|
1693
|
+
}
|
|
1694
|
+
};
|
|
1695
|
+
shadowRootWrappedListener.placement = 1 /* SHADOW_ROOT_LISTENER */;
|
|
1696
|
+
shadowRootEventListenerMap.set(listener, shadowRootWrappedListener);
|
|
1697
|
+
}
|
|
1698
|
+
return shadowRootWrappedListener;
|
|
1699
|
+
}
|
|
1700
|
+
const customElementEventListenerMap = new WeakMap();
|
|
1701
|
+
function getWrappedCustomElementListener(listener) {
|
|
1702
|
+
if (!isFunction(listener)) {
|
|
1703
|
+
throw new TypeError(); // avoiding problems with non-valid listeners
|
|
1704
|
+
}
|
|
1705
|
+
let customElementWrappedListener = customElementEventListenerMap.get(listener);
|
|
1706
|
+
if (isUndefined(customElementWrappedListener)) {
|
|
1707
|
+
customElementWrappedListener = function (event) {
|
|
1708
|
+
// currentTarget is always defined inside an event listener
|
|
1709
|
+
const currentTarget = eventCurrentTargetGetter.call(event);
|
|
1710
|
+
const actualTarget = getActualTarget(event);
|
|
1711
|
+
if (shouldInvokeListener(event, actualTarget, currentTarget)) {
|
|
1712
|
+
listener.call(currentTarget, event);
|
|
1713
|
+
}
|
|
1714
|
+
};
|
|
1715
|
+
customElementWrappedListener.placement = 0 /* CUSTOM_ELEMENT_LISTENER */;
|
|
1716
|
+
customElementEventListenerMap.set(listener, customElementWrappedListener);
|
|
1717
|
+
}
|
|
1718
|
+
return customElementWrappedListener;
|
|
1719
|
+
}
|
|
1720
|
+
function domListener(evt) {
|
|
1721
|
+
let immediatePropagationStopped = false;
|
|
1722
|
+
let propagationStopped = false;
|
|
1723
|
+
const { type, stopImmediatePropagation, stopPropagation } = evt;
|
|
1724
|
+
// currentTarget is always defined
|
|
1725
|
+
const currentTarget = eventCurrentTargetGetter.call(evt);
|
|
1726
|
+
const listenerMap = getEventMap(currentTarget);
|
|
1727
|
+
const listeners = listenerMap[type]; // it must have listeners at this point
|
|
1728
|
+
defineProperty(evt, 'stopImmediatePropagation', {
|
|
1729
|
+
value() {
|
|
1730
|
+
immediatePropagationStopped = true;
|
|
1731
|
+
stopImmediatePropagation.call(evt);
|
|
1732
|
+
},
|
|
1733
|
+
writable: true,
|
|
1734
|
+
enumerable: true,
|
|
1735
|
+
configurable: true,
|
|
1736
|
+
});
|
|
1737
|
+
defineProperty(evt, 'stopPropagation', {
|
|
1738
|
+
value() {
|
|
1739
|
+
propagationStopped = true;
|
|
1740
|
+
stopPropagation.call(evt);
|
|
1741
|
+
},
|
|
1742
|
+
writable: true,
|
|
1743
|
+
enumerable: true,
|
|
1744
|
+
configurable: true,
|
|
1745
|
+
});
|
|
1746
|
+
// in case a listener adds or removes other listeners during invocation
|
|
1747
|
+
const bookkeeping = ArraySlice.call(listeners);
|
|
1748
|
+
function invokeListenersByPlacement(placement) {
|
|
1749
|
+
forEach.call(bookkeeping, (listener) => {
|
|
1750
|
+
if (isFalse(immediatePropagationStopped) && listener.placement === placement) {
|
|
1751
|
+
// making sure that the listener was not removed from the original listener queue
|
|
1752
|
+
if (ArrayIndexOf.call(listeners, listener) !== -1) {
|
|
1753
|
+
// all handlers on the custom element should be called with undefined 'this'
|
|
1754
|
+
listener.call(undefined, evt);
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
});
|
|
1758
|
+
}
|
|
1759
|
+
eventToContextMap.set(evt, 1 /* SHADOW_ROOT_LISTENER */);
|
|
1760
|
+
invokeListenersByPlacement(1 /* SHADOW_ROOT_LISTENER */);
|
|
1761
|
+
if (isFalse(immediatePropagationStopped) && isFalse(propagationStopped)) {
|
|
1762
|
+
// doing the second iteration only if the first one didn't interrupt the event propagation
|
|
1763
|
+
eventToContextMap.set(evt, 0 /* CUSTOM_ELEMENT_LISTENER */);
|
|
1764
|
+
invokeListenersByPlacement(0 /* CUSTOM_ELEMENT_LISTENER */);
|
|
1765
|
+
}
|
|
1766
|
+
eventToContextMap.set(evt, 2 /* UNKNOWN_LISTENER */);
|
|
1767
|
+
}
|
|
1768
|
+
function attachDOMListener(elm, type, wrappedListener) {
|
|
1769
|
+
const listenerMap = getEventMap(elm);
|
|
1770
|
+
let cmpEventHandlers = listenerMap[type];
|
|
1771
|
+
if (isUndefined(cmpEventHandlers)) {
|
|
1772
|
+
cmpEventHandlers = listenerMap[type] = [];
|
|
1773
|
+
}
|
|
1774
|
+
// Prevent identical listeners from subscribing to the same event type.
|
|
1775
|
+
// TODO [#1824]: Options will also play a factor when we introduce support for them (#1824).
|
|
1776
|
+
if (ArrayIndexOf.call(cmpEventHandlers, wrappedListener) !== -1) {
|
|
1777
|
+
return;
|
|
1778
|
+
}
|
|
1779
|
+
// only add to DOM if there is no other listener on the same placement yet
|
|
1780
|
+
if (cmpEventHandlers.length === 0) {
|
|
1781
|
+
// super.addEventListener() - this will not work on
|
|
1782
|
+
addEventListener.call(elm, type, domListener);
|
|
1783
|
+
}
|
|
1784
|
+
ArrayPush.call(cmpEventHandlers, wrappedListener);
|
|
1785
|
+
}
|
|
1786
|
+
function detachDOMListener(elm, type, wrappedListener) {
|
|
1787
|
+
const listenerMap = getEventMap(elm);
|
|
1788
|
+
let p;
|
|
1789
|
+
let listeners;
|
|
1790
|
+
if (!isUndefined((listeners = listenerMap[type])) &&
|
|
1791
|
+
(p = ArrayIndexOf.call(listeners, wrappedListener)) !== -1) {
|
|
1792
|
+
ArraySplice.call(listeners, p, 1);
|
|
1793
|
+
// only remove from DOM if there is no other listener on the same placement
|
|
1794
|
+
if (listeners.length === 0) {
|
|
1795
|
+
removeEventListener.call(elm, type, domListener);
|
|
1796
|
+
}
|
|
1797
|
+
}
|
|
1798
|
+
}
|
|
1799
|
+
function addCustomElementEventListener(type, listener, _options) {
|
|
1800
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1801
|
+
if (!isFunction(listener)) {
|
|
1802
|
+
throw new TypeError(`Invalid second argument for Element.addEventListener() in ${toString(this)} for event "${type}". Expected an EventListener but received ${listener}.`);
|
|
1803
|
+
}
|
|
1804
|
+
}
|
|
1805
|
+
// TODO [#1824]: Lift this restriction on the option parameter
|
|
1806
|
+
if (isFunction(listener)) {
|
|
1807
|
+
const wrappedListener = getWrappedCustomElementListener(listener);
|
|
1808
|
+
attachDOMListener(this, type, wrappedListener);
|
|
1789
1809
|
}
|
|
1790
|
-
return rootNodes;
|
|
1791
1810
|
}
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
if (thisRootNode === targetRootNode) {
|
|
1798
|
-
return host;
|
|
1799
|
-
}
|
|
1800
|
-
rootNode = thisRootNode;
|
|
1811
|
+
function removeCustomElementEventListener(type, listener, _options) {
|
|
1812
|
+
// TODO [#1824]: Lift this restriction on the option parameter
|
|
1813
|
+
if (isFunction(listener)) {
|
|
1814
|
+
const wrappedListener = getWrappedCustomElementListener(listener);
|
|
1815
|
+
detachDOMListener(this, type, wrappedListener);
|
|
1801
1816
|
}
|
|
1802
|
-
}
|
|
1803
|
-
function
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
// Filter the elements array to only include those elements that are in this shadow root or in one of its
|
|
1808
|
-
// ancestor roots. This matches Chrome and Safari's implementation (but not Firefox's, which only includes
|
|
1809
|
-
// elements in the immediate shadow root: https://crbug.com/1207863#c4).
|
|
1810
|
-
if (!isNull(elements)) {
|
|
1811
|
-
// can be null in IE https://developer.mozilla.org/en-US/docs/Web/API/Document/elementsFromPoint#browser_compatibility
|
|
1812
|
-
for (let i = 0; i < elements.length; i++) {
|
|
1813
|
-
const element = elements[i];
|
|
1814
|
-
if (isSyntheticSlotElement(element)) {
|
|
1815
|
-
continue;
|
|
1816
|
-
}
|
|
1817
|
-
const elementRootNode = element.getRootNode();
|
|
1818
|
-
if (ArrayIndexOf.call(rootNodes, elementRootNode) !== -1) {
|
|
1819
|
-
ArrayPush.call(result, element);
|
|
1820
|
-
continue;
|
|
1821
|
-
}
|
|
1822
|
-
// In cases where the host element is not visible but its shadow descendants are, then
|
|
1823
|
-
// we may get the shadow descendant instead of the host element here. (The
|
|
1824
|
-
// browser doesn't know the difference in synthetic shadow DOM.)
|
|
1825
|
-
// In native shadow DOM, however, elementsFromPoint would return the host but not
|
|
1826
|
-
// the child. So we need to detect if this shadow element's host is accessible from
|
|
1827
|
-
// the context's shadow root. Note we also need to be careful not to add the host
|
|
1828
|
-
// multiple times.
|
|
1829
|
-
const ancestorHost = findAncestorHostInImmediateShadowRoot(elementRootNode, rootNodes[0]);
|
|
1830
|
-
if (!isUndefined(ancestorHost) &&
|
|
1831
|
-
ArrayIndexOf.call(elements, ancestorHost) === -1 &&
|
|
1832
|
-
ArrayIndexOf.call(result, ancestorHost) === -1) {
|
|
1833
|
-
ArrayPush.call(result, ancestorHost);
|
|
1834
|
-
}
|
|
1817
|
+
}
|
|
1818
|
+
function addShadowRootEventListener(sr, type, listener, _options) {
|
|
1819
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1820
|
+
if (!isFunction(listener)) {
|
|
1821
|
+
throw new TypeError(`Invalid second argument for ShadowRoot.addEventListener() in ${toString(sr)} for event "${type}". Expected an EventListener but received ${listener}.`);
|
|
1835
1822
|
}
|
|
1836
1823
|
}
|
|
1837
|
-
|
|
1824
|
+
// TODO [#1824]: Lift this restriction on the option parameter
|
|
1825
|
+
if (isFunction(listener)) {
|
|
1826
|
+
const elm = getHost(sr);
|
|
1827
|
+
const wrappedListener = getWrappedShadowRootListener(listener);
|
|
1828
|
+
attachDOMListener(elm, type, wrappedListener);
|
|
1829
|
+
}
|
|
1830
|
+
}
|
|
1831
|
+
function removeShadowRootEventListener(sr, type, listener, _options) {
|
|
1832
|
+
// TODO [#1824]: Lift this restriction on the option parameter
|
|
1833
|
+
if (isFunction(listener)) {
|
|
1834
|
+
const elm = getHost(sr);
|
|
1835
|
+
const wrappedListener = getWrappedShadowRootListener(listener);
|
|
1836
|
+
detachDOMListener(elm, type, wrappedListener);
|
|
1837
|
+
}
|
|
1838
1838
|
}
|
|
1839
1839
|
|
|
1840
1840
|
/*
|
|
@@ -4104,41 +4104,230 @@
|
|
|
4104
4104
|
if (!runtimeFlags.ENABLE_HTML_COLLECTIONS_PATCH) {
|
|
4105
4105
|
return createStaticHTMLCollection(getNonPatchedFilteredArrayOfNodes(this, elements));
|
|
4106
4106
|
}
|
|
4107
|
-
|
|
4108
|
-
const filteredResults = getFilteredArrayOfNodes(this, elements, 1
|
|
4109
|
-
/* Enabled */
|
|
4110
|
-
);
|
|
4111
|
-
return createStaticHTMLCollection(filteredResults);
|
|
4112
|
-
},
|
|
4113
|
-
|
|
4114
|
-
writable: true,
|
|
4115
|
-
enumerable: true,
|
|
4116
|
-
configurable: true
|
|
4117
|
-
},
|
|
4118
|
-
getElementsByTagNameNS: {
|
|
4119
|
-
value() {
|
|
4120
|
-
const elements = arrayFromCollection(getElementsByTagNameNS$1.apply(this, ArraySlice.call(arguments)));
|
|
4121
|
-
|
|
4122
|
-
if (!runtimeFlags.ENABLE_HTML_COLLECTIONS_PATCH) {
|
|
4123
|
-
return createStaticHTMLCollection(getNonPatchedFilteredArrayOfNodes(this, elements));
|
|
4107
|
+
|
|
4108
|
+
const filteredResults = getFilteredArrayOfNodes(this, elements, 1
|
|
4109
|
+
/* Enabled */
|
|
4110
|
+
);
|
|
4111
|
+
return createStaticHTMLCollection(filteredResults);
|
|
4112
|
+
},
|
|
4113
|
+
|
|
4114
|
+
writable: true,
|
|
4115
|
+
enumerable: true,
|
|
4116
|
+
configurable: true
|
|
4117
|
+
},
|
|
4118
|
+
getElementsByTagNameNS: {
|
|
4119
|
+
value() {
|
|
4120
|
+
const elements = arrayFromCollection(getElementsByTagNameNS$1.apply(this, ArraySlice.call(arguments)));
|
|
4121
|
+
|
|
4122
|
+
if (!runtimeFlags.ENABLE_HTML_COLLECTIONS_PATCH) {
|
|
4123
|
+
return createStaticHTMLCollection(getNonPatchedFilteredArrayOfNodes(this, elements));
|
|
4124
|
+
}
|
|
4125
|
+
|
|
4126
|
+
const filteredResults = getFilteredArrayOfNodes(this, elements, 1
|
|
4127
|
+
/* Enabled */
|
|
4128
|
+
);
|
|
4129
|
+
return createStaticHTMLCollection(filteredResults);
|
|
4130
|
+
},
|
|
4131
|
+
|
|
4132
|
+
writable: true,
|
|
4133
|
+
enumerable: true,
|
|
4134
|
+
configurable: true
|
|
4135
|
+
}
|
|
4136
|
+
});
|
|
4137
|
+
} // IE11 extra patches for wrong prototypes
|
|
4138
|
+
|
|
4139
|
+
|
|
4140
|
+
if (hasOwnProperty.call(HTMLElement.prototype, 'getElementsByClassName')) {
|
|
4141
|
+
defineProperty(HTMLElement.prototype, 'getElementsByClassName', getOwnPropertyDescriptor(Element.prototype, 'getElementsByClassName'));
|
|
4142
|
+
}
|
|
4143
|
+
|
|
4144
|
+
/*
|
|
4145
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
4146
|
+
* All rights reserved.
|
|
4147
|
+
* SPDX-License-Identifier: MIT
|
|
4148
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
4149
|
+
*/
|
|
4150
|
+
function getElementComputedStyle(element) {
|
|
4151
|
+
const win = getOwnerWindow(element);
|
|
4152
|
+
return windowGetComputedStyle.call(win, element);
|
|
4153
|
+
}
|
|
4154
|
+
function getWindowSelection(node) {
|
|
4155
|
+
const win = getOwnerWindow(node);
|
|
4156
|
+
return windowGetSelection.call(win);
|
|
4157
|
+
}
|
|
4158
|
+
function nodeIsBeingRendered(nodeComputedStyle) {
|
|
4159
|
+
return nodeComputedStyle.visibility === 'visible' && nodeComputedStyle.display !== 'none';
|
|
4160
|
+
}
|
|
4161
|
+
function getSelectionState(element) {
|
|
4162
|
+
const win = getOwnerWindow(element);
|
|
4163
|
+
const selection = getWindowSelection(element);
|
|
4164
|
+
if (selection === null) {
|
|
4165
|
+
return null;
|
|
4166
|
+
}
|
|
4167
|
+
const ranges = [];
|
|
4168
|
+
for (let i = 0; i < selection.rangeCount; i++) {
|
|
4169
|
+
ranges.push(selection.getRangeAt(i));
|
|
4170
|
+
}
|
|
4171
|
+
const state = {
|
|
4172
|
+
element,
|
|
4173
|
+
onselect: win.onselect,
|
|
4174
|
+
onselectstart: win.onselectstart,
|
|
4175
|
+
onselectionchange: win.onselectionchange,
|
|
4176
|
+
ranges,
|
|
4177
|
+
};
|
|
4178
|
+
win.onselect = null;
|
|
4179
|
+
win.onselectstart = null;
|
|
4180
|
+
win.onselectionchange = null;
|
|
4181
|
+
return state;
|
|
4182
|
+
}
|
|
4183
|
+
function restoreSelectionState(state) {
|
|
4184
|
+
if (state === null) {
|
|
4185
|
+
return;
|
|
4186
|
+
}
|
|
4187
|
+
const { element, onselect, onselectstart, onselectionchange, ranges } = state;
|
|
4188
|
+
const win = getOwnerWindow(element);
|
|
4189
|
+
const selection = getWindowSelection(element);
|
|
4190
|
+
selection.removeAllRanges();
|
|
4191
|
+
for (let i = 0; i < ranges.length; i++) {
|
|
4192
|
+
selection.addRange(ranges[i]);
|
|
4193
|
+
}
|
|
4194
|
+
win.onselect = onselect;
|
|
4195
|
+
win.onselectstart = onselectstart;
|
|
4196
|
+
win.onselectionchange = onselectionchange;
|
|
4197
|
+
}
|
|
4198
|
+
/**
|
|
4199
|
+
* Gets the "innerText" of a text node using the Selection API
|
|
4200
|
+
*
|
|
4201
|
+
* NOTE: For performance reasons, since this function will be called multiple times while calculating the innerText of
|
|
4202
|
+
* an element, it does not restore the current selection.
|
|
4203
|
+
*/
|
|
4204
|
+
function getTextNodeInnerText(textNode) {
|
|
4205
|
+
const selection = getWindowSelection(textNode);
|
|
4206
|
+
if (selection === null) {
|
|
4207
|
+
return textNode.textContent || '';
|
|
4208
|
+
}
|
|
4209
|
+
const range = document.createRange();
|
|
4210
|
+
range.selectNodeContents(textNode);
|
|
4211
|
+
const domRect = range.getBoundingClientRect();
|
|
4212
|
+
if (domRect.height <= 0 || domRect.width <= 0) {
|
|
4213
|
+
// the text node is not rendered
|
|
4214
|
+
return '';
|
|
4215
|
+
}
|
|
4216
|
+
// Needed to remove non rendered characters from the text node.
|
|
4217
|
+
selection.removeAllRanges();
|
|
4218
|
+
selection.addRange(range);
|
|
4219
|
+
const selectionText = selection.toString();
|
|
4220
|
+
// The textNode is visible, but it may not be selectable. When the text is not selectable,
|
|
4221
|
+
// textContent is the nearest approximation to innerText.
|
|
4222
|
+
return selectionText ? selectionText : textNode.textContent || '';
|
|
4223
|
+
}
|
|
4224
|
+
const nodeIsElement = (node) => node.nodeType === ELEMENT_NODE;
|
|
4225
|
+
const nodeIsText = (node) => node.nodeType === TEXT_NODE;
|
|
4226
|
+
/**
|
|
4227
|
+
* Spec: https://html.spec.whatwg.org/multipage/dom.html#inner-text-collection-steps
|
|
4228
|
+
* One spec implementation: https://github.com/servo/servo/blob/721271dcd3c20db5ca8cf146e2b5907647afb4d6/components/layout/query.rs#L1132
|
|
4229
|
+
*/
|
|
4230
|
+
function innerTextCollectionSteps(node) {
|
|
4231
|
+
const items = [];
|
|
4232
|
+
if (nodeIsElement(node)) {
|
|
4233
|
+
const { tagName } = node;
|
|
4234
|
+
const computedStyle = getElementComputedStyle(node);
|
|
4235
|
+
if (tagName === 'OPTION') {
|
|
4236
|
+
// For options, is hard to get the "rendered" text, let's use the original getter.
|
|
4237
|
+
return [1, innerTextGetter.call(node), 1];
|
|
4238
|
+
}
|
|
4239
|
+
else if (tagName === 'TEXTAREA') {
|
|
4240
|
+
return [];
|
|
4241
|
+
}
|
|
4242
|
+
else {
|
|
4243
|
+
const childNodes = node.childNodes;
|
|
4244
|
+
for (let i = 0, n = childNodes.length; i < n; i++) {
|
|
4245
|
+
ArrayPush.apply(items, innerTextCollectionSteps(childNodes[i]));
|
|
4246
|
+
}
|
|
4247
|
+
}
|
|
4248
|
+
if (!nodeIsBeingRendered(computedStyle)) {
|
|
4249
|
+
if (tagName === 'SELECT' || tagName === 'DATALIST') {
|
|
4250
|
+
// the select is either: .visibility != 'visible' or .display === hidden, therefore this select should
|
|
4251
|
+
// not display any value.
|
|
4252
|
+
return [];
|
|
4253
|
+
}
|
|
4254
|
+
return items;
|
|
4255
|
+
}
|
|
4256
|
+
if (tagName === 'BR') {
|
|
4257
|
+
items.push('\u{000A}' /* line feed */);
|
|
4258
|
+
}
|
|
4259
|
+
const { display } = computedStyle;
|
|
4260
|
+
if (display === 'table-cell') {
|
|
4261
|
+
// omitting case: and node's CSS box is not the last 'table-cell' box of its enclosing 'table-row' box
|
|
4262
|
+
items.push('\u{0009}' /* tab */);
|
|
4263
|
+
}
|
|
4264
|
+
if (display === 'table-row') {
|
|
4265
|
+
// omitting case: and node's CSS box is not the last 'table-row' box of the nearest ancestor 'table' box
|
|
4266
|
+
items.push('\u{000A}' /* line feed */);
|
|
4267
|
+
}
|
|
4268
|
+
if (tagName === 'P') {
|
|
4269
|
+
items.unshift(2);
|
|
4270
|
+
items.push(2);
|
|
4271
|
+
}
|
|
4272
|
+
if (display === 'block' ||
|
|
4273
|
+
display === 'table-caption' ||
|
|
4274
|
+
display === 'flex' ||
|
|
4275
|
+
display === 'table') {
|
|
4276
|
+
items.unshift(1);
|
|
4277
|
+
items.push(1);
|
|
4278
|
+
}
|
|
4279
|
+
}
|
|
4280
|
+
else if (nodeIsText(node)) {
|
|
4281
|
+
items.push(getTextNodeInnerText(node));
|
|
4282
|
+
}
|
|
4283
|
+
return items;
|
|
4284
|
+
}
|
|
4285
|
+
/**
|
|
4286
|
+
* InnerText getter spec: https://html.spec.whatwg.org/multipage/dom.html#the-innertext-idl-attribute
|
|
4287
|
+
*
|
|
4288
|
+
* One spec implementation: https://github.com/servo/servo/blob/721271dcd3c20db5ca8cf146e2b5907647afb4d6/components/layout/query.rs#L1087
|
|
4289
|
+
*/
|
|
4290
|
+
function getInnerText(element) {
|
|
4291
|
+
const thisComputedStyle = getElementComputedStyle(element);
|
|
4292
|
+
if (!nodeIsBeingRendered(thisComputedStyle)) {
|
|
4293
|
+
return getTextContent(element) || '';
|
|
4294
|
+
}
|
|
4295
|
+
const selectionState = getSelectionState(element);
|
|
4296
|
+
const results = [];
|
|
4297
|
+
const childNodes = element.childNodes;
|
|
4298
|
+
for (let i = 0, n = childNodes.length; i < n; i++) {
|
|
4299
|
+
ArrayPush.apply(results, innerTextCollectionSteps(childNodes[i]));
|
|
4300
|
+
}
|
|
4301
|
+
restoreSelectionState(selectionState);
|
|
4302
|
+
let elementInnerText = '';
|
|
4303
|
+
let maxReqLineBreakCount = 0;
|
|
4304
|
+
for (let i = 0, n = results.length; i < n; i++) {
|
|
4305
|
+
const item = results[i];
|
|
4306
|
+
if (typeof item === 'string') {
|
|
4307
|
+
if (maxReqLineBreakCount > 0) {
|
|
4308
|
+
for (let j = 0; j < maxReqLineBreakCount; j++) {
|
|
4309
|
+
elementInnerText += '\u{000A}';
|
|
4310
|
+
}
|
|
4311
|
+
maxReqLineBreakCount = 0;
|
|
4312
|
+
}
|
|
4313
|
+
if (item.length > 0) {
|
|
4314
|
+
elementInnerText += item;
|
|
4315
|
+
}
|
|
4316
|
+
}
|
|
4317
|
+
else {
|
|
4318
|
+
if (elementInnerText.length == 0) {
|
|
4319
|
+
// Remove required line break count at the start.
|
|
4320
|
+
continue;
|
|
4321
|
+
}
|
|
4322
|
+
// Store the count if it's the max of this run,
|
|
4323
|
+
// but it may be ignored if no text item is found afterwards,
|
|
4324
|
+
// which means that these are consecutive line breaks at the end.
|
|
4325
|
+
if (item > maxReqLineBreakCount) {
|
|
4326
|
+
maxReqLineBreakCount = item;
|
|
4327
|
+
}
|
|
4124
4328
|
}
|
|
4125
|
-
|
|
4126
|
-
const filteredResults = getFilteredArrayOfNodes(this, elements, 1
|
|
4127
|
-
/* Enabled */
|
|
4128
|
-
);
|
|
4129
|
-
return createStaticHTMLCollection(filteredResults);
|
|
4130
|
-
},
|
|
4131
|
-
|
|
4132
|
-
writable: true,
|
|
4133
|
-
enumerable: true,
|
|
4134
|
-
configurable: true
|
|
4135
4329
|
}
|
|
4136
|
-
|
|
4137
|
-
} // IE11 extra patches for wrong prototypes
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
if (hasOwnProperty.call(HTMLElement.prototype, 'getElementsByClassName')) {
|
|
4141
|
-
defineProperty(HTMLElement.prototype, 'getElementsByClassName', getOwnPropertyDescriptor(Element.prototype, 'getElementsByClassName'));
|
|
4330
|
+
return elementInnerText;
|
|
4142
4331
|
}
|
|
4143
4332
|
|
|
4144
4333
|
/*
|
|
@@ -4482,195 +4671,6 @@
|
|
|
4482
4671
|
removeEventListener.call(elm, 'focusin', skipShadowHandler, true);
|
|
4483
4672
|
}
|
|
4484
4673
|
|
|
4485
|
-
/*
|
|
4486
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
4487
|
-
* All rights reserved.
|
|
4488
|
-
* SPDX-License-Identifier: MIT
|
|
4489
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
4490
|
-
*/
|
|
4491
|
-
function getElementComputedStyle(element) {
|
|
4492
|
-
const win = getOwnerWindow(element);
|
|
4493
|
-
return windowGetComputedStyle.call(win, element);
|
|
4494
|
-
}
|
|
4495
|
-
function getWindowSelection(node) {
|
|
4496
|
-
const win = getOwnerWindow(node);
|
|
4497
|
-
return windowGetSelection.call(win);
|
|
4498
|
-
}
|
|
4499
|
-
function nodeIsBeingRendered(nodeComputedStyle) {
|
|
4500
|
-
return nodeComputedStyle.visibility === 'visible' && nodeComputedStyle.display !== 'none';
|
|
4501
|
-
}
|
|
4502
|
-
function getSelectionState(element) {
|
|
4503
|
-
const win = getOwnerWindow(element);
|
|
4504
|
-
const selection = getWindowSelection(element);
|
|
4505
|
-
if (selection === null) {
|
|
4506
|
-
return null;
|
|
4507
|
-
}
|
|
4508
|
-
const ranges = [];
|
|
4509
|
-
for (let i = 0; i < selection.rangeCount; i++) {
|
|
4510
|
-
ranges.push(selection.getRangeAt(i));
|
|
4511
|
-
}
|
|
4512
|
-
const state = {
|
|
4513
|
-
element,
|
|
4514
|
-
onselect: win.onselect,
|
|
4515
|
-
onselectstart: win.onselectstart,
|
|
4516
|
-
onselectionchange: win.onselectionchange,
|
|
4517
|
-
ranges,
|
|
4518
|
-
};
|
|
4519
|
-
win.onselect = null;
|
|
4520
|
-
win.onselectstart = null;
|
|
4521
|
-
win.onselectionchange = null;
|
|
4522
|
-
return state;
|
|
4523
|
-
}
|
|
4524
|
-
function restoreSelectionState(state) {
|
|
4525
|
-
if (state === null) {
|
|
4526
|
-
return;
|
|
4527
|
-
}
|
|
4528
|
-
const { element, onselect, onselectstart, onselectionchange, ranges } = state;
|
|
4529
|
-
const win = getOwnerWindow(element);
|
|
4530
|
-
const selection = getWindowSelection(element);
|
|
4531
|
-
selection.removeAllRanges();
|
|
4532
|
-
for (let i = 0; i < ranges.length; i++) {
|
|
4533
|
-
selection.addRange(ranges[i]);
|
|
4534
|
-
}
|
|
4535
|
-
win.onselect = onselect;
|
|
4536
|
-
win.onselectstart = onselectstart;
|
|
4537
|
-
win.onselectionchange = onselectionchange;
|
|
4538
|
-
}
|
|
4539
|
-
/**
|
|
4540
|
-
* Gets the "innerText" of a text node using the Selection API
|
|
4541
|
-
*
|
|
4542
|
-
* NOTE: For performance reasons, since this function will be called multiple times while calculating the innerText of
|
|
4543
|
-
* an element, it does not restore the current selection.
|
|
4544
|
-
*/
|
|
4545
|
-
function getTextNodeInnerText(textNode) {
|
|
4546
|
-
const selection = getWindowSelection(textNode);
|
|
4547
|
-
if (selection === null) {
|
|
4548
|
-
return textNode.textContent || '';
|
|
4549
|
-
}
|
|
4550
|
-
const range = document.createRange();
|
|
4551
|
-
range.selectNodeContents(textNode);
|
|
4552
|
-
const domRect = range.getBoundingClientRect();
|
|
4553
|
-
if (domRect.height <= 0 || domRect.width <= 0) {
|
|
4554
|
-
// the text node is not rendered
|
|
4555
|
-
return '';
|
|
4556
|
-
}
|
|
4557
|
-
// Needed to remove non rendered characters from the text node.
|
|
4558
|
-
selection.removeAllRanges();
|
|
4559
|
-
selection.addRange(range);
|
|
4560
|
-
const selectionText = selection.toString();
|
|
4561
|
-
// The textNode is visible, but it may not be selectable. When the text is not selectable,
|
|
4562
|
-
// textContent is the nearest approximation to innerText.
|
|
4563
|
-
return selectionText ? selectionText : textNode.textContent || '';
|
|
4564
|
-
}
|
|
4565
|
-
const nodeIsElement = (node) => node.nodeType === ELEMENT_NODE;
|
|
4566
|
-
const nodeIsText = (node) => node.nodeType === TEXT_NODE;
|
|
4567
|
-
/**
|
|
4568
|
-
* Spec: https://html.spec.whatwg.org/multipage/dom.html#inner-text-collection-steps
|
|
4569
|
-
* One spec implementation: https://github.com/servo/servo/blob/721271dcd3c20db5ca8cf146e2b5907647afb4d6/components/layout/query.rs#L1132
|
|
4570
|
-
*/
|
|
4571
|
-
function innerTextCollectionSteps(node) {
|
|
4572
|
-
const items = [];
|
|
4573
|
-
if (nodeIsElement(node)) {
|
|
4574
|
-
const { tagName } = node;
|
|
4575
|
-
const computedStyle = getElementComputedStyle(node);
|
|
4576
|
-
if (tagName === 'OPTION') {
|
|
4577
|
-
// For options, is hard to get the "rendered" text, let's use the original getter.
|
|
4578
|
-
return [1, innerTextGetter.call(node), 1];
|
|
4579
|
-
}
|
|
4580
|
-
else if (tagName === 'TEXTAREA') {
|
|
4581
|
-
return [];
|
|
4582
|
-
}
|
|
4583
|
-
else {
|
|
4584
|
-
const childNodes = node.childNodes;
|
|
4585
|
-
for (let i = 0, n = childNodes.length; i < n; i++) {
|
|
4586
|
-
ArrayPush.apply(items, innerTextCollectionSteps(childNodes[i]));
|
|
4587
|
-
}
|
|
4588
|
-
}
|
|
4589
|
-
if (!nodeIsBeingRendered(computedStyle)) {
|
|
4590
|
-
if (tagName === 'SELECT' || tagName === 'DATALIST') {
|
|
4591
|
-
// the select is either: .visibility != 'visible' or .display === hidden, therefore this select should
|
|
4592
|
-
// not display any value.
|
|
4593
|
-
return [];
|
|
4594
|
-
}
|
|
4595
|
-
return items;
|
|
4596
|
-
}
|
|
4597
|
-
if (tagName === 'BR') {
|
|
4598
|
-
items.push('\u{000A}' /* line feed */);
|
|
4599
|
-
}
|
|
4600
|
-
const { display } = computedStyle;
|
|
4601
|
-
if (display === 'table-cell') {
|
|
4602
|
-
// omitting case: and node's CSS box is not the last 'table-cell' box of its enclosing 'table-row' box
|
|
4603
|
-
items.push('\u{0009}' /* tab */);
|
|
4604
|
-
}
|
|
4605
|
-
if (display === 'table-row') {
|
|
4606
|
-
// omitting case: and node's CSS box is not the last 'table-row' box of the nearest ancestor 'table' box
|
|
4607
|
-
items.push('\u{000A}' /* line feed */);
|
|
4608
|
-
}
|
|
4609
|
-
if (tagName === 'P') {
|
|
4610
|
-
items.unshift(2);
|
|
4611
|
-
items.push(2);
|
|
4612
|
-
}
|
|
4613
|
-
if (display === 'block' ||
|
|
4614
|
-
display === 'table-caption' ||
|
|
4615
|
-
display === 'flex' ||
|
|
4616
|
-
display === 'table') {
|
|
4617
|
-
items.unshift(1);
|
|
4618
|
-
items.push(1);
|
|
4619
|
-
}
|
|
4620
|
-
}
|
|
4621
|
-
else if (nodeIsText(node)) {
|
|
4622
|
-
items.push(getTextNodeInnerText(node));
|
|
4623
|
-
}
|
|
4624
|
-
return items;
|
|
4625
|
-
}
|
|
4626
|
-
/**
|
|
4627
|
-
* InnerText getter spec: https://html.spec.whatwg.org/multipage/dom.html#the-innertext-idl-attribute
|
|
4628
|
-
*
|
|
4629
|
-
* One spec implementation: https://github.com/servo/servo/blob/721271dcd3c20db5ca8cf146e2b5907647afb4d6/components/layout/query.rs#L1087
|
|
4630
|
-
*/
|
|
4631
|
-
function getInnerText(element) {
|
|
4632
|
-
const thisComputedStyle = getElementComputedStyle(element);
|
|
4633
|
-
if (!nodeIsBeingRendered(thisComputedStyle)) {
|
|
4634
|
-
return getTextContent(element) || '';
|
|
4635
|
-
}
|
|
4636
|
-
const selectionState = getSelectionState(element);
|
|
4637
|
-
const results = [];
|
|
4638
|
-
const childNodes = element.childNodes;
|
|
4639
|
-
for (let i = 0, n = childNodes.length; i < n; i++) {
|
|
4640
|
-
ArrayPush.apply(results, innerTextCollectionSteps(childNodes[i]));
|
|
4641
|
-
}
|
|
4642
|
-
restoreSelectionState(selectionState);
|
|
4643
|
-
let elementInnerText = '';
|
|
4644
|
-
let maxReqLineBreakCount = 0;
|
|
4645
|
-
for (let i = 0, n = results.length; i < n; i++) {
|
|
4646
|
-
const item = results[i];
|
|
4647
|
-
if (typeof item === 'string') {
|
|
4648
|
-
if (maxReqLineBreakCount > 0) {
|
|
4649
|
-
for (let j = 0; j < maxReqLineBreakCount; j++) {
|
|
4650
|
-
elementInnerText += '\u{000A}';
|
|
4651
|
-
}
|
|
4652
|
-
maxReqLineBreakCount = 0;
|
|
4653
|
-
}
|
|
4654
|
-
if (item.length > 0) {
|
|
4655
|
-
elementInnerText += item;
|
|
4656
|
-
}
|
|
4657
|
-
}
|
|
4658
|
-
else {
|
|
4659
|
-
if (elementInnerText.length == 0) {
|
|
4660
|
-
// Remove required line break count at the start.
|
|
4661
|
-
continue;
|
|
4662
|
-
}
|
|
4663
|
-
// Store the count if it's the max of this run,
|
|
4664
|
-
// but it may be ignored if no text item is found afterwards,
|
|
4665
|
-
// which means that these are consecutive line breaks at the end.
|
|
4666
|
-
if (item > maxReqLineBreakCount) {
|
|
4667
|
-
maxReqLineBreakCount = item;
|
|
4668
|
-
}
|
|
4669
|
-
}
|
|
4670
|
-
}
|
|
4671
|
-
return elementInnerText;
|
|
4672
|
-
}
|
|
4673
|
-
|
|
4674
4674
|
/*
|
|
4675
4675
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
4676
4676
|
* All rights reserved.
|
|
@@ -5071,6 +5071,6 @@
|
|
|
5071
5071
|
},
|
|
5072
5072
|
configurable: true,
|
|
5073
5073
|
});
|
|
5074
|
-
/** version: 2.13.
|
|
5074
|
+
/** version: 2.13.1 */
|
|
5075
5075
|
|
|
5076
5076
|
}));
|