lwc 2.12.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 -95
- package/dist/engine-dom/iife/es2017/engine-dom.js +88 -95
- package/dist/engine-dom/iife/es2017/engine-dom.min.js +2 -1
- package/dist/engine-dom/iife/es2017/engine-dom_debug.js +76 -83
- package/dist/engine-dom/iife/es5/engine-dom.js +5761 -7323
- package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es5/engine-dom_debug.js +4567 -5868
- package/dist/engine-dom/umd/es2017/engine-dom.js +88 -95
- package/dist/engine-dom/umd/es2017/engine-dom.min.js +2 -1
- package/dist/engine-dom/umd/es2017/engine-dom_debug.js +76 -83
- package/dist/engine-dom/umd/es5/engine-dom.js +5761 -7323
- package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es5/engine-dom_debug.js +4567 -5868
- package/dist/engine-server/commonjs/es2017/engine-server.js +88 -95
- package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
- package/dist/engine-server/esm/es2017/engine-server.js +88 -95
- 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 +13 -10
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +681 -681
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +3725 -4699
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow.min.js +1 -10
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +3600 -4543
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +693 -693
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.min.js +13 -10
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +681 -681
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +3725 -4699
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow.min.js +1 -10
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +3600 -4543
- 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.min.js +1 -1
- package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
- package/dist/wire-service/iife/es5/wire-service.js +258 -243
- package/dist/wire-service/iife/es5/wire-service.min.js +1 -1
- package/dist/wire-service/iife/es5/wire-service_debug.js +258 -243
- package/dist/wire-service/umd/es2017/wire-service.js +2 -2
- package/dist/wire-service/umd/es2017/wire-service.min.js +1 -1
- package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
- package/dist/wire-service/umd/es5/wire-service.js +258 -243
- package/dist/wire-service/umd/es5/wire-service.min.js +1 -1
- package/dist/wire-service/umd/es5/wire-service_debug.js +258 -243
- package/package.json +7 -7
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
const KEY__SHADOW_TOKEN = '$shadowToken$';
|
|
86
86
|
const KEY__SHADOW_TOKEN_PRIVATE = '$$ShadowTokenKey$$';
|
|
87
87
|
const KEY__SYNTHETIC_MODE = '$$lwc-synthetic-mode';
|
|
88
|
-
/** version: 2.
|
|
88
|
+
/** version: 2.13.1 */
|
|
89
89
|
|
|
90
90
|
/*
|
|
91
91
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -392,236 +392,6 @@
|
|
|
392
392
|
const eventTargetPrototype = typeof EventTarget !== 'undefined' ? EventTarget.prototype : _Node.prototype;
|
|
393
393
|
const { addEventListener, dispatchEvent, removeEventListener } = eventTargetPrototype;
|
|
394
394
|
|
|
395
|
-
/*
|
|
396
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
397
|
-
* All rights reserved.
|
|
398
|
-
* SPDX-License-Identifier: MIT
|
|
399
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
400
|
-
*/
|
|
401
|
-
const EventListenerMap = new WeakMap();
|
|
402
|
-
const ComposedPathMap = new WeakMap();
|
|
403
|
-
function isEventListenerOrEventListenerObject(fnOrObj) {
|
|
404
|
-
return (isFunction(fnOrObj) ||
|
|
405
|
-
(isObject(fnOrObj) &&
|
|
406
|
-
!isNull(fnOrObj) &&
|
|
407
|
-
isFunction(fnOrObj.handleEvent)));
|
|
408
|
-
}
|
|
409
|
-
function shouldInvokeListener(event, target, currentTarget) {
|
|
410
|
-
// Subsequent logic assumes that `currentTarget` must be contained in the composed path for the listener to be
|
|
411
|
-
// invoked, but this is not always the case. `composedPath()` will sometimes return an empty array, even when the
|
|
412
|
-
// listener should be invoked (e.g., a disconnected instance of EventTarget, an instance of XMLHttpRequest, etc).
|
|
413
|
-
if (target === currentTarget) {
|
|
414
|
-
return true;
|
|
415
|
-
}
|
|
416
|
-
let composedPath = ComposedPathMap.get(event);
|
|
417
|
-
if (isUndefined(composedPath)) {
|
|
418
|
-
composedPath = event.composedPath();
|
|
419
|
-
ComposedPathMap.set(event, composedPath);
|
|
420
|
-
}
|
|
421
|
-
return composedPath.includes(currentTarget);
|
|
422
|
-
}
|
|
423
|
-
function getEventListenerWrapper(fnOrObj) {
|
|
424
|
-
if (!isEventListenerOrEventListenerObject(fnOrObj)) {
|
|
425
|
-
return fnOrObj;
|
|
426
|
-
}
|
|
427
|
-
let wrapperFn = EventListenerMap.get(fnOrObj);
|
|
428
|
-
if (isUndefined(wrapperFn)) {
|
|
429
|
-
wrapperFn = function (event) {
|
|
430
|
-
// This function is invoked from an event listener and currentTarget is always defined.
|
|
431
|
-
const currentTarget = eventCurrentTargetGetter.call(event);
|
|
432
|
-
const actualTarget = getActualTarget(event);
|
|
433
|
-
if (!shouldInvokeListener(event, actualTarget, currentTarget)) {
|
|
434
|
-
return;
|
|
435
|
-
}
|
|
436
|
-
return isFunction(fnOrObj)
|
|
437
|
-
? fnOrObj.call(this, event)
|
|
438
|
-
: fnOrObj.handleEvent && fnOrObj.handleEvent(event);
|
|
439
|
-
};
|
|
440
|
-
EventListenerMap.set(fnOrObj, wrapperFn);
|
|
441
|
-
}
|
|
442
|
-
return wrapperFn;
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
/*
|
|
446
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
447
|
-
* All rights reserved.
|
|
448
|
-
* SPDX-License-Identifier: MIT
|
|
449
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
450
|
-
*/
|
|
451
|
-
const eventToContextMap = new WeakMap();
|
|
452
|
-
const customElementToWrappedListeners = new WeakMap();
|
|
453
|
-
function getEventMap(elm) {
|
|
454
|
-
let listenerInfo = customElementToWrappedListeners.get(elm);
|
|
455
|
-
if (isUndefined(listenerInfo)) {
|
|
456
|
-
listenerInfo = create(null);
|
|
457
|
-
customElementToWrappedListeners.set(elm, listenerInfo);
|
|
458
|
-
}
|
|
459
|
-
return listenerInfo;
|
|
460
|
-
}
|
|
461
|
-
/**
|
|
462
|
-
* Events dispatched on shadow roots actually end up being dispatched on their hosts. This means that the event.target
|
|
463
|
-
* property of events dispatched on shadow roots always resolve to their host. This function understands this
|
|
464
|
-
* abstraction and properly returns a reference to the shadow root when appropriate.
|
|
465
|
-
*/
|
|
466
|
-
function getActualTarget(event) {
|
|
467
|
-
var _a;
|
|
468
|
-
return (_a = eventToShadowRootMap.get(event)) !== null && _a !== void 0 ? _a : eventTargetGetter.call(event);
|
|
469
|
-
}
|
|
470
|
-
const shadowRootEventListenerMap = new WeakMap();
|
|
471
|
-
function getWrappedShadowRootListener(listener) {
|
|
472
|
-
if (!isFunction(listener)) {
|
|
473
|
-
throw new TypeError(); // avoiding problems with non-valid listeners
|
|
474
|
-
}
|
|
475
|
-
let shadowRootWrappedListener = shadowRootEventListenerMap.get(listener);
|
|
476
|
-
if (isUndefined(shadowRootWrappedListener)) {
|
|
477
|
-
shadowRootWrappedListener = function (event) {
|
|
478
|
-
// currentTarget is always defined inside an event listener
|
|
479
|
-
let currentTarget = eventCurrentTargetGetter.call(event);
|
|
480
|
-
// If currentTarget is not an instance of a native shadow root then we're dealing with a
|
|
481
|
-
// host element whose synthetic shadow root must be accessed via getShadowRoot().
|
|
482
|
-
if (!isInstanceOfNativeShadowRoot(currentTarget)) {
|
|
483
|
-
currentTarget = getShadowRoot(currentTarget);
|
|
484
|
-
}
|
|
485
|
-
const actualTarget = getActualTarget(event);
|
|
486
|
-
if (shouldInvokeListener(event, actualTarget, currentTarget)) {
|
|
487
|
-
listener.call(currentTarget, event);
|
|
488
|
-
}
|
|
489
|
-
};
|
|
490
|
-
shadowRootWrappedListener.placement = 1 /* SHADOW_ROOT_LISTENER */;
|
|
491
|
-
shadowRootEventListenerMap.set(listener, shadowRootWrappedListener);
|
|
492
|
-
}
|
|
493
|
-
return shadowRootWrappedListener;
|
|
494
|
-
}
|
|
495
|
-
const customElementEventListenerMap = new WeakMap();
|
|
496
|
-
function getWrappedCustomElementListener(listener) {
|
|
497
|
-
if (!isFunction(listener)) {
|
|
498
|
-
throw new TypeError(); // avoiding problems with non-valid listeners
|
|
499
|
-
}
|
|
500
|
-
let customElementWrappedListener = customElementEventListenerMap.get(listener);
|
|
501
|
-
if (isUndefined(customElementWrappedListener)) {
|
|
502
|
-
customElementWrappedListener = function (event) {
|
|
503
|
-
// currentTarget is always defined inside an event listener
|
|
504
|
-
const currentTarget = eventCurrentTargetGetter.call(event);
|
|
505
|
-
const actualTarget = getActualTarget(event);
|
|
506
|
-
if (shouldInvokeListener(event, actualTarget, currentTarget)) {
|
|
507
|
-
listener.call(currentTarget, event);
|
|
508
|
-
}
|
|
509
|
-
};
|
|
510
|
-
customElementWrappedListener.placement = 0 /* CUSTOM_ELEMENT_LISTENER */;
|
|
511
|
-
customElementEventListenerMap.set(listener, customElementWrappedListener);
|
|
512
|
-
}
|
|
513
|
-
return customElementWrappedListener;
|
|
514
|
-
}
|
|
515
|
-
function domListener(evt) {
|
|
516
|
-
let immediatePropagationStopped = false;
|
|
517
|
-
let propagationStopped = false;
|
|
518
|
-
const { type, stopImmediatePropagation, stopPropagation } = evt;
|
|
519
|
-
// currentTarget is always defined
|
|
520
|
-
const currentTarget = eventCurrentTargetGetter.call(evt);
|
|
521
|
-
const listenerMap = getEventMap(currentTarget);
|
|
522
|
-
const listeners = listenerMap[type]; // it must have listeners at this point
|
|
523
|
-
defineProperty(evt, 'stopImmediatePropagation', {
|
|
524
|
-
value() {
|
|
525
|
-
immediatePropagationStopped = true;
|
|
526
|
-
stopImmediatePropagation.call(evt);
|
|
527
|
-
},
|
|
528
|
-
writable: true,
|
|
529
|
-
enumerable: true,
|
|
530
|
-
configurable: true,
|
|
531
|
-
});
|
|
532
|
-
defineProperty(evt, 'stopPropagation', {
|
|
533
|
-
value() {
|
|
534
|
-
propagationStopped = true;
|
|
535
|
-
stopPropagation.call(evt);
|
|
536
|
-
},
|
|
537
|
-
writable: true,
|
|
538
|
-
enumerable: true,
|
|
539
|
-
configurable: true,
|
|
540
|
-
});
|
|
541
|
-
// in case a listener adds or removes other listeners during invocation
|
|
542
|
-
const bookkeeping = ArraySlice.call(listeners);
|
|
543
|
-
function invokeListenersByPlacement(placement) {
|
|
544
|
-
forEach.call(bookkeeping, (listener) => {
|
|
545
|
-
if (isFalse(immediatePropagationStopped) && listener.placement === placement) {
|
|
546
|
-
// making sure that the listener was not removed from the original listener queue
|
|
547
|
-
if (ArrayIndexOf.call(listeners, listener) !== -1) {
|
|
548
|
-
// all handlers on the custom element should be called with undefined 'this'
|
|
549
|
-
listener.call(undefined, evt);
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
});
|
|
553
|
-
}
|
|
554
|
-
eventToContextMap.set(evt, 1 /* SHADOW_ROOT_LISTENER */);
|
|
555
|
-
invokeListenersByPlacement(1 /* SHADOW_ROOT_LISTENER */);
|
|
556
|
-
if (isFalse(immediatePropagationStopped) && isFalse(propagationStopped)) {
|
|
557
|
-
// doing the second iteration only if the first one didn't interrupt the event propagation
|
|
558
|
-
eventToContextMap.set(evt, 0 /* CUSTOM_ELEMENT_LISTENER */);
|
|
559
|
-
invokeListenersByPlacement(0 /* CUSTOM_ELEMENT_LISTENER */);
|
|
560
|
-
}
|
|
561
|
-
eventToContextMap.set(evt, 2 /* UNKNOWN_LISTENER */);
|
|
562
|
-
}
|
|
563
|
-
function attachDOMListener(elm, type, wrappedListener) {
|
|
564
|
-
const listenerMap = getEventMap(elm);
|
|
565
|
-
let cmpEventHandlers = listenerMap[type];
|
|
566
|
-
if (isUndefined(cmpEventHandlers)) {
|
|
567
|
-
cmpEventHandlers = listenerMap[type] = [];
|
|
568
|
-
}
|
|
569
|
-
// Prevent identical listeners from subscribing to the same event type.
|
|
570
|
-
// TODO [#1824]: Options will also play a factor when we introduce support for them (#1824).
|
|
571
|
-
if (ArrayIndexOf.call(cmpEventHandlers, wrappedListener) !== -1) {
|
|
572
|
-
return;
|
|
573
|
-
}
|
|
574
|
-
// only add to DOM if there is no other listener on the same placement yet
|
|
575
|
-
if (cmpEventHandlers.length === 0) {
|
|
576
|
-
// super.addEventListener() - this will not work on
|
|
577
|
-
addEventListener.call(elm, type, domListener);
|
|
578
|
-
}
|
|
579
|
-
ArrayPush.call(cmpEventHandlers, wrappedListener);
|
|
580
|
-
}
|
|
581
|
-
function detachDOMListener(elm, type, wrappedListener) {
|
|
582
|
-
const listenerMap = getEventMap(elm);
|
|
583
|
-
let p;
|
|
584
|
-
let listeners;
|
|
585
|
-
if (!isUndefined((listeners = listenerMap[type])) &&
|
|
586
|
-
(p = ArrayIndexOf.call(listeners, wrappedListener)) !== -1) {
|
|
587
|
-
ArraySplice.call(listeners, p, 1);
|
|
588
|
-
// only remove from DOM if there is no other listener on the same placement
|
|
589
|
-
if (listeners.length === 0) {
|
|
590
|
-
removeEventListener.call(elm, type, domListener);
|
|
591
|
-
}
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
function addCustomElementEventListener(type, listener, _options) {
|
|
595
|
-
// TODO [#1824]: Lift this restriction on the option parameter
|
|
596
|
-
if (isFunction(listener)) {
|
|
597
|
-
const wrappedListener = getWrappedCustomElementListener(listener);
|
|
598
|
-
attachDOMListener(this, type, wrappedListener);
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
function removeCustomElementEventListener(type, listener, _options) {
|
|
602
|
-
// TODO [#1824]: Lift this restriction on the option parameter
|
|
603
|
-
if (isFunction(listener)) {
|
|
604
|
-
const wrappedListener = getWrappedCustomElementListener(listener);
|
|
605
|
-
detachDOMListener(this, type, wrappedListener);
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
function addShadowRootEventListener(sr, type, listener, _options) {
|
|
609
|
-
// TODO [#1824]: Lift this restriction on the option parameter
|
|
610
|
-
if (isFunction(listener)) {
|
|
611
|
-
const elm = getHost(sr);
|
|
612
|
-
const wrappedListener = getWrappedShadowRootListener(listener);
|
|
613
|
-
attachDOMListener(elm, type, wrappedListener);
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
function removeShadowRootEventListener(sr, type, listener, _options) {
|
|
617
|
-
// TODO [#1824]: Lift this restriction on the option parameter
|
|
618
|
-
if (isFunction(listener)) {
|
|
619
|
-
const elm = getHost(sr);
|
|
620
|
-
const wrappedListener = getWrappedShadowRootListener(listener);
|
|
621
|
-
detachDOMListener(elm, type, wrappedListener);
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
|
-
|
|
625
395
|
/*
|
|
626
396
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
627
397
|
* All rights reserved.
|
|
@@ -871,22 +641,13 @@
|
|
|
871
641
|
* SPDX-License-Identifier: MIT
|
|
872
642
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
873
643
|
*/
|
|
874
|
-
function
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
for (let i = 0, len = childNodes.length; i < len; i += 1) {
|
|
880
|
-
const currentNode = childNodes[i];
|
|
881
|
-
if (currentNode.nodeType !== COMMENT_NODE) {
|
|
882
|
-
content += getTextContent(currentNode);
|
|
883
|
-
}
|
|
884
|
-
}
|
|
885
|
-
return content;
|
|
886
|
-
}
|
|
887
|
-
default:
|
|
888
|
-
return node.nodeValue;
|
|
644
|
+
function getInnerHTML(node) {
|
|
645
|
+
let s = '';
|
|
646
|
+
const childNodes = getFilteredChildNodes(node);
|
|
647
|
+
for (let i = 0, len = childNodes.length; i < len; i += 1) {
|
|
648
|
+
s += getOuterHTML(childNodes[i]);
|
|
889
649
|
}
|
|
650
|
+
return s;
|
|
890
651
|
}
|
|
891
652
|
|
|
892
653
|
/*
|
|
@@ -895,11 +656,137 @@
|
|
|
895
656
|
* SPDX-License-Identifier: MIT
|
|
896
657
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
897
658
|
*/
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
}
|
|
902
|
-
|
|
659
|
+
// http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#escapingString
|
|
660
|
+
const escapeAttrRegExp = /[&\u00A0"]/g;
|
|
661
|
+
const escapeDataRegExp = /[&\u00A0<>]/g;
|
|
662
|
+
const { replace, toLowerCase } = String.prototype;
|
|
663
|
+
function escapeReplace(c) {
|
|
664
|
+
switch (c) {
|
|
665
|
+
case '&':
|
|
666
|
+
return '&';
|
|
667
|
+
case '<':
|
|
668
|
+
return '<';
|
|
669
|
+
case '>':
|
|
670
|
+
return '>';
|
|
671
|
+
case '"':
|
|
672
|
+
return '"';
|
|
673
|
+
case '\u00A0':
|
|
674
|
+
return ' ';
|
|
675
|
+
default:
|
|
676
|
+
return '';
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
function escapeAttr(s) {
|
|
680
|
+
return replace.call(s, escapeAttrRegExp, escapeReplace);
|
|
681
|
+
}
|
|
682
|
+
function escapeData(s) {
|
|
683
|
+
return replace.call(s, escapeDataRegExp, escapeReplace);
|
|
684
|
+
}
|
|
685
|
+
// http://www.whatwg.org/specs/web-apps/current-work/#void-elements
|
|
686
|
+
const voidElements = new Set([
|
|
687
|
+
'AREA',
|
|
688
|
+
'BASE',
|
|
689
|
+
'BR',
|
|
690
|
+
'COL',
|
|
691
|
+
'COMMAND',
|
|
692
|
+
'EMBED',
|
|
693
|
+
'HR',
|
|
694
|
+
'IMG',
|
|
695
|
+
'INPUT',
|
|
696
|
+
'KEYGEN',
|
|
697
|
+
'LINK',
|
|
698
|
+
'META',
|
|
699
|
+
'PARAM',
|
|
700
|
+
'SOURCE',
|
|
701
|
+
'TRACK',
|
|
702
|
+
'WBR',
|
|
703
|
+
]);
|
|
704
|
+
const plaintextParents = new Set([
|
|
705
|
+
'STYLE',
|
|
706
|
+
'SCRIPT',
|
|
707
|
+
'XMP',
|
|
708
|
+
'IFRAME',
|
|
709
|
+
'NOEMBED',
|
|
710
|
+
'NOFRAMES',
|
|
711
|
+
'PLAINTEXT',
|
|
712
|
+
'NOSCRIPT',
|
|
713
|
+
]);
|
|
714
|
+
function getOuterHTML(node) {
|
|
715
|
+
switch (node.nodeType) {
|
|
716
|
+
case ELEMENT_NODE: {
|
|
717
|
+
const { attributes: attrs } = node;
|
|
718
|
+
const tagName = tagNameGetter.call(node);
|
|
719
|
+
let s = '<' + toLowerCase.call(tagName);
|
|
720
|
+
for (let i = 0, attr; (attr = attrs[i]); i++) {
|
|
721
|
+
s += ' ' + attr.name + '="' + escapeAttr(attr.value) + '"';
|
|
722
|
+
}
|
|
723
|
+
s += '>';
|
|
724
|
+
if (voidElements.has(tagName)) {
|
|
725
|
+
return s;
|
|
726
|
+
}
|
|
727
|
+
return s + getInnerHTML(node) + '</' + toLowerCase.call(tagName) + '>';
|
|
728
|
+
}
|
|
729
|
+
case TEXT_NODE: {
|
|
730
|
+
const { data, parentNode } = node;
|
|
731
|
+
if (parentNode instanceof Element &&
|
|
732
|
+
plaintextParents.has(tagNameGetter.call(parentNode))) {
|
|
733
|
+
return data;
|
|
734
|
+
}
|
|
735
|
+
return escapeData(data);
|
|
736
|
+
}
|
|
737
|
+
case CDATA_SECTION_NODE: {
|
|
738
|
+
return `<!CDATA[[${node.data}]]>`;
|
|
739
|
+
}
|
|
740
|
+
case PROCESSING_INSTRUCTION_NODE: {
|
|
741
|
+
return `<?${node.target} ${node.data}?>`;
|
|
742
|
+
}
|
|
743
|
+
case COMMENT_NODE: {
|
|
744
|
+
return `<!--${node.data}-->`;
|
|
745
|
+
}
|
|
746
|
+
default: {
|
|
747
|
+
// intentionally ignoring unknown node types
|
|
748
|
+
// Note: since this routine is always invoked for childNodes
|
|
749
|
+
// we can safety ignore type 9, 10 and 99 (document, fragment and doctype)
|
|
750
|
+
return '';
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
/*
|
|
756
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
757
|
+
* All rights reserved.
|
|
758
|
+
* SPDX-License-Identifier: MIT
|
|
759
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
760
|
+
*/
|
|
761
|
+
function getTextContent(node) {
|
|
762
|
+
switch (node.nodeType) {
|
|
763
|
+
case ELEMENT_NODE: {
|
|
764
|
+
const childNodes = getFilteredChildNodes(node);
|
|
765
|
+
let content = '';
|
|
766
|
+
for (let i = 0, len = childNodes.length; i < len; i += 1) {
|
|
767
|
+
const currentNode = childNodes[i];
|
|
768
|
+
if (currentNode.nodeType !== COMMENT_NODE) {
|
|
769
|
+
content += getTextContent(currentNode);
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
return content;
|
|
773
|
+
}
|
|
774
|
+
default:
|
|
775
|
+
return node.nodeValue;
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
/*
|
|
780
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
781
|
+
* All rights reserved.
|
|
782
|
+
* SPDX-License-Identifier: MIT
|
|
783
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
784
|
+
*/
|
|
785
|
+
const Items$1 = new WeakMap();
|
|
786
|
+
function StaticNodeList() {
|
|
787
|
+
throw new TypeError('Illegal constructor');
|
|
788
|
+
}
|
|
789
|
+
StaticNodeList.prototype = create(NodeList.prototype, {
|
|
903
790
|
constructor: {
|
|
904
791
|
writable: true,
|
|
905
792
|
configurable: true,
|
|
@@ -1005,6 +892,71 @@
|
|
|
1005
892
|
return nodeList;
|
|
1006
893
|
}
|
|
1007
894
|
|
|
895
|
+
/*
|
|
896
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
897
|
+
* All rights reserved.
|
|
898
|
+
* SPDX-License-Identifier: MIT
|
|
899
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
900
|
+
*/
|
|
901
|
+
// Walk up the DOM tree, collecting all shadow roots plus the document root
|
|
902
|
+
function getAllRootNodes(node) {
|
|
903
|
+
var _a;
|
|
904
|
+
const rootNodes = [];
|
|
905
|
+
let currentRootNode = node.getRootNode();
|
|
906
|
+
while (!isUndefined(currentRootNode)) {
|
|
907
|
+
rootNodes.push(currentRootNode);
|
|
908
|
+
currentRootNode = (_a = currentRootNode.host) === null || _a === void 0 ? void 0 : _a.getRootNode();
|
|
909
|
+
}
|
|
910
|
+
return rootNodes;
|
|
911
|
+
}
|
|
912
|
+
// Keep searching up the host tree until we find an element that is within the immediate shadow root
|
|
913
|
+
const findAncestorHostInImmediateShadowRoot = (rootNode, targetRootNode) => {
|
|
914
|
+
let host;
|
|
915
|
+
while (!isUndefined((host = rootNode.host))) {
|
|
916
|
+
const thisRootNode = host.getRootNode();
|
|
917
|
+
if (thisRootNode === targetRootNode) {
|
|
918
|
+
return host;
|
|
919
|
+
}
|
|
920
|
+
rootNode = thisRootNode;
|
|
921
|
+
}
|
|
922
|
+
};
|
|
923
|
+
function fauxElementsFromPoint(context, doc, left, top) {
|
|
924
|
+
const elements = elementsFromPoint.call(doc, left, top);
|
|
925
|
+
const result = [];
|
|
926
|
+
const rootNodes = getAllRootNodes(context);
|
|
927
|
+
// Filter the elements array to only include those elements that are in this shadow root or in one of its
|
|
928
|
+
// ancestor roots. This matches Chrome and Safari's implementation (but not Firefox's, which only includes
|
|
929
|
+
// elements in the immediate shadow root: https://crbug.com/1207863#c4).
|
|
930
|
+
if (!isNull(elements)) {
|
|
931
|
+
// can be null in IE https://developer.mozilla.org/en-US/docs/Web/API/Document/elementsFromPoint#browser_compatibility
|
|
932
|
+
for (let i = 0; i < elements.length; i++) {
|
|
933
|
+
const element = elements[i];
|
|
934
|
+
if (isSyntheticSlotElement(element)) {
|
|
935
|
+
continue;
|
|
936
|
+
}
|
|
937
|
+
const elementRootNode = element.getRootNode();
|
|
938
|
+
if (ArrayIndexOf.call(rootNodes, elementRootNode) !== -1) {
|
|
939
|
+
ArrayPush.call(result, element);
|
|
940
|
+
continue;
|
|
941
|
+
}
|
|
942
|
+
// In cases where the host element is not visible but its shadow descendants are, then
|
|
943
|
+
// we may get the shadow descendant instead of the host element here. (The
|
|
944
|
+
// browser doesn't know the difference in synthetic shadow DOM.)
|
|
945
|
+
// In native shadow DOM, however, elementsFromPoint would return the host but not
|
|
946
|
+
// the child. So we need to detect if this shadow element's host is accessible from
|
|
947
|
+
// the context's shadow root. Note we also need to be careful not to add the host
|
|
948
|
+
// multiple times.
|
|
949
|
+
const ancestorHost = findAncestorHostInImmediateShadowRoot(elementRootNode, rootNodes[0]);
|
|
950
|
+
if (!isUndefined(ancestorHost) &&
|
|
951
|
+
ArrayIndexOf.call(elements, ancestorHost) === -1 &&
|
|
952
|
+
ArrayIndexOf.call(result, ancestorHost) === -1) {
|
|
953
|
+
ArrayPush.call(result, ancestorHost);
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
return result;
|
|
958
|
+
}
|
|
959
|
+
|
|
1008
960
|
/*
|
|
1009
961
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
1010
962
|
* All rights reserved.
|
|
@@ -1048,161 +1000,44 @@
|
|
|
1048
1000
|
const items = Items.get(this);
|
|
1049
1001
|
for (let i = 0, len = items.length; i < len; i++) {
|
|
1050
1002
|
const item = items[len];
|
|
1051
|
-
if (name === getAttribute.call(item, 'id') ||
|
|
1052
|
-
name === getAttribute.call(item, 'name')) {
|
|
1053
|
-
return item;
|
|
1054
|
-
}
|
|
1055
|
-
}
|
|
1056
|
-
return null;
|
|
1057
|
-
},
|
|
1058
|
-
},
|
|
1059
|
-
[Symbol.toStringTag]: {
|
|
1060
|
-
configurable: true,
|
|
1061
|
-
get() {
|
|
1062
|
-
return 'HTMLCollection';
|
|
1063
|
-
},
|
|
1064
|
-
},
|
|
1065
|
-
// IE11 doesn't support Symbol.toStringTag, in which case we
|
|
1066
|
-
// provide the regular toString method.
|
|
1067
|
-
toString: {
|
|
1068
|
-
writable: true,
|
|
1069
|
-
configurable: true,
|
|
1070
|
-
value() {
|
|
1071
|
-
return '[object HTMLCollection]';
|
|
1072
|
-
},
|
|
1073
|
-
},
|
|
1074
|
-
});
|
|
1075
|
-
// prototype inheritance dance
|
|
1076
|
-
setPrototypeOf(StaticHTMLCollection, HTMLCollection);
|
|
1077
|
-
function createStaticHTMLCollection(items) {
|
|
1078
|
-
const collection = create(StaticHTMLCollection.prototype);
|
|
1079
|
-
Items.set(collection, items);
|
|
1080
|
-
// setting static indexes
|
|
1081
|
-
forEach.call(items, (item, index) => {
|
|
1082
|
-
defineProperty(collection, index, {
|
|
1083
|
-
value: item,
|
|
1084
|
-
enumerable: true,
|
|
1085
|
-
configurable: true,
|
|
1086
|
-
});
|
|
1087
|
-
});
|
|
1088
|
-
return collection;
|
|
1089
|
-
}
|
|
1090
|
-
|
|
1091
|
-
/*
|
|
1092
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
1093
|
-
* All rights reserved.
|
|
1094
|
-
* SPDX-License-Identifier: MIT
|
|
1095
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1096
|
-
*/
|
|
1097
|
-
function getInnerHTML(node) {
|
|
1098
|
-
let s = '';
|
|
1099
|
-
const childNodes = getFilteredChildNodes(node);
|
|
1100
|
-
for (let i = 0, len = childNodes.length; i < len; i += 1) {
|
|
1101
|
-
s += getOuterHTML(childNodes[i]);
|
|
1102
|
-
}
|
|
1103
|
-
return s;
|
|
1104
|
-
}
|
|
1105
|
-
|
|
1106
|
-
/*
|
|
1107
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
1108
|
-
* All rights reserved.
|
|
1109
|
-
* SPDX-License-Identifier: MIT
|
|
1110
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1111
|
-
*/
|
|
1112
|
-
// http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#escapingString
|
|
1113
|
-
const escapeAttrRegExp = /[&\u00A0"]/g;
|
|
1114
|
-
const escapeDataRegExp = /[&\u00A0<>]/g;
|
|
1115
|
-
const { replace, toLowerCase } = String.prototype;
|
|
1116
|
-
function escapeReplace(c) {
|
|
1117
|
-
switch (c) {
|
|
1118
|
-
case '&':
|
|
1119
|
-
return '&';
|
|
1120
|
-
case '<':
|
|
1121
|
-
return '<';
|
|
1122
|
-
case '>':
|
|
1123
|
-
return '>';
|
|
1124
|
-
case '"':
|
|
1125
|
-
return '"';
|
|
1126
|
-
case '\u00A0':
|
|
1127
|
-
return ' ';
|
|
1128
|
-
default:
|
|
1129
|
-
return '';
|
|
1130
|
-
}
|
|
1131
|
-
}
|
|
1132
|
-
function escapeAttr(s) {
|
|
1133
|
-
return replace.call(s, escapeAttrRegExp, escapeReplace);
|
|
1134
|
-
}
|
|
1135
|
-
function escapeData(s) {
|
|
1136
|
-
return replace.call(s, escapeDataRegExp, escapeReplace);
|
|
1137
|
-
}
|
|
1138
|
-
// http://www.whatwg.org/specs/web-apps/current-work/#void-elements
|
|
1139
|
-
const voidElements = new Set([
|
|
1140
|
-
'AREA',
|
|
1141
|
-
'BASE',
|
|
1142
|
-
'BR',
|
|
1143
|
-
'COL',
|
|
1144
|
-
'COMMAND',
|
|
1145
|
-
'EMBED',
|
|
1146
|
-
'HR',
|
|
1147
|
-
'IMG',
|
|
1148
|
-
'INPUT',
|
|
1149
|
-
'KEYGEN',
|
|
1150
|
-
'LINK',
|
|
1151
|
-
'META',
|
|
1152
|
-
'PARAM',
|
|
1153
|
-
'SOURCE',
|
|
1154
|
-
'TRACK',
|
|
1155
|
-
'WBR',
|
|
1156
|
-
]);
|
|
1157
|
-
const plaintextParents = new Set([
|
|
1158
|
-
'STYLE',
|
|
1159
|
-
'SCRIPT',
|
|
1160
|
-
'XMP',
|
|
1161
|
-
'IFRAME',
|
|
1162
|
-
'NOEMBED',
|
|
1163
|
-
'NOFRAMES',
|
|
1164
|
-
'PLAINTEXT',
|
|
1165
|
-
'NOSCRIPT',
|
|
1166
|
-
]);
|
|
1167
|
-
function getOuterHTML(node) {
|
|
1168
|
-
switch (node.nodeType) {
|
|
1169
|
-
case ELEMENT_NODE: {
|
|
1170
|
-
const { attributes: attrs } = node;
|
|
1171
|
-
const tagName = tagNameGetter.call(node);
|
|
1172
|
-
let s = '<' + toLowerCase.call(tagName);
|
|
1173
|
-
for (let i = 0, attr; (attr = attrs[i]); i++) {
|
|
1174
|
-
s += ' ' + attr.name + '="' + escapeAttr(attr.value) + '"';
|
|
1175
|
-
}
|
|
1176
|
-
s += '>';
|
|
1177
|
-
if (voidElements.has(tagName)) {
|
|
1178
|
-
return s;
|
|
1179
|
-
}
|
|
1180
|
-
return s + getInnerHTML(node) + '</' + toLowerCase.call(tagName) + '>';
|
|
1181
|
-
}
|
|
1182
|
-
case TEXT_NODE: {
|
|
1183
|
-
const { data, parentNode } = node;
|
|
1184
|
-
if (parentNode instanceof Element &&
|
|
1185
|
-
plaintextParents.has(tagNameGetter.call(parentNode))) {
|
|
1186
|
-
return data;
|
|
1003
|
+
if (name === getAttribute.call(item, 'id') ||
|
|
1004
|
+
name === getAttribute.call(item, 'name')) {
|
|
1005
|
+
return item;
|
|
1006
|
+
}
|
|
1187
1007
|
}
|
|
1188
|
-
return
|
|
1189
|
-
}
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
return
|
|
1195
|
-
}
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
return '';
|
|
1204
|
-
}
|
|
1205
|
-
}
|
|
1008
|
+
return null;
|
|
1009
|
+
},
|
|
1010
|
+
},
|
|
1011
|
+
[Symbol.toStringTag]: {
|
|
1012
|
+
configurable: true,
|
|
1013
|
+
get() {
|
|
1014
|
+
return 'HTMLCollection';
|
|
1015
|
+
},
|
|
1016
|
+
},
|
|
1017
|
+
// IE11 doesn't support Symbol.toStringTag, in which case we
|
|
1018
|
+
// provide the regular toString method.
|
|
1019
|
+
toString: {
|
|
1020
|
+
writable: true,
|
|
1021
|
+
configurable: true,
|
|
1022
|
+
value() {
|
|
1023
|
+
return '[object HTMLCollection]';
|
|
1024
|
+
},
|
|
1025
|
+
},
|
|
1026
|
+
});
|
|
1027
|
+
// prototype inheritance dance
|
|
1028
|
+
setPrototypeOf(StaticHTMLCollection, HTMLCollection);
|
|
1029
|
+
function createStaticHTMLCollection(items) {
|
|
1030
|
+
const collection = create(StaticHTMLCollection.prototype);
|
|
1031
|
+
Items.set(collection, items);
|
|
1032
|
+
// setting static indexes
|
|
1033
|
+
forEach.call(items, (item, index) => {
|
|
1034
|
+
defineProperty(collection, index, {
|
|
1035
|
+
value: item,
|
|
1036
|
+
enumerable: true,
|
|
1037
|
+
configurable: true,
|
|
1038
|
+
});
|
|
1039
|
+
});
|
|
1040
|
+
return collection;
|
|
1206
1041
|
}
|
|
1207
1042
|
|
|
1208
1043
|
/**
|
|
@@ -1212,7 +1047,7 @@
|
|
|
1212
1047
|
Object.defineProperty(_globalThis, 'lwcRuntimeFlags', { value: create(null) });
|
|
1213
1048
|
}
|
|
1214
1049
|
const runtimeFlags = _globalThis.lwcRuntimeFlags;
|
|
1215
|
-
/** version: 2.
|
|
1050
|
+
/** version: 2.13.1 */
|
|
1216
1051
|
|
|
1217
1052
|
/*
|
|
1218
1053
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -1646,63 +1481,228 @@
|
|
|
1646
1481
|
* SPDX-License-Identifier: MIT
|
|
1647
1482
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1648
1483
|
*/
|
|
1649
|
-
|
|
1650
|
-
|
|
1484
|
+
const EventListenerMap = new WeakMap();
|
|
1485
|
+
const ComposedPathMap = new WeakMap();
|
|
1486
|
+
function isEventListenerOrEventListenerObject(fnOrObj) {
|
|
1487
|
+
return (isFunction(fnOrObj) ||
|
|
1488
|
+
(isObject(fnOrObj) &&
|
|
1489
|
+
!isNull(fnOrObj) &&
|
|
1490
|
+
isFunction(fnOrObj.handleEvent)));
|
|
1491
|
+
}
|
|
1492
|
+
function shouldInvokeListener(event, target, currentTarget) {
|
|
1493
|
+
// Subsequent logic assumes that `currentTarget` must be contained in the composed path for the listener to be
|
|
1494
|
+
// invoked, but this is not always the case. `composedPath()` will sometimes return an empty array, even when the
|
|
1495
|
+
// listener should be invoked (e.g., a disconnected instance of EventTarget, an instance of XMLHttpRequest, etc).
|
|
1496
|
+
if (target === currentTarget) {
|
|
1497
|
+
return true;
|
|
1498
|
+
}
|
|
1499
|
+
let composedPath = ComposedPathMap.get(event);
|
|
1500
|
+
if (isUndefined(composedPath)) {
|
|
1501
|
+
composedPath = event.composedPath();
|
|
1502
|
+
ComposedPathMap.set(event, composedPath);
|
|
1503
|
+
}
|
|
1504
|
+
return composedPath.includes(currentTarget);
|
|
1505
|
+
}
|
|
1506
|
+
function getEventListenerWrapper(fnOrObj) {
|
|
1507
|
+
if (!isEventListenerOrEventListenerObject(fnOrObj)) {
|
|
1508
|
+
return fnOrObj;
|
|
1509
|
+
}
|
|
1510
|
+
let wrapperFn = EventListenerMap.get(fnOrObj);
|
|
1511
|
+
if (isUndefined(wrapperFn)) {
|
|
1512
|
+
wrapperFn = function (event) {
|
|
1513
|
+
// This function is invoked from an event listener and currentTarget is always defined.
|
|
1514
|
+
const currentTarget = eventCurrentTargetGetter.call(event);
|
|
1515
|
+
const actualTarget = getActualTarget(event);
|
|
1516
|
+
if (!shouldInvokeListener(event, actualTarget, currentTarget)) {
|
|
1517
|
+
return;
|
|
1518
|
+
}
|
|
1519
|
+
return isFunction(fnOrObj)
|
|
1520
|
+
? fnOrObj.call(this, event)
|
|
1521
|
+
: fnOrObj.handleEvent && fnOrObj.handleEvent(event);
|
|
1522
|
+
};
|
|
1523
|
+
EventListenerMap.set(fnOrObj, wrapperFn);
|
|
1524
|
+
}
|
|
1525
|
+
return wrapperFn;
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
/*
|
|
1529
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
1530
|
+
* All rights reserved.
|
|
1531
|
+
* SPDX-License-Identifier: MIT
|
|
1532
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1533
|
+
*/
|
|
1534
|
+
const eventToContextMap = new WeakMap();
|
|
1535
|
+
const customElementToWrappedListeners = new WeakMap();
|
|
1536
|
+
function getEventMap(elm) {
|
|
1537
|
+
let listenerInfo = customElementToWrappedListeners.get(elm);
|
|
1538
|
+
if (isUndefined(listenerInfo)) {
|
|
1539
|
+
listenerInfo = create(null);
|
|
1540
|
+
customElementToWrappedListeners.set(elm, listenerInfo);
|
|
1541
|
+
}
|
|
1542
|
+
return listenerInfo;
|
|
1543
|
+
}
|
|
1544
|
+
/**
|
|
1545
|
+
* Events dispatched on shadow roots actually end up being dispatched on their hosts. This means that the event.target
|
|
1546
|
+
* property of events dispatched on shadow roots always resolve to their host. This function understands this
|
|
1547
|
+
* abstraction and properly returns a reference to the shadow root when appropriate.
|
|
1548
|
+
*/
|
|
1549
|
+
function getActualTarget(event) {
|
|
1651
1550
|
var _a;
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1551
|
+
return (_a = eventToShadowRootMap.get(event)) !== null && _a !== void 0 ? _a : eventTargetGetter.call(event);
|
|
1552
|
+
}
|
|
1553
|
+
const shadowRootEventListenerMap = new WeakMap();
|
|
1554
|
+
function getWrappedShadowRootListener(listener) {
|
|
1555
|
+
if (!isFunction(listener)) {
|
|
1556
|
+
throw new TypeError(); // avoiding problems with non-valid listeners
|
|
1557
|
+
}
|
|
1558
|
+
let shadowRootWrappedListener = shadowRootEventListenerMap.get(listener);
|
|
1559
|
+
if (isUndefined(shadowRootWrappedListener)) {
|
|
1560
|
+
shadowRootWrappedListener = function (event) {
|
|
1561
|
+
// currentTarget is always defined inside an event listener
|
|
1562
|
+
let currentTarget = eventCurrentTargetGetter.call(event);
|
|
1563
|
+
// If currentTarget is not an instance of a native shadow root then we're dealing with a
|
|
1564
|
+
// host element whose synthetic shadow root must be accessed via getShadowRoot().
|
|
1565
|
+
if (!isInstanceOfNativeShadowRoot(currentTarget)) {
|
|
1566
|
+
currentTarget = getShadowRoot(currentTarget);
|
|
1567
|
+
}
|
|
1568
|
+
const actualTarget = getActualTarget(event);
|
|
1569
|
+
if (shouldInvokeListener(event, actualTarget, currentTarget)) {
|
|
1570
|
+
listener.call(currentTarget, event);
|
|
1571
|
+
}
|
|
1572
|
+
};
|
|
1573
|
+
shadowRootWrappedListener.placement = 1 /* SHADOW_ROOT_LISTENER */;
|
|
1574
|
+
shadowRootEventListenerMap.set(listener, shadowRootWrappedListener);
|
|
1575
|
+
}
|
|
1576
|
+
return shadowRootWrappedListener;
|
|
1577
|
+
}
|
|
1578
|
+
const customElementEventListenerMap = new WeakMap();
|
|
1579
|
+
function getWrappedCustomElementListener(listener) {
|
|
1580
|
+
if (!isFunction(listener)) {
|
|
1581
|
+
throw new TypeError(); // avoiding problems with non-valid listeners
|
|
1582
|
+
}
|
|
1583
|
+
let customElementWrappedListener = customElementEventListenerMap.get(listener);
|
|
1584
|
+
if (isUndefined(customElementWrappedListener)) {
|
|
1585
|
+
customElementWrappedListener = function (event) {
|
|
1586
|
+
// currentTarget is always defined inside an event listener
|
|
1587
|
+
const currentTarget = eventCurrentTargetGetter.call(event);
|
|
1588
|
+
const actualTarget = getActualTarget(event);
|
|
1589
|
+
if (shouldInvokeListener(event, actualTarget, currentTarget)) {
|
|
1590
|
+
listener.call(currentTarget, event);
|
|
1591
|
+
}
|
|
1592
|
+
};
|
|
1593
|
+
customElementWrappedListener.placement = 0 /* CUSTOM_ELEMENT_LISTENER */;
|
|
1594
|
+
customElementEventListenerMap.set(listener, customElementWrappedListener);
|
|
1595
|
+
}
|
|
1596
|
+
return customElementWrappedListener;
|
|
1597
|
+
}
|
|
1598
|
+
function domListener(evt) {
|
|
1599
|
+
let immediatePropagationStopped = false;
|
|
1600
|
+
let propagationStopped = false;
|
|
1601
|
+
const { type, stopImmediatePropagation, stopPropagation } = evt;
|
|
1602
|
+
// currentTarget is always defined
|
|
1603
|
+
const currentTarget = eventCurrentTargetGetter.call(evt);
|
|
1604
|
+
const listenerMap = getEventMap(currentTarget);
|
|
1605
|
+
const listeners = listenerMap[type]; // it must have listeners at this point
|
|
1606
|
+
defineProperty(evt, 'stopImmediatePropagation', {
|
|
1607
|
+
value() {
|
|
1608
|
+
immediatePropagationStopped = true;
|
|
1609
|
+
stopImmediatePropagation.call(evt);
|
|
1610
|
+
},
|
|
1611
|
+
writable: true,
|
|
1612
|
+
enumerable: true,
|
|
1613
|
+
configurable: true,
|
|
1614
|
+
});
|
|
1615
|
+
defineProperty(evt, 'stopPropagation', {
|
|
1616
|
+
value() {
|
|
1617
|
+
propagationStopped = true;
|
|
1618
|
+
stopPropagation.call(evt);
|
|
1619
|
+
},
|
|
1620
|
+
writable: true,
|
|
1621
|
+
enumerable: true,
|
|
1622
|
+
configurable: true,
|
|
1623
|
+
});
|
|
1624
|
+
// in case a listener adds or removes other listeners during invocation
|
|
1625
|
+
const bookkeeping = ArraySlice.call(listeners);
|
|
1626
|
+
function invokeListenersByPlacement(placement) {
|
|
1627
|
+
forEach.call(bookkeeping, (listener) => {
|
|
1628
|
+
if (isFalse(immediatePropagationStopped) && listener.placement === placement) {
|
|
1629
|
+
// making sure that the listener was not removed from the original listener queue
|
|
1630
|
+
if (ArrayIndexOf.call(listeners, listener) !== -1) {
|
|
1631
|
+
// all handlers on the custom element should be called with undefined 'this'
|
|
1632
|
+
listener.call(undefined, evt);
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
});
|
|
1636
|
+
}
|
|
1637
|
+
eventToContextMap.set(evt, 1 /* SHADOW_ROOT_LISTENER */);
|
|
1638
|
+
invokeListenersByPlacement(1 /* SHADOW_ROOT_LISTENER */);
|
|
1639
|
+
if (isFalse(immediatePropagationStopped) && isFalse(propagationStopped)) {
|
|
1640
|
+
// doing the second iteration only if the first one didn't interrupt the event propagation
|
|
1641
|
+
eventToContextMap.set(evt, 0 /* CUSTOM_ELEMENT_LISTENER */);
|
|
1642
|
+
invokeListenersByPlacement(0 /* CUSTOM_ELEMENT_LISTENER */);
|
|
1643
|
+
}
|
|
1644
|
+
eventToContextMap.set(evt, 2 /* UNKNOWN_LISTENER */);
|
|
1645
|
+
}
|
|
1646
|
+
function attachDOMListener(elm, type, wrappedListener) {
|
|
1647
|
+
const listenerMap = getEventMap(elm);
|
|
1648
|
+
let cmpEventHandlers = listenerMap[type];
|
|
1649
|
+
if (isUndefined(cmpEventHandlers)) {
|
|
1650
|
+
cmpEventHandlers = listenerMap[type] = [];
|
|
1651
|
+
}
|
|
1652
|
+
// Prevent identical listeners from subscribing to the same event type.
|
|
1653
|
+
// TODO [#1824]: Options will also play a factor when we introduce support for them (#1824).
|
|
1654
|
+
if (ArrayIndexOf.call(cmpEventHandlers, wrappedListener) !== -1) {
|
|
1655
|
+
return;
|
|
1656
|
+
}
|
|
1657
|
+
// only add to DOM if there is no other listener on the same placement yet
|
|
1658
|
+
if (cmpEventHandlers.length === 0) {
|
|
1659
|
+
// super.addEventListener() - this will not work on
|
|
1660
|
+
addEventListener.call(elm, type, domListener);
|
|
1661
|
+
}
|
|
1662
|
+
ArrayPush.call(cmpEventHandlers, wrappedListener);
|
|
1663
|
+
}
|
|
1664
|
+
function detachDOMListener(elm, type, wrappedListener) {
|
|
1665
|
+
const listenerMap = getEventMap(elm);
|
|
1666
|
+
let p;
|
|
1667
|
+
let listeners;
|
|
1668
|
+
if (!isUndefined((listeners = listenerMap[type])) &&
|
|
1669
|
+
(p = ArrayIndexOf.call(listeners, wrappedListener)) !== -1) {
|
|
1670
|
+
ArraySplice.call(listeners, p, 1);
|
|
1671
|
+
// only remove from DOM if there is no other listener on the same placement
|
|
1672
|
+
if (listeners.length === 0) {
|
|
1673
|
+
removeEventListener.call(elm, type, domListener);
|
|
1674
|
+
}
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1677
|
+
function addCustomElementEventListener(type, listener, _options) {
|
|
1678
|
+
// TODO [#1824]: Lift this restriction on the option parameter
|
|
1679
|
+
if (isFunction(listener)) {
|
|
1680
|
+
const wrappedListener = getWrappedCustomElementListener(listener);
|
|
1681
|
+
attachDOMListener(this, type, wrappedListener);
|
|
1657
1682
|
}
|
|
1658
|
-
return rootNodes;
|
|
1659
1683
|
}
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
if (thisRootNode === targetRootNode) {
|
|
1666
|
-
return host;
|
|
1667
|
-
}
|
|
1668
|
-
rootNode = thisRootNode;
|
|
1684
|
+
function removeCustomElementEventListener(type, listener, _options) {
|
|
1685
|
+
// TODO [#1824]: Lift this restriction on the option parameter
|
|
1686
|
+
if (isFunction(listener)) {
|
|
1687
|
+
const wrappedListener = getWrappedCustomElementListener(listener);
|
|
1688
|
+
detachDOMListener(this, type, wrappedListener);
|
|
1669
1689
|
}
|
|
1670
|
-
}
|
|
1671
|
-
function
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
const elementRootNode = element.getRootNode();
|
|
1686
|
-
if (ArrayIndexOf.call(rootNodes, elementRootNode) !== -1) {
|
|
1687
|
-
ArrayPush.call(result, element);
|
|
1688
|
-
continue;
|
|
1689
|
-
}
|
|
1690
|
-
// In cases where the host element is not visible but its shadow descendants are, then
|
|
1691
|
-
// we may get the shadow descendant instead of the host element here. (The
|
|
1692
|
-
// browser doesn't know the difference in synthetic shadow DOM.)
|
|
1693
|
-
// In native shadow DOM, however, elementsFromPoint would return the host but not
|
|
1694
|
-
// the child. So we need to detect if this shadow element's host is accessible from
|
|
1695
|
-
// the context's shadow root. Note we also need to be careful not to add the host
|
|
1696
|
-
// multiple times.
|
|
1697
|
-
const ancestorHost = findAncestorHostInImmediateShadowRoot(elementRootNode, rootNodes[0]);
|
|
1698
|
-
if (!isUndefined(ancestorHost) &&
|
|
1699
|
-
ArrayIndexOf.call(elements, ancestorHost) === -1 &&
|
|
1700
|
-
ArrayIndexOf.call(result, ancestorHost) === -1) {
|
|
1701
|
-
ArrayPush.call(result, ancestorHost);
|
|
1702
|
-
}
|
|
1703
|
-
}
|
|
1690
|
+
}
|
|
1691
|
+
function addShadowRootEventListener(sr, type, listener, _options) {
|
|
1692
|
+
// TODO [#1824]: Lift this restriction on the option parameter
|
|
1693
|
+
if (isFunction(listener)) {
|
|
1694
|
+
const elm = getHost(sr);
|
|
1695
|
+
const wrappedListener = getWrappedShadowRootListener(listener);
|
|
1696
|
+
attachDOMListener(elm, type, wrappedListener);
|
|
1697
|
+
}
|
|
1698
|
+
}
|
|
1699
|
+
function removeShadowRootEventListener(sr, type, listener, _options) {
|
|
1700
|
+
// TODO [#1824]: Lift this restriction on the option parameter
|
|
1701
|
+
if (isFunction(listener)) {
|
|
1702
|
+
const elm = getHost(sr);
|
|
1703
|
+
const wrappedListener = getWrappedShadowRootListener(listener);
|
|
1704
|
+
detachDOMListener(elm, type, wrappedListener);
|
|
1704
1705
|
}
|
|
1705
|
-
return result;
|
|
1706
1706
|
}
|
|
1707
1707
|
|
|
1708
1708
|
/*
|
|
@@ -3933,41 +3933,230 @@
|
|
|
3933
3933
|
if (!runtimeFlags.ENABLE_HTML_COLLECTIONS_PATCH) {
|
|
3934
3934
|
return createStaticHTMLCollection(getNonPatchedFilteredArrayOfNodes(this, elements));
|
|
3935
3935
|
}
|
|
3936
|
-
|
|
3937
|
-
const filteredResults = getFilteredArrayOfNodes(this, elements, 1
|
|
3938
|
-
/* Enabled */
|
|
3939
|
-
);
|
|
3940
|
-
return createStaticHTMLCollection(filteredResults);
|
|
3941
|
-
},
|
|
3942
|
-
|
|
3943
|
-
writable: true,
|
|
3944
|
-
enumerable: true,
|
|
3945
|
-
configurable: true
|
|
3946
|
-
},
|
|
3947
|
-
getElementsByTagNameNS: {
|
|
3948
|
-
value() {
|
|
3949
|
-
const elements = arrayFromCollection(getElementsByTagNameNS$1.apply(this, ArraySlice.call(arguments)));
|
|
3950
|
-
|
|
3951
|
-
if (!runtimeFlags.ENABLE_HTML_COLLECTIONS_PATCH) {
|
|
3952
|
-
return createStaticHTMLCollection(getNonPatchedFilteredArrayOfNodes(this, elements));
|
|
3936
|
+
|
|
3937
|
+
const filteredResults = getFilteredArrayOfNodes(this, elements, 1
|
|
3938
|
+
/* Enabled */
|
|
3939
|
+
);
|
|
3940
|
+
return createStaticHTMLCollection(filteredResults);
|
|
3941
|
+
},
|
|
3942
|
+
|
|
3943
|
+
writable: true,
|
|
3944
|
+
enumerable: true,
|
|
3945
|
+
configurable: true
|
|
3946
|
+
},
|
|
3947
|
+
getElementsByTagNameNS: {
|
|
3948
|
+
value() {
|
|
3949
|
+
const elements = arrayFromCollection(getElementsByTagNameNS$1.apply(this, ArraySlice.call(arguments)));
|
|
3950
|
+
|
|
3951
|
+
if (!runtimeFlags.ENABLE_HTML_COLLECTIONS_PATCH) {
|
|
3952
|
+
return createStaticHTMLCollection(getNonPatchedFilteredArrayOfNodes(this, elements));
|
|
3953
|
+
}
|
|
3954
|
+
|
|
3955
|
+
const filteredResults = getFilteredArrayOfNodes(this, elements, 1
|
|
3956
|
+
/* Enabled */
|
|
3957
|
+
);
|
|
3958
|
+
return createStaticHTMLCollection(filteredResults);
|
|
3959
|
+
},
|
|
3960
|
+
|
|
3961
|
+
writable: true,
|
|
3962
|
+
enumerable: true,
|
|
3963
|
+
configurable: true
|
|
3964
|
+
}
|
|
3965
|
+
});
|
|
3966
|
+
} // IE11 extra patches for wrong prototypes
|
|
3967
|
+
|
|
3968
|
+
|
|
3969
|
+
if (hasOwnProperty.call(HTMLElement.prototype, 'getElementsByClassName')) {
|
|
3970
|
+
defineProperty(HTMLElement.prototype, 'getElementsByClassName', getOwnPropertyDescriptor(Element.prototype, 'getElementsByClassName'));
|
|
3971
|
+
}
|
|
3972
|
+
|
|
3973
|
+
/*
|
|
3974
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
3975
|
+
* All rights reserved.
|
|
3976
|
+
* SPDX-License-Identifier: MIT
|
|
3977
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3978
|
+
*/
|
|
3979
|
+
function getElementComputedStyle(element) {
|
|
3980
|
+
const win = getOwnerWindow(element);
|
|
3981
|
+
return windowGetComputedStyle.call(win, element);
|
|
3982
|
+
}
|
|
3983
|
+
function getWindowSelection(node) {
|
|
3984
|
+
const win = getOwnerWindow(node);
|
|
3985
|
+
return windowGetSelection.call(win);
|
|
3986
|
+
}
|
|
3987
|
+
function nodeIsBeingRendered(nodeComputedStyle) {
|
|
3988
|
+
return nodeComputedStyle.visibility === 'visible' && nodeComputedStyle.display !== 'none';
|
|
3989
|
+
}
|
|
3990
|
+
function getSelectionState(element) {
|
|
3991
|
+
const win = getOwnerWindow(element);
|
|
3992
|
+
const selection = getWindowSelection(element);
|
|
3993
|
+
if (selection === null) {
|
|
3994
|
+
return null;
|
|
3995
|
+
}
|
|
3996
|
+
const ranges = [];
|
|
3997
|
+
for (let i = 0; i < selection.rangeCount; i++) {
|
|
3998
|
+
ranges.push(selection.getRangeAt(i));
|
|
3999
|
+
}
|
|
4000
|
+
const state = {
|
|
4001
|
+
element,
|
|
4002
|
+
onselect: win.onselect,
|
|
4003
|
+
onselectstart: win.onselectstart,
|
|
4004
|
+
onselectionchange: win.onselectionchange,
|
|
4005
|
+
ranges,
|
|
4006
|
+
};
|
|
4007
|
+
win.onselect = null;
|
|
4008
|
+
win.onselectstart = null;
|
|
4009
|
+
win.onselectionchange = null;
|
|
4010
|
+
return state;
|
|
4011
|
+
}
|
|
4012
|
+
function restoreSelectionState(state) {
|
|
4013
|
+
if (state === null) {
|
|
4014
|
+
return;
|
|
4015
|
+
}
|
|
4016
|
+
const { element, onselect, onselectstart, onselectionchange, ranges } = state;
|
|
4017
|
+
const win = getOwnerWindow(element);
|
|
4018
|
+
const selection = getWindowSelection(element);
|
|
4019
|
+
selection.removeAllRanges();
|
|
4020
|
+
for (let i = 0; i < ranges.length; i++) {
|
|
4021
|
+
selection.addRange(ranges[i]);
|
|
4022
|
+
}
|
|
4023
|
+
win.onselect = onselect;
|
|
4024
|
+
win.onselectstart = onselectstart;
|
|
4025
|
+
win.onselectionchange = onselectionchange;
|
|
4026
|
+
}
|
|
4027
|
+
/**
|
|
4028
|
+
* Gets the "innerText" of a text node using the Selection API
|
|
4029
|
+
*
|
|
4030
|
+
* NOTE: For performance reasons, since this function will be called multiple times while calculating the innerText of
|
|
4031
|
+
* an element, it does not restore the current selection.
|
|
4032
|
+
*/
|
|
4033
|
+
function getTextNodeInnerText(textNode) {
|
|
4034
|
+
const selection = getWindowSelection(textNode);
|
|
4035
|
+
if (selection === null) {
|
|
4036
|
+
return textNode.textContent || '';
|
|
4037
|
+
}
|
|
4038
|
+
const range = document.createRange();
|
|
4039
|
+
range.selectNodeContents(textNode);
|
|
4040
|
+
const domRect = range.getBoundingClientRect();
|
|
4041
|
+
if (domRect.height <= 0 || domRect.width <= 0) {
|
|
4042
|
+
// the text node is not rendered
|
|
4043
|
+
return '';
|
|
4044
|
+
}
|
|
4045
|
+
// Needed to remove non rendered characters from the text node.
|
|
4046
|
+
selection.removeAllRanges();
|
|
4047
|
+
selection.addRange(range);
|
|
4048
|
+
const selectionText = selection.toString();
|
|
4049
|
+
// The textNode is visible, but it may not be selectable. When the text is not selectable,
|
|
4050
|
+
// textContent is the nearest approximation to innerText.
|
|
4051
|
+
return selectionText ? selectionText : textNode.textContent || '';
|
|
4052
|
+
}
|
|
4053
|
+
const nodeIsElement = (node) => node.nodeType === ELEMENT_NODE;
|
|
4054
|
+
const nodeIsText = (node) => node.nodeType === TEXT_NODE;
|
|
4055
|
+
/**
|
|
4056
|
+
* Spec: https://html.spec.whatwg.org/multipage/dom.html#inner-text-collection-steps
|
|
4057
|
+
* One spec implementation: https://github.com/servo/servo/blob/721271dcd3c20db5ca8cf146e2b5907647afb4d6/components/layout/query.rs#L1132
|
|
4058
|
+
*/
|
|
4059
|
+
function innerTextCollectionSteps(node) {
|
|
4060
|
+
const items = [];
|
|
4061
|
+
if (nodeIsElement(node)) {
|
|
4062
|
+
const { tagName } = node;
|
|
4063
|
+
const computedStyle = getElementComputedStyle(node);
|
|
4064
|
+
if (tagName === 'OPTION') {
|
|
4065
|
+
// For options, is hard to get the "rendered" text, let's use the original getter.
|
|
4066
|
+
return [1, innerTextGetter.call(node), 1];
|
|
4067
|
+
}
|
|
4068
|
+
else if (tagName === 'TEXTAREA') {
|
|
4069
|
+
return [];
|
|
4070
|
+
}
|
|
4071
|
+
else {
|
|
4072
|
+
const childNodes = node.childNodes;
|
|
4073
|
+
for (let i = 0, n = childNodes.length; i < n; i++) {
|
|
4074
|
+
ArrayPush.apply(items, innerTextCollectionSteps(childNodes[i]));
|
|
4075
|
+
}
|
|
4076
|
+
}
|
|
4077
|
+
if (!nodeIsBeingRendered(computedStyle)) {
|
|
4078
|
+
if (tagName === 'SELECT' || tagName === 'DATALIST') {
|
|
4079
|
+
// the select is either: .visibility != 'visible' or .display === hidden, therefore this select should
|
|
4080
|
+
// not display any value.
|
|
4081
|
+
return [];
|
|
4082
|
+
}
|
|
4083
|
+
return items;
|
|
4084
|
+
}
|
|
4085
|
+
if (tagName === 'BR') {
|
|
4086
|
+
items.push('\u{000A}' /* line feed */);
|
|
4087
|
+
}
|
|
4088
|
+
const { display } = computedStyle;
|
|
4089
|
+
if (display === 'table-cell') {
|
|
4090
|
+
// omitting case: and node's CSS box is not the last 'table-cell' box of its enclosing 'table-row' box
|
|
4091
|
+
items.push('\u{0009}' /* tab */);
|
|
4092
|
+
}
|
|
4093
|
+
if (display === 'table-row') {
|
|
4094
|
+
// omitting case: and node's CSS box is not the last 'table-row' box of the nearest ancestor 'table' box
|
|
4095
|
+
items.push('\u{000A}' /* line feed */);
|
|
4096
|
+
}
|
|
4097
|
+
if (tagName === 'P') {
|
|
4098
|
+
items.unshift(2);
|
|
4099
|
+
items.push(2);
|
|
4100
|
+
}
|
|
4101
|
+
if (display === 'block' ||
|
|
4102
|
+
display === 'table-caption' ||
|
|
4103
|
+
display === 'flex' ||
|
|
4104
|
+
display === 'table') {
|
|
4105
|
+
items.unshift(1);
|
|
4106
|
+
items.push(1);
|
|
4107
|
+
}
|
|
4108
|
+
}
|
|
4109
|
+
else if (nodeIsText(node)) {
|
|
4110
|
+
items.push(getTextNodeInnerText(node));
|
|
4111
|
+
}
|
|
4112
|
+
return items;
|
|
4113
|
+
}
|
|
4114
|
+
/**
|
|
4115
|
+
* InnerText getter spec: https://html.spec.whatwg.org/multipage/dom.html#the-innertext-idl-attribute
|
|
4116
|
+
*
|
|
4117
|
+
* One spec implementation: https://github.com/servo/servo/blob/721271dcd3c20db5ca8cf146e2b5907647afb4d6/components/layout/query.rs#L1087
|
|
4118
|
+
*/
|
|
4119
|
+
function getInnerText(element) {
|
|
4120
|
+
const thisComputedStyle = getElementComputedStyle(element);
|
|
4121
|
+
if (!nodeIsBeingRendered(thisComputedStyle)) {
|
|
4122
|
+
return getTextContent(element) || '';
|
|
4123
|
+
}
|
|
4124
|
+
const selectionState = getSelectionState(element);
|
|
4125
|
+
const results = [];
|
|
4126
|
+
const childNodes = element.childNodes;
|
|
4127
|
+
for (let i = 0, n = childNodes.length; i < n; i++) {
|
|
4128
|
+
ArrayPush.apply(results, innerTextCollectionSteps(childNodes[i]));
|
|
4129
|
+
}
|
|
4130
|
+
restoreSelectionState(selectionState);
|
|
4131
|
+
let elementInnerText = '';
|
|
4132
|
+
let maxReqLineBreakCount = 0;
|
|
4133
|
+
for (let i = 0, n = results.length; i < n; i++) {
|
|
4134
|
+
const item = results[i];
|
|
4135
|
+
if (typeof item === 'string') {
|
|
4136
|
+
if (maxReqLineBreakCount > 0) {
|
|
4137
|
+
for (let j = 0; j < maxReqLineBreakCount; j++) {
|
|
4138
|
+
elementInnerText += '\u{000A}';
|
|
4139
|
+
}
|
|
4140
|
+
maxReqLineBreakCount = 0;
|
|
4141
|
+
}
|
|
4142
|
+
if (item.length > 0) {
|
|
4143
|
+
elementInnerText += item;
|
|
4144
|
+
}
|
|
4145
|
+
}
|
|
4146
|
+
else {
|
|
4147
|
+
if (elementInnerText.length == 0) {
|
|
4148
|
+
// Remove required line break count at the start.
|
|
4149
|
+
continue;
|
|
4150
|
+
}
|
|
4151
|
+
// Store the count if it's the max of this run,
|
|
4152
|
+
// but it may be ignored if no text item is found afterwards,
|
|
4153
|
+
// which means that these are consecutive line breaks at the end.
|
|
4154
|
+
if (item > maxReqLineBreakCount) {
|
|
4155
|
+
maxReqLineBreakCount = item;
|
|
4156
|
+
}
|
|
3953
4157
|
}
|
|
3954
|
-
|
|
3955
|
-
const filteredResults = getFilteredArrayOfNodes(this, elements, 1
|
|
3956
|
-
/* Enabled */
|
|
3957
|
-
);
|
|
3958
|
-
return createStaticHTMLCollection(filteredResults);
|
|
3959
|
-
},
|
|
3960
|
-
|
|
3961
|
-
writable: true,
|
|
3962
|
-
enumerable: true,
|
|
3963
|
-
configurable: true
|
|
3964
4158
|
}
|
|
3965
|
-
|
|
3966
|
-
} // IE11 extra patches for wrong prototypes
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
if (hasOwnProperty.call(HTMLElement.prototype, 'getElementsByClassName')) {
|
|
3970
|
-
defineProperty(HTMLElement.prototype, 'getElementsByClassName', getOwnPropertyDescriptor(Element.prototype, 'getElementsByClassName'));
|
|
4159
|
+
return elementInnerText;
|
|
3971
4160
|
}
|
|
3972
4161
|
|
|
3973
4162
|
/*
|
|
@@ -4302,195 +4491,6 @@
|
|
|
4302
4491
|
removeEventListener.call(elm, 'focusin', skipShadowHandler, true);
|
|
4303
4492
|
}
|
|
4304
4493
|
|
|
4305
|
-
/*
|
|
4306
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
4307
|
-
* All rights reserved.
|
|
4308
|
-
* SPDX-License-Identifier: MIT
|
|
4309
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
4310
|
-
*/
|
|
4311
|
-
function getElementComputedStyle(element) {
|
|
4312
|
-
const win = getOwnerWindow(element);
|
|
4313
|
-
return windowGetComputedStyle.call(win, element);
|
|
4314
|
-
}
|
|
4315
|
-
function getWindowSelection(node) {
|
|
4316
|
-
const win = getOwnerWindow(node);
|
|
4317
|
-
return windowGetSelection.call(win);
|
|
4318
|
-
}
|
|
4319
|
-
function nodeIsBeingRendered(nodeComputedStyle) {
|
|
4320
|
-
return nodeComputedStyle.visibility === 'visible' && nodeComputedStyle.display !== 'none';
|
|
4321
|
-
}
|
|
4322
|
-
function getSelectionState(element) {
|
|
4323
|
-
const win = getOwnerWindow(element);
|
|
4324
|
-
const selection = getWindowSelection(element);
|
|
4325
|
-
if (selection === null) {
|
|
4326
|
-
return null;
|
|
4327
|
-
}
|
|
4328
|
-
const ranges = [];
|
|
4329
|
-
for (let i = 0; i < selection.rangeCount; i++) {
|
|
4330
|
-
ranges.push(selection.getRangeAt(i));
|
|
4331
|
-
}
|
|
4332
|
-
const state = {
|
|
4333
|
-
element,
|
|
4334
|
-
onselect: win.onselect,
|
|
4335
|
-
onselectstart: win.onselectstart,
|
|
4336
|
-
onselectionchange: win.onselectionchange,
|
|
4337
|
-
ranges,
|
|
4338
|
-
};
|
|
4339
|
-
win.onselect = null;
|
|
4340
|
-
win.onselectstart = null;
|
|
4341
|
-
win.onselectionchange = null;
|
|
4342
|
-
return state;
|
|
4343
|
-
}
|
|
4344
|
-
function restoreSelectionState(state) {
|
|
4345
|
-
if (state === null) {
|
|
4346
|
-
return;
|
|
4347
|
-
}
|
|
4348
|
-
const { element, onselect, onselectstart, onselectionchange, ranges } = state;
|
|
4349
|
-
const win = getOwnerWindow(element);
|
|
4350
|
-
const selection = getWindowSelection(element);
|
|
4351
|
-
selection.removeAllRanges();
|
|
4352
|
-
for (let i = 0; i < ranges.length; i++) {
|
|
4353
|
-
selection.addRange(ranges[i]);
|
|
4354
|
-
}
|
|
4355
|
-
win.onselect = onselect;
|
|
4356
|
-
win.onselectstart = onselectstart;
|
|
4357
|
-
win.onselectionchange = onselectionchange;
|
|
4358
|
-
}
|
|
4359
|
-
/**
|
|
4360
|
-
* Gets the "innerText" of a text node using the Selection API
|
|
4361
|
-
*
|
|
4362
|
-
* NOTE: For performance reasons, since this function will be called multiple times while calculating the innerText of
|
|
4363
|
-
* an element, it does not restore the current selection.
|
|
4364
|
-
*/
|
|
4365
|
-
function getTextNodeInnerText(textNode) {
|
|
4366
|
-
const selection = getWindowSelection(textNode);
|
|
4367
|
-
if (selection === null) {
|
|
4368
|
-
return textNode.textContent || '';
|
|
4369
|
-
}
|
|
4370
|
-
const range = document.createRange();
|
|
4371
|
-
range.selectNodeContents(textNode);
|
|
4372
|
-
const domRect = range.getBoundingClientRect();
|
|
4373
|
-
if (domRect.height <= 0 || domRect.width <= 0) {
|
|
4374
|
-
// the text node is not rendered
|
|
4375
|
-
return '';
|
|
4376
|
-
}
|
|
4377
|
-
// Needed to remove non rendered characters from the text node.
|
|
4378
|
-
selection.removeAllRanges();
|
|
4379
|
-
selection.addRange(range);
|
|
4380
|
-
const selectionText = selection.toString();
|
|
4381
|
-
// The textNode is visible, but it may not be selectable. When the text is not selectable,
|
|
4382
|
-
// textContent is the nearest approximation to innerText.
|
|
4383
|
-
return selectionText ? selectionText : textNode.textContent || '';
|
|
4384
|
-
}
|
|
4385
|
-
const nodeIsElement = (node) => node.nodeType === ELEMENT_NODE;
|
|
4386
|
-
const nodeIsText = (node) => node.nodeType === TEXT_NODE;
|
|
4387
|
-
/**
|
|
4388
|
-
* Spec: https://html.spec.whatwg.org/multipage/dom.html#inner-text-collection-steps
|
|
4389
|
-
* One spec implementation: https://github.com/servo/servo/blob/721271dcd3c20db5ca8cf146e2b5907647afb4d6/components/layout/query.rs#L1132
|
|
4390
|
-
*/
|
|
4391
|
-
function innerTextCollectionSteps(node) {
|
|
4392
|
-
const items = [];
|
|
4393
|
-
if (nodeIsElement(node)) {
|
|
4394
|
-
const { tagName } = node;
|
|
4395
|
-
const computedStyle = getElementComputedStyle(node);
|
|
4396
|
-
if (tagName === 'OPTION') {
|
|
4397
|
-
// For options, is hard to get the "rendered" text, let's use the original getter.
|
|
4398
|
-
return [1, innerTextGetter.call(node), 1];
|
|
4399
|
-
}
|
|
4400
|
-
else if (tagName === 'TEXTAREA') {
|
|
4401
|
-
return [];
|
|
4402
|
-
}
|
|
4403
|
-
else {
|
|
4404
|
-
const childNodes = node.childNodes;
|
|
4405
|
-
for (let i = 0, n = childNodes.length; i < n; i++) {
|
|
4406
|
-
ArrayPush.apply(items, innerTextCollectionSteps(childNodes[i]));
|
|
4407
|
-
}
|
|
4408
|
-
}
|
|
4409
|
-
if (!nodeIsBeingRendered(computedStyle)) {
|
|
4410
|
-
if (tagName === 'SELECT' || tagName === 'DATALIST') {
|
|
4411
|
-
// the select is either: .visibility != 'visible' or .display === hidden, therefore this select should
|
|
4412
|
-
// not display any value.
|
|
4413
|
-
return [];
|
|
4414
|
-
}
|
|
4415
|
-
return items;
|
|
4416
|
-
}
|
|
4417
|
-
if (tagName === 'BR') {
|
|
4418
|
-
items.push('\u{000A}' /* line feed */);
|
|
4419
|
-
}
|
|
4420
|
-
const { display } = computedStyle;
|
|
4421
|
-
if (display === 'table-cell') {
|
|
4422
|
-
// omitting case: and node's CSS box is not the last 'table-cell' box of its enclosing 'table-row' box
|
|
4423
|
-
items.push('\u{0009}' /* tab */);
|
|
4424
|
-
}
|
|
4425
|
-
if (display === 'table-row') {
|
|
4426
|
-
// omitting case: and node's CSS box is not the last 'table-row' box of the nearest ancestor 'table' box
|
|
4427
|
-
items.push('\u{000A}' /* line feed */);
|
|
4428
|
-
}
|
|
4429
|
-
if (tagName === 'P') {
|
|
4430
|
-
items.unshift(2);
|
|
4431
|
-
items.push(2);
|
|
4432
|
-
}
|
|
4433
|
-
if (display === 'block' ||
|
|
4434
|
-
display === 'table-caption' ||
|
|
4435
|
-
display === 'flex' ||
|
|
4436
|
-
display === 'table') {
|
|
4437
|
-
items.unshift(1);
|
|
4438
|
-
items.push(1);
|
|
4439
|
-
}
|
|
4440
|
-
}
|
|
4441
|
-
else if (nodeIsText(node)) {
|
|
4442
|
-
items.push(getTextNodeInnerText(node));
|
|
4443
|
-
}
|
|
4444
|
-
return items;
|
|
4445
|
-
}
|
|
4446
|
-
/**
|
|
4447
|
-
* InnerText getter spec: https://html.spec.whatwg.org/multipage/dom.html#the-innertext-idl-attribute
|
|
4448
|
-
*
|
|
4449
|
-
* One spec implementation: https://github.com/servo/servo/blob/721271dcd3c20db5ca8cf146e2b5907647afb4d6/components/layout/query.rs#L1087
|
|
4450
|
-
*/
|
|
4451
|
-
function getInnerText(element) {
|
|
4452
|
-
const thisComputedStyle = getElementComputedStyle(element);
|
|
4453
|
-
if (!nodeIsBeingRendered(thisComputedStyle)) {
|
|
4454
|
-
return getTextContent(element) || '';
|
|
4455
|
-
}
|
|
4456
|
-
const selectionState = getSelectionState(element);
|
|
4457
|
-
const results = [];
|
|
4458
|
-
const childNodes = element.childNodes;
|
|
4459
|
-
for (let i = 0, n = childNodes.length; i < n; i++) {
|
|
4460
|
-
ArrayPush.apply(results, innerTextCollectionSteps(childNodes[i]));
|
|
4461
|
-
}
|
|
4462
|
-
restoreSelectionState(selectionState);
|
|
4463
|
-
let elementInnerText = '';
|
|
4464
|
-
let maxReqLineBreakCount = 0;
|
|
4465
|
-
for (let i = 0, n = results.length; i < n; i++) {
|
|
4466
|
-
const item = results[i];
|
|
4467
|
-
if (typeof item === 'string') {
|
|
4468
|
-
if (maxReqLineBreakCount > 0) {
|
|
4469
|
-
for (let j = 0; j < maxReqLineBreakCount; j++) {
|
|
4470
|
-
elementInnerText += '\u{000A}';
|
|
4471
|
-
}
|
|
4472
|
-
maxReqLineBreakCount = 0;
|
|
4473
|
-
}
|
|
4474
|
-
if (item.length > 0) {
|
|
4475
|
-
elementInnerText += item;
|
|
4476
|
-
}
|
|
4477
|
-
}
|
|
4478
|
-
else {
|
|
4479
|
-
if (elementInnerText.length == 0) {
|
|
4480
|
-
// Remove required line break count at the start.
|
|
4481
|
-
continue;
|
|
4482
|
-
}
|
|
4483
|
-
// Store the count if it's the max of this run,
|
|
4484
|
-
// but it may be ignored if no text item is found afterwards,
|
|
4485
|
-
// which means that these are consecutive line breaks at the end.
|
|
4486
|
-
if (item > maxReqLineBreakCount) {
|
|
4487
|
-
maxReqLineBreakCount = item;
|
|
4488
|
-
}
|
|
4489
|
-
}
|
|
4490
|
-
}
|
|
4491
|
-
return elementInnerText;
|
|
4492
|
-
}
|
|
4493
|
-
|
|
4494
4494
|
/*
|
|
4495
4495
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
4496
4496
|
* All rights reserved.
|
|
@@ -4891,6 +4891,6 @@
|
|
|
4891
4891
|
},
|
|
4892
4892
|
configurable: true,
|
|
4893
4893
|
});
|
|
4894
|
-
/** version: 2.
|
|
4894
|
+
/** version: 2.13.1 */
|
|
4895
4895
|
|
|
4896
4896
|
})();
|