lwc 2.13.0 → 2.13.3

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