lwc 2.13.0 → 2.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/engine-dom/esm/es2017/engine-dom.js +88 -88
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +88 -88
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +2 -2
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +76 -76
  5. package/dist/engine-dom/iife/es5/engine-dom.js +87 -87
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +69 -69
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +88 -88
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +2 -2
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +76 -76
  11. package/dist/engine-dom/umd/es5/engine-dom.js +87 -87
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +69 -69
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +88 -88
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +88 -88
  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_debug.js +2 -2
  33. package/dist/wire-service/iife/es5/wire-service.js +1 -1
  34. package/dist/wire-service/iife/es5/wire-service_debug.js +1 -1
  35. package/dist/wire-service/umd/es2017/wire-service.js +2 -2
  36. package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
  37. package/dist/wire-service/umd/es5/wire-service.js +1 -1
  38. package/dist/wire-service/umd/es5/wire-service_debug.js +1 -1
  39. package/package.json +7 -7
@@ -160,7 +160,7 @@
160
160
  var hasNativeSymbolSupport = /*@__PURE__*/ function() {
161
161
  return Symbol("x").toString() === "Symbol(x)";
162
162
  }();
163
- /** version: 2.13.0 */ /*
163
+ /** version: 2.13.1 */ /*
164
164
  * Copyright (c) 2018, salesforce.com, inc.
165
165
  * All rights reserved.
166
166
  * SPDX-License-Identifier: MIT
@@ -404,238 +404,6 @@
404
404
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
405
405
  */ var eventTargetPrototype = typeof EventTarget !== "undefined" ? EventTarget.prototype : _Node.prototype;
406
406
  var addEventListener = eventTargetPrototype.addEventListener, dispatchEvent = eventTargetPrototype.dispatchEvent, removeEventListener = eventTargetPrototype.removeEventListener;
407
- /*
408
- * Copyright (c) 2018, salesforce.com, inc.
409
- * All rights reserved.
410
- * SPDX-License-Identifier: MIT
411
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
412
- */ var EventListenerMap = new WeakMap();
413
- var ComposedPathMap = new WeakMap();
414
- function isEventListenerOrEventListenerObject(fnOrObj) {
415
- return isFunction(fnOrObj) || isObject(fnOrObj) && !isNull(fnOrObj) && isFunction(fnOrObj.handleEvent);
416
- }
417
- function shouldInvokeListener(event, target, currentTarget) {
418
- // Subsequent logic assumes that `currentTarget` must be contained in the composed path for the listener to be
419
- // invoked, but this is not always the case. `composedPath()` will sometimes return an empty array, even when the
420
- // listener should be invoked (e.g., a disconnected instance of EventTarget, an instance of XMLHttpRequest, etc).
421
- if (target === currentTarget) {
422
- return true;
423
- }
424
- var composedPath1 = ComposedPathMap.get(event);
425
- if (isUndefined(composedPath1)) {
426
- composedPath1 = event.composedPath();
427
- ComposedPathMap.set(event, composedPath1);
428
- }
429
- return composedPath1.includes(currentTarget);
430
- }
431
- function getEventListenerWrapper(fnOrObj) {
432
- if (!isEventListenerOrEventListenerObject(fnOrObj)) {
433
- return fnOrObj;
434
- }
435
- var wrapperFn = EventListenerMap.get(fnOrObj);
436
- if (isUndefined(wrapperFn)) {
437
- wrapperFn = function wrapperFn(event) {
438
- // This function is invoked from an event listener and currentTarget is always defined.
439
- var currentTarget = eventCurrentTargetGetter.call(event);
440
- if (process.env.NODE_ENV !== "production") {
441
- assert.invariant(isFalse(isSyntheticShadowHost(currentTarget)), "This routine should not be used to wrap event listeners for host elements and shadow roots.");
442
- }
443
- var actualTarget = getActualTarget(event);
444
- if (!shouldInvokeListener(event, actualTarget, currentTarget)) {
445
- return;
446
- }
447
- return isFunction(fnOrObj) ? fnOrObj.call(this, event) : fnOrObj.handleEvent && fnOrObj.handleEvent(event);
448
- };
449
- EventListenerMap.set(fnOrObj, wrapperFn);
450
- }
451
- return wrapperFn;
452
- }
453
- /*
454
- * Copyright (c) 2018, salesforce.com, inc.
455
- * All rights reserved.
456
- * SPDX-License-Identifier: MIT
457
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
458
- */ var eventToContextMap = new WeakMap();
459
- var customElementToWrappedListeners = new WeakMap();
460
- function getEventMap(elm) {
461
- var listenerInfo = customElementToWrappedListeners.get(elm);
462
- if (isUndefined(listenerInfo)) {
463
- listenerInfo = create(null);
464
- customElementToWrappedListeners.set(elm, listenerInfo);
465
- }
466
- return listenerInfo;
467
- }
468
- /**
469
- * Events dispatched on shadow roots actually end up being dispatched on their hosts. This means that the event.target
470
- * property of events dispatched on shadow roots always resolve to their host. This function understands this
471
- * abstraction and properly returns a reference to the shadow root when appropriate.
472
- */ function getActualTarget(event) {
473
- var _a;
474
- return (_a = eventToShadowRootMap.get(event)) !== null && _a !== void 0 ? _a : eventTargetGetter.call(event);
475
- }
476
- var shadowRootEventListenerMap = new WeakMap();
477
- function getWrappedShadowRootListener(listener) {
478
- if (!isFunction(listener)) {
479
- throw new TypeError(); // avoiding problems with non-valid listeners
480
- }
481
- var shadowRootWrappedListener = shadowRootEventListenerMap.get(listener);
482
- if (isUndefined(shadowRootWrappedListener)) {
483
- shadowRootWrappedListener = function shadowRootWrappedListener(event) {
484
- // currentTarget is always defined inside an event listener
485
- var currentTarget = eventCurrentTargetGetter.call(event);
486
- // If currentTarget is not an instance of a native shadow root then we're dealing with a
487
- // host element whose synthetic shadow root must be accessed via getShadowRoot().
488
- if (!isInstanceOfNativeShadowRoot(currentTarget)) {
489
- currentTarget = getShadowRoot(currentTarget);
490
- }
491
- var actualTarget = getActualTarget(event);
492
- if (shouldInvokeListener(event, actualTarget, currentTarget)) {
493
- listener.call(currentTarget, event);
494
- }
495
- };
496
- shadowRootWrappedListener.placement = 1 /* SHADOW_ROOT_LISTENER */ ;
497
- shadowRootEventListenerMap.set(listener, shadowRootWrappedListener);
498
- }
499
- return shadowRootWrappedListener;
500
- }
501
- var customElementEventListenerMap = new WeakMap();
502
- function getWrappedCustomElementListener(listener) {
503
- if (!isFunction(listener)) {
504
- throw new TypeError(); // avoiding problems with non-valid listeners
505
- }
506
- var customElementWrappedListener = customElementEventListenerMap.get(listener);
507
- if (isUndefined(customElementWrappedListener)) {
508
- customElementWrappedListener = function customElementWrappedListener(event) {
509
- // currentTarget is always defined inside an event listener
510
- var currentTarget = eventCurrentTargetGetter.call(event);
511
- var actualTarget = getActualTarget(event);
512
- if (shouldInvokeListener(event, actualTarget, currentTarget)) {
513
- listener.call(currentTarget, event);
514
- }
515
- };
516
- customElementWrappedListener.placement = 0 /* CUSTOM_ELEMENT_LISTENER */ ;
517
- customElementEventListenerMap.set(listener, customElementWrappedListener);
518
- }
519
- return customElementWrappedListener;
520
- }
521
- function domListener(evt) {
522
- var invokeListenersByPlacement = function invokeListenersByPlacement(placement) {
523
- forEach.call(bookkeeping, function(listener) {
524
- if (isFalse(immediatePropagationStopped) && listener.placement === placement) {
525
- // making sure that the listener was not removed from the original listener queue
526
- if (ArrayIndexOf.call(listeners, listener) !== -1) {
527
- // all handlers on the custom element should be called with undefined 'this'
528
- listener.call(undefined, evt);
529
- }
530
- }
531
- });
532
- };
533
- var immediatePropagationStopped = false;
534
- var propagationStopped = false;
535
- var type = evt.type, stopImmediatePropagation = evt.stopImmediatePropagation, stopPropagation = evt.stopPropagation;
536
- // currentTarget is always defined
537
- var currentTarget = eventCurrentTargetGetter.call(evt);
538
- var listenerMap = getEventMap(currentTarget);
539
- var listeners = listenerMap[type]; // it must have listeners at this point
540
- defineProperty(evt, "stopImmediatePropagation", {
541
- value: function value() {
542
- immediatePropagationStopped = true;
543
- stopImmediatePropagation.call(evt);
544
- },
545
- writable: true,
546
- enumerable: true,
547
- configurable: true
548
- });
549
- defineProperty(evt, "stopPropagation", {
550
- value: function value() {
551
- propagationStopped = true;
552
- stopPropagation.call(evt);
553
- },
554
- writable: true,
555
- enumerable: true,
556
- configurable: true
557
- });
558
- // in case a listener adds or removes other listeners during invocation
559
- var bookkeeping = ArraySlice.call(listeners);
560
- eventToContextMap.set(evt, 1 /* SHADOW_ROOT_LISTENER */ );
561
- invokeListenersByPlacement(1 /* SHADOW_ROOT_LISTENER */ );
562
- if (isFalse(immediatePropagationStopped) && isFalse(propagationStopped)) {
563
- // doing the second iteration only if the first one didn't interrupt the event propagation
564
- eventToContextMap.set(evt, 0 /* CUSTOM_ELEMENT_LISTENER */ );
565
- invokeListenersByPlacement(0 /* CUSTOM_ELEMENT_LISTENER */ );
566
- }
567
- eventToContextMap.set(evt, 2 /* UNKNOWN_LISTENER */ );
568
- }
569
- function attachDOMListener(elm, type, wrappedListener) {
570
- var listenerMap = getEventMap(elm);
571
- var cmpEventHandlers = listenerMap[type];
572
- if (isUndefined(cmpEventHandlers)) {
573
- cmpEventHandlers = listenerMap[type] = [];
574
- }
575
- // Prevent identical listeners from subscribing to the same event type.
576
- // TODO [#1824]: Options will also play a factor when we introduce support for them (#1824).
577
- if (ArrayIndexOf.call(cmpEventHandlers, wrappedListener) !== -1) {
578
- return;
579
- }
580
- // only add to DOM if there is no other listener on the same placement yet
581
- if (cmpEventHandlers.length === 0) {
582
- // super.addEventListener() - this will not work on
583
- addEventListener.call(elm, type, domListener);
584
- }
585
- ArrayPush.call(cmpEventHandlers, wrappedListener);
586
- }
587
- function detachDOMListener(elm, type, wrappedListener) {
588
- var listenerMap = getEventMap(elm);
589
- var p;
590
- var listeners;
591
- if (!isUndefined(listeners = listenerMap[type]) && (p = ArrayIndexOf.call(listeners, wrappedListener)) !== -1) {
592
- ArraySplice.call(listeners, p, 1);
593
- // only remove from DOM if there is no other listener on the same placement
594
- if (listeners.length === 0) {
595
- removeEventListener.call(elm, type, domListener);
596
- }
597
- }
598
- }
599
- function addCustomElementEventListener(type, listener, _options) {
600
- if (process.env.NODE_ENV !== "production") {
601
- if (!isFunction(listener)) {
602
- throw new TypeError("Invalid second argument for Element.addEventListener() in ".concat(toString(this), ' for event "').concat(type, '". Expected an EventListener but received ').concat(listener, "."));
603
- }
604
- }
605
- // TODO [#1824]: Lift this restriction on the option parameter
606
- if (isFunction(listener)) {
607
- var wrappedListener = getWrappedCustomElementListener(listener);
608
- attachDOMListener(this, type, wrappedListener);
609
- }
610
- }
611
- function removeCustomElementEventListener(type, listener, _options) {
612
- // TODO [#1824]: Lift this restriction on the option parameter
613
- if (isFunction(listener)) {
614
- var wrappedListener = getWrappedCustomElementListener(listener);
615
- detachDOMListener(this, type, wrappedListener);
616
- }
617
- }
618
- function addShadowRootEventListener(sr, type, listener, _options) {
619
- if (process.env.NODE_ENV !== "production") {
620
- if (!isFunction(listener)) {
621
- throw new TypeError("Invalid second argument for ShadowRoot.addEventListener() in ".concat(toString(sr), ' for event "').concat(type, '". Expected an EventListener but received ').concat(listener, "."));
622
- }
623
- }
624
- // TODO [#1824]: Lift this restriction on the option parameter
625
- if (isFunction(listener)) {
626
- var elm = getHost(sr);
627
- var wrappedListener = getWrappedShadowRootListener(listener);
628
- attachDOMListener(elm, type, wrappedListener);
629
- }
630
- }
631
- function removeShadowRootEventListener(sr, type, listener, _options) {
632
- // TODO [#1824]: Lift this restriction on the option parameter
633
- if (isFunction(listener)) {
634
- var elm = getHost(sr);
635
- var wrappedListener = getWrappedShadowRootListener(listener);
636
- detachDOMListener(elm, type, wrappedListener);
637
- }
638
- }
639
407
  /*
640
408
  * Copyright (c) 2018, salesforce.com, inc.
641
409
  * All rights reserved.
@@ -894,31 +662,149 @@
894
662
  * All rights reserved.
895
663
  * SPDX-License-Identifier: MIT
896
664
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
897
- */ function getTextContent(node) {
898
- switch(node.nodeType){
899
- case ELEMENT_NODE:
900
- {
901
- var childNodes = getFilteredChildNodes(node);
902
- var content = "";
903
- for(var i = 0, len = childNodes.length; i < len; i += 1){
904
- var currentNode = childNodes[i];
905
- if (currentNode.nodeType !== COMMENT_NODE) {
906
- content += getTextContent(currentNode);
907
- }
908
- }
909
- return content;
910
- }
911
- default:
912
- return node.nodeValue;
665
+ */ function getInnerHTML(node) {
666
+ var s = "";
667
+ var childNodes = getFilteredChildNodes(node);
668
+ for(var i = 0, len = childNodes.length; i < len; i += 1){
669
+ s += getOuterHTML(childNodes[i]);
913
670
  }
671
+ return s;
914
672
  }
915
673
  /*
916
674
  * Copyright (c) 2018, salesforce.com, inc.
917
675
  * All rights reserved.
918
676
  * SPDX-License-Identifier: MIT
919
677
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
920
- */ var Items$1 = new WeakMap();
921
- function StaticNodeList() {
678
+ */ // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#escapingString
679
+ var escapeAttrRegExp = /[&\u00A0"]/g;
680
+ var escapeDataRegExp = /[&\u00A0<>]/g;
681
+ var _prototype5 = String.prototype, replace = _prototype5.replace, toLowerCase = _prototype5.toLowerCase;
682
+ function escapeReplace(c) {
683
+ switch(c){
684
+ case "&":
685
+ return "&amp;";
686
+ case "<":
687
+ return "&lt;";
688
+ case ">":
689
+ return "&gt;";
690
+ case '"':
691
+ return "&quot;";
692
+ case "\xa0":
693
+ return "&nbsp;";
694
+ default:
695
+ return "";
696
+ }
697
+ }
698
+ function escapeAttr(s) {
699
+ return replace.call(s, escapeAttrRegExp, escapeReplace);
700
+ }
701
+ function escapeData(s) {
702
+ return replace.call(s, escapeDataRegExp, escapeReplace);
703
+ }
704
+ // http://www.whatwg.org/specs/web-apps/current-work/#void-elements
705
+ var voidElements = new Set([
706
+ "AREA",
707
+ "BASE",
708
+ "BR",
709
+ "COL",
710
+ "COMMAND",
711
+ "EMBED",
712
+ "HR",
713
+ "IMG",
714
+ "INPUT",
715
+ "KEYGEN",
716
+ "LINK",
717
+ "META",
718
+ "PARAM",
719
+ "SOURCE",
720
+ "TRACK",
721
+ "WBR",
722
+ ]);
723
+ var plaintextParents = new Set([
724
+ "STYLE",
725
+ "SCRIPT",
726
+ "XMP",
727
+ "IFRAME",
728
+ "NOEMBED",
729
+ "NOFRAMES",
730
+ "PLAINTEXT",
731
+ "NOSCRIPT",
732
+ ]);
733
+ function getOuterHTML(node) {
734
+ switch(node.nodeType){
735
+ case ELEMENT_NODE:
736
+ {
737
+ var attrs = node.attributes;
738
+ var tagName = tagNameGetter.call(node);
739
+ var s = "<" + toLowerCase.call(tagName);
740
+ for(var i = 0, attr; attr = attrs[i]; i++){
741
+ s += " " + attr.name + '="' + escapeAttr(attr.value) + '"';
742
+ }
743
+ s += ">";
744
+ if (voidElements.has(tagName)) {
745
+ return s;
746
+ }
747
+ return s + getInnerHTML(node) + "</" + toLowerCase.call(tagName) + ">";
748
+ }
749
+ case TEXT_NODE:
750
+ {
751
+ var data = node.data, parentNode = node.parentNode;
752
+ if (_instanceof(parentNode, Element) && plaintextParents.has(tagNameGetter.call(parentNode))) {
753
+ return data;
754
+ }
755
+ return escapeData(data);
756
+ }
757
+ case CDATA_SECTION_NODE:
758
+ {
759
+ return "<!CDATA[[".concat(node.data, "]]>");
760
+ }
761
+ case PROCESSING_INSTRUCTION_NODE:
762
+ {
763
+ return "<?".concat(node.target, " ").concat(node.data, "?>");
764
+ }
765
+ case COMMENT_NODE:
766
+ {
767
+ return "<!--".concat(node.data, "-->");
768
+ }
769
+ default:
770
+ {
771
+ // intentionally ignoring unknown node types
772
+ // Note: since this routine is always invoked for childNodes
773
+ // we can safety ignore type 9, 10 and 99 (document, fragment and doctype)
774
+ return "";
775
+ }
776
+ }
777
+ }
778
+ /*
779
+ * Copyright (c) 2018, salesforce.com, inc.
780
+ * All rights reserved.
781
+ * SPDX-License-Identifier: MIT
782
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
783
+ */ function getTextContent(node) {
784
+ switch(node.nodeType){
785
+ case ELEMENT_NODE:
786
+ {
787
+ var childNodes = getFilteredChildNodes(node);
788
+ var content = "";
789
+ for(var i = 0, len = childNodes.length; i < len; i += 1){
790
+ var currentNode = childNodes[i];
791
+ if (currentNode.nodeType !== COMMENT_NODE) {
792
+ content += getTextContent(currentNode);
793
+ }
794
+ }
795
+ return content;
796
+ }
797
+ default:
798
+ return node.nodeValue;
799
+ }
800
+ }
801
+ /*
802
+ * Copyright (c) 2018, salesforce.com, inc.
803
+ * All rights reserved.
804
+ * SPDX-License-Identifier: MIT
805
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
806
+ */ var Items$1 = new WeakMap();
807
+ function StaticNodeList() {
922
808
  throw new TypeError("Illegal constructor");
923
809
  }
924
810
  var _obj;
@@ -1030,6 +916,67 @@
1030
916
  });
1031
917
  return nodeList;
1032
918
  }
919
+ /*
920
+ * Copyright (c) 2018, salesforce.com, inc.
921
+ * All rights reserved.
922
+ * SPDX-License-Identifier: MIT
923
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
924
+ */ // Walk up the DOM tree, collecting all shadow roots plus the document root
925
+ function getAllRootNodes(node) {
926
+ var _a;
927
+ var rootNodes = [];
928
+ var currentRootNode = node.getRootNode();
929
+ while(!isUndefined(currentRootNode)){
930
+ rootNodes.push(currentRootNode);
931
+ currentRootNode = (_a = currentRootNode.host) === null || _a === void 0 ? void 0 : _a.getRootNode();
932
+ }
933
+ return rootNodes;
934
+ }
935
+ // Keep searching up the host tree until we find an element that is within the immediate shadow root
936
+ var findAncestorHostInImmediateShadowRoot = function(rootNode, targetRootNode) {
937
+ var host;
938
+ while(!isUndefined(host = rootNode.host)){
939
+ var thisRootNode = host.getRootNode();
940
+ if (thisRootNode === targetRootNode) {
941
+ return host;
942
+ }
943
+ rootNode = thisRootNode;
944
+ }
945
+ };
946
+ function fauxElementsFromPoint(context, doc, left, top) {
947
+ var elements = elementsFromPoint.call(doc, left, top);
948
+ var result = [];
949
+ var rootNodes = getAllRootNodes(context);
950
+ // Filter the elements array to only include those elements that are in this shadow root or in one of its
951
+ // ancestor roots. This matches Chrome and Safari's implementation (but not Firefox's, which only includes
952
+ // elements in the immediate shadow root: https://crbug.com/1207863#c4).
953
+ if (!isNull(elements)) {
954
+ // can be null in IE https://developer.mozilla.org/en-US/docs/Web/API/Document/elementsFromPoint#browser_compatibility
955
+ for(var i = 0; i < elements.length; i++){
956
+ var element = elements[i];
957
+ if (isSyntheticSlotElement(element)) {
958
+ continue;
959
+ }
960
+ var elementRootNode = element.getRootNode();
961
+ if (ArrayIndexOf.call(rootNodes, elementRootNode) !== -1) {
962
+ ArrayPush.call(result, element);
963
+ continue;
964
+ }
965
+ // In cases where the host element is not visible but its shadow descendants are, then
966
+ // we may get the shadow descendant instead of the host element here. (The
967
+ // browser doesn't know the difference in synthetic shadow DOM.)
968
+ // In native shadow DOM, however, elementsFromPoint would return the host but not
969
+ // the child. So we need to detect if this shadow element's host is accessible from
970
+ // the context's shadow root. Note we also need to be careful not to add the host
971
+ // multiple times.
972
+ var ancestorHost = findAncestorHostInImmediateShadowRoot(elementRootNode, rootNodes[0]);
973
+ if (!isUndefined(ancestorHost) && ArrayIndexOf.call(elements, ancestorHost) === -1 && ArrayIndexOf.call(result, ancestorHost) === -1) {
974
+ ArrayPush.call(result, ancestorHost);
975
+ }
976
+ }
977
+ }
978
+ return result;
979
+ }
1033
980
  /*
1034
981
  * Copyright (c) 2018, salesforce.com, inc.
1035
982
  * All rights reserved.
@@ -1066,166 +1013,48 @@
1066
1013
  writable: true,
1067
1014
  enumerable: true,
1068
1015
  configurable: true,
1069
- value: function value(name) {
1070
- if (name === "") {
1071
- return null;
1072
- }
1073
- var items = Items.get(this);
1074
- for(var i = 0, len = items.length; i < len; i++){
1075
- var item = items[len];
1076
- if (name === getAttribute.call(item, "id") || name === getAttribute.call(item, "name")) {
1077
- return item;
1078
- }
1079
- }
1080
- return null;
1081
- }
1082
- }
1083
- }, _defineProperty(_obj1, Symbol.toStringTag, {
1084
- configurable: true,
1085
- get: function get() {
1086
- return "HTMLCollection";
1087
- }
1088
- }), // IE11 doesn't support Symbol.toStringTag, in which case we
1089
- // provide the regular toString method.
1090
- _defineProperty(_obj1, "toString", {
1091
- writable: true,
1092
- configurable: true,
1093
- value: function value() {
1094
- return "[object HTMLCollection]";
1095
- }
1096
- }), _obj1));
1097
- // prototype inheritance dance
1098
- setPrototypeOf(StaticHTMLCollection, HTMLCollection);
1099
- function createStaticHTMLCollection(items) {
1100
- var collection = create(StaticHTMLCollection.prototype);
1101
- Items.set(collection, items);
1102
- // setting static indexes
1103
- forEach.call(items, function(item, index) {
1104
- defineProperty(collection, index, {
1105
- value: item,
1106
- enumerable: true,
1107
- configurable: true
1108
- });
1109
- });
1110
- return collection;
1111
- }
1112
- /*
1113
- * Copyright (c) 2018, salesforce.com, inc.
1114
- * All rights reserved.
1115
- * SPDX-License-Identifier: MIT
1116
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1117
- */ function getInnerHTML(node) {
1118
- var s = "";
1119
- var childNodes = getFilteredChildNodes(node);
1120
- for(var i = 0, len = childNodes.length; i < len; i += 1){
1121
- s += getOuterHTML(childNodes[i]);
1122
- }
1123
- return s;
1124
- }
1125
- /*
1126
- * Copyright (c) 2018, salesforce.com, inc.
1127
- * All rights reserved.
1128
- * SPDX-License-Identifier: MIT
1129
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1130
- */ // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#escapingString
1131
- var escapeAttrRegExp = /[&\u00A0"]/g;
1132
- var escapeDataRegExp = /[&\u00A0<>]/g;
1133
- var _prototype5 = String.prototype, replace = _prototype5.replace, toLowerCase = _prototype5.toLowerCase;
1134
- function escapeReplace(c) {
1135
- switch(c){
1136
- case "&":
1137
- return "&amp;";
1138
- case "<":
1139
- return "&lt;";
1140
- case ">":
1141
- return "&gt;";
1142
- case '"':
1143
- return "&quot;";
1144
- case "\xa0":
1145
- return "&nbsp;";
1146
- default:
1147
- return "";
1148
- }
1149
- }
1150
- function escapeAttr(s) {
1151
- return replace.call(s, escapeAttrRegExp, escapeReplace);
1152
- }
1153
- function escapeData(s) {
1154
- return replace.call(s, escapeDataRegExp, escapeReplace);
1155
- }
1156
- // http://www.whatwg.org/specs/web-apps/current-work/#void-elements
1157
- var voidElements = new Set([
1158
- "AREA",
1159
- "BASE",
1160
- "BR",
1161
- "COL",
1162
- "COMMAND",
1163
- "EMBED",
1164
- "HR",
1165
- "IMG",
1166
- "INPUT",
1167
- "KEYGEN",
1168
- "LINK",
1169
- "META",
1170
- "PARAM",
1171
- "SOURCE",
1172
- "TRACK",
1173
- "WBR",
1174
- ]);
1175
- var plaintextParents = new Set([
1176
- "STYLE",
1177
- "SCRIPT",
1178
- "XMP",
1179
- "IFRAME",
1180
- "NOEMBED",
1181
- "NOFRAMES",
1182
- "PLAINTEXT",
1183
- "NOSCRIPT",
1184
- ]);
1185
- function getOuterHTML(node) {
1186
- switch(node.nodeType){
1187
- case ELEMENT_NODE:
1188
- {
1189
- var attrs = node.attributes;
1190
- var tagName = tagNameGetter.call(node);
1191
- var s = "<" + toLowerCase.call(tagName);
1192
- for(var i = 0, attr; attr = attrs[i]; i++){
1193
- s += " " + attr.name + '="' + escapeAttr(attr.value) + '"';
1194
- }
1195
- s += ">";
1196
- if (voidElements.has(tagName)) {
1197
- return s;
1198
- }
1199
- return s + getInnerHTML(node) + "</" + toLowerCase.call(tagName) + ">";
1200
- }
1201
- case TEXT_NODE:
1202
- {
1203
- var data = node.data, parentNode = node.parentNode;
1204
- if (_instanceof(parentNode, Element) && plaintextParents.has(tagNameGetter.call(parentNode))) {
1205
- return data;
1206
- }
1207
- return escapeData(data);
1208
- }
1209
- case CDATA_SECTION_NODE:
1210
- {
1211
- return "<!CDATA[[".concat(node.data, "]]>");
1212
- }
1213
- case PROCESSING_INSTRUCTION_NODE:
1214
- {
1215
- return "<?".concat(node.target, " ").concat(node.data, "?>");
1216
- }
1217
- case COMMENT_NODE:
1218
- {
1219
- return "<!--".concat(node.data, "-->");
1016
+ value: function value(name) {
1017
+ if (name === "") {
1018
+ return null;
1220
1019
  }
1221
- default:
1222
- {
1223
- // intentionally ignoring unknown node types
1224
- // Note: since this routine is always invoked for childNodes
1225
- // we can safety ignore type 9, 10 and 99 (document, fragment and doctype)
1226
- return "";
1020
+ var items = Items.get(this);
1021
+ for(var i = 0, len = items.length; i < len; i++){
1022
+ var item = items[len];
1023
+ if (name === getAttribute.call(item, "id") || name === getAttribute.call(item, "name")) {
1024
+ return item;
1025
+ }
1227
1026
  }
1027
+ return null;
1028
+ }
1029
+ }
1030
+ }, _defineProperty(_obj1, Symbol.toStringTag, {
1031
+ configurable: true,
1032
+ get: function get() {
1033
+ return "HTMLCollection";
1034
+ }
1035
+ }), // IE11 doesn't support Symbol.toStringTag, in which case we
1036
+ // provide the regular toString method.
1037
+ _defineProperty(_obj1, "toString", {
1038
+ writable: true,
1039
+ configurable: true,
1040
+ value: function value() {
1041
+ return "[object HTMLCollection]";
1228
1042
  }
1043
+ }), _obj1));
1044
+ // prototype inheritance dance
1045
+ setPrototypeOf(StaticHTMLCollection, HTMLCollection);
1046
+ function createStaticHTMLCollection(items) {
1047
+ var collection = create(StaticHTMLCollection.prototype);
1048
+ Items.set(collection, items);
1049
+ // setting static indexes
1050
+ forEach.call(items, function(item, index) {
1051
+ defineProperty(collection, index, {
1052
+ value: item,
1053
+ enumerable: true,
1054
+ configurable: true
1055
+ });
1056
+ });
1057
+ return collection;
1229
1058
  }
1230
1059
  /**
1231
1060
  * Copyright (C) 2018 salesforce.com, inc.
@@ -1235,7 +1064,7 @@
1235
1064
  });
1236
1065
  }
1237
1066
  var runtimeFlags = _globalThis.lwcRuntimeFlags;
1238
- /** version: 2.13.0 */ /*
1067
+ /** version: 2.13.1 */ /*
1239
1068
  * Copyright (c) 2018, salesforce.com, inc.
1240
1069
  * All rights reserved.
1241
1070
  * SPDX-License-Identifier: MIT
@@ -1609,61 +1438,232 @@
1609
1438
  * All rights reserved.
1610
1439
  * SPDX-License-Identifier: MIT
1611
1440
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1612
- */ // Walk up the DOM tree, collecting all shadow roots plus the document root
1613
- function getAllRootNodes(node) {
1441
+ */ var EventListenerMap = new WeakMap();
1442
+ var ComposedPathMap = new WeakMap();
1443
+ function isEventListenerOrEventListenerObject(fnOrObj) {
1444
+ return isFunction(fnOrObj) || isObject(fnOrObj) && !isNull(fnOrObj) && isFunction(fnOrObj.handleEvent);
1445
+ }
1446
+ function shouldInvokeListener(event, target, currentTarget) {
1447
+ // Subsequent logic assumes that `currentTarget` must be contained in the composed path for the listener to be
1448
+ // invoked, but this is not always the case. `composedPath()` will sometimes return an empty array, even when the
1449
+ // listener should be invoked (e.g., a disconnected instance of EventTarget, an instance of XMLHttpRequest, etc).
1450
+ if (target === currentTarget) {
1451
+ return true;
1452
+ }
1453
+ var composedPath1 = ComposedPathMap.get(event);
1454
+ if (isUndefined(composedPath1)) {
1455
+ composedPath1 = event.composedPath();
1456
+ ComposedPathMap.set(event, composedPath1);
1457
+ }
1458
+ return composedPath1.includes(currentTarget);
1459
+ }
1460
+ function getEventListenerWrapper(fnOrObj) {
1461
+ if (!isEventListenerOrEventListenerObject(fnOrObj)) {
1462
+ return fnOrObj;
1463
+ }
1464
+ var wrapperFn = EventListenerMap.get(fnOrObj);
1465
+ if (isUndefined(wrapperFn)) {
1466
+ wrapperFn = function wrapperFn(event) {
1467
+ // This function is invoked from an event listener and currentTarget is always defined.
1468
+ var currentTarget = eventCurrentTargetGetter.call(event);
1469
+ if (process.env.NODE_ENV !== "production") {
1470
+ assert.invariant(isFalse(isSyntheticShadowHost(currentTarget)), "This routine should not be used to wrap event listeners for host elements and shadow roots.");
1471
+ }
1472
+ var actualTarget = getActualTarget(event);
1473
+ if (!shouldInvokeListener(event, actualTarget, currentTarget)) {
1474
+ return;
1475
+ }
1476
+ return isFunction(fnOrObj) ? fnOrObj.call(this, event) : fnOrObj.handleEvent && fnOrObj.handleEvent(event);
1477
+ };
1478
+ EventListenerMap.set(fnOrObj, wrapperFn);
1479
+ }
1480
+ return wrapperFn;
1481
+ }
1482
+ /*
1483
+ * Copyright (c) 2018, salesforce.com, inc.
1484
+ * All rights reserved.
1485
+ * SPDX-License-Identifier: MIT
1486
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1487
+ */ var eventToContextMap = new WeakMap();
1488
+ var customElementToWrappedListeners = new WeakMap();
1489
+ function getEventMap(elm) {
1490
+ var listenerInfo = customElementToWrappedListeners.get(elm);
1491
+ if (isUndefined(listenerInfo)) {
1492
+ listenerInfo = create(null);
1493
+ customElementToWrappedListeners.set(elm, listenerInfo);
1494
+ }
1495
+ return listenerInfo;
1496
+ }
1497
+ /**
1498
+ * Events dispatched on shadow roots actually end up being dispatched on their hosts. This means that the event.target
1499
+ * property of events dispatched on shadow roots always resolve to their host. This function understands this
1500
+ * abstraction and properly returns a reference to the shadow root when appropriate.
1501
+ */ function getActualTarget(event) {
1614
1502
  var _a;
1615
- var rootNodes = [];
1616
- var currentRootNode = node.getRootNode();
1617
- while(!isUndefined(currentRootNode)){
1618
- rootNodes.push(currentRootNode);
1619
- currentRootNode = (_a = currentRootNode.host) === null || _a === void 0 ? void 0 : _a.getRootNode();
1503
+ return (_a = eventToShadowRootMap.get(event)) !== null && _a !== void 0 ? _a : eventTargetGetter.call(event);
1504
+ }
1505
+ var shadowRootEventListenerMap = new WeakMap();
1506
+ function getWrappedShadowRootListener(listener) {
1507
+ if (!isFunction(listener)) {
1508
+ throw new TypeError(); // avoiding problems with non-valid listeners
1620
1509
  }
1621
- return rootNodes;
1510
+ var shadowRootWrappedListener = shadowRootEventListenerMap.get(listener);
1511
+ if (isUndefined(shadowRootWrappedListener)) {
1512
+ shadowRootWrappedListener = function shadowRootWrappedListener(event) {
1513
+ // currentTarget is always defined inside an event listener
1514
+ var currentTarget = eventCurrentTargetGetter.call(event);
1515
+ // If currentTarget is not an instance of a native shadow root then we're dealing with a
1516
+ // host element whose synthetic shadow root must be accessed via getShadowRoot().
1517
+ if (!isInstanceOfNativeShadowRoot(currentTarget)) {
1518
+ currentTarget = getShadowRoot(currentTarget);
1519
+ }
1520
+ var actualTarget = getActualTarget(event);
1521
+ if (shouldInvokeListener(event, actualTarget, currentTarget)) {
1522
+ listener.call(currentTarget, event);
1523
+ }
1524
+ };
1525
+ shadowRootWrappedListener.placement = 1 /* SHADOW_ROOT_LISTENER */ ;
1526
+ shadowRootEventListenerMap.set(listener, shadowRootWrappedListener);
1527
+ }
1528
+ return shadowRootWrappedListener;
1622
1529
  }
1623
- // Keep searching up the host tree until we find an element that is within the immediate shadow root
1624
- var findAncestorHostInImmediateShadowRoot = function(rootNode, targetRootNode) {
1625
- var host;
1626
- while(!isUndefined(host = rootNode.host)){
1627
- var thisRootNode = host.getRootNode();
1628
- if (thisRootNode === targetRootNode) {
1629
- return host;
1530
+ var customElementEventListenerMap = new WeakMap();
1531
+ function getWrappedCustomElementListener(listener) {
1532
+ if (!isFunction(listener)) {
1533
+ throw new TypeError(); // avoiding problems with non-valid listeners
1534
+ }
1535
+ var customElementWrappedListener = customElementEventListenerMap.get(listener);
1536
+ if (isUndefined(customElementWrappedListener)) {
1537
+ customElementWrappedListener = function customElementWrappedListener(event) {
1538
+ // currentTarget is always defined inside an event listener
1539
+ var currentTarget = eventCurrentTargetGetter.call(event);
1540
+ var actualTarget = getActualTarget(event);
1541
+ if (shouldInvokeListener(event, actualTarget, currentTarget)) {
1542
+ listener.call(currentTarget, event);
1543
+ }
1544
+ };
1545
+ customElementWrappedListener.placement = 0 /* CUSTOM_ELEMENT_LISTENER */ ;
1546
+ customElementEventListenerMap.set(listener, customElementWrappedListener);
1547
+ }
1548
+ return customElementWrappedListener;
1549
+ }
1550
+ function domListener(evt) {
1551
+ var invokeListenersByPlacement = function invokeListenersByPlacement(placement) {
1552
+ forEach.call(bookkeeping, function(listener) {
1553
+ if (isFalse(immediatePropagationStopped) && listener.placement === placement) {
1554
+ // making sure that the listener was not removed from the original listener queue
1555
+ if (ArrayIndexOf.call(listeners, listener) !== -1) {
1556
+ // all handlers on the custom element should be called with undefined 'this'
1557
+ listener.call(undefined, evt);
1558
+ }
1559
+ }
1560
+ });
1561
+ };
1562
+ var immediatePropagationStopped = false;
1563
+ var propagationStopped = false;
1564
+ var type = evt.type, stopImmediatePropagation = evt.stopImmediatePropagation, stopPropagation = evt.stopPropagation;
1565
+ // currentTarget is always defined
1566
+ var currentTarget = eventCurrentTargetGetter.call(evt);
1567
+ var listenerMap = getEventMap(currentTarget);
1568
+ var listeners = listenerMap[type]; // it must have listeners at this point
1569
+ defineProperty(evt, "stopImmediatePropagation", {
1570
+ value: function value() {
1571
+ immediatePropagationStopped = true;
1572
+ stopImmediatePropagation.call(evt);
1573
+ },
1574
+ writable: true,
1575
+ enumerable: true,
1576
+ configurable: true
1577
+ });
1578
+ defineProperty(evt, "stopPropagation", {
1579
+ value: function value() {
1580
+ propagationStopped = true;
1581
+ stopPropagation.call(evt);
1582
+ },
1583
+ writable: true,
1584
+ enumerable: true,
1585
+ configurable: true
1586
+ });
1587
+ // in case a listener adds or removes other listeners during invocation
1588
+ var bookkeeping = ArraySlice.call(listeners);
1589
+ eventToContextMap.set(evt, 1 /* SHADOW_ROOT_LISTENER */ );
1590
+ invokeListenersByPlacement(1 /* SHADOW_ROOT_LISTENER */ );
1591
+ if (isFalse(immediatePropagationStopped) && isFalse(propagationStopped)) {
1592
+ // doing the second iteration only if the first one didn't interrupt the event propagation
1593
+ eventToContextMap.set(evt, 0 /* CUSTOM_ELEMENT_LISTENER */ );
1594
+ invokeListenersByPlacement(0 /* CUSTOM_ELEMENT_LISTENER */ );
1595
+ }
1596
+ eventToContextMap.set(evt, 2 /* UNKNOWN_LISTENER */ );
1597
+ }
1598
+ function attachDOMListener(elm, type, wrappedListener) {
1599
+ var listenerMap = getEventMap(elm);
1600
+ var cmpEventHandlers = listenerMap[type];
1601
+ if (isUndefined(cmpEventHandlers)) {
1602
+ cmpEventHandlers = listenerMap[type] = [];
1603
+ }
1604
+ // Prevent identical listeners from subscribing to the same event type.
1605
+ // TODO [#1824]: Options will also play a factor when we introduce support for them (#1824).
1606
+ if (ArrayIndexOf.call(cmpEventHandlers, wrappedListener) !== -1) {
1607
+ return;
1608
+ }
1609
+ // only add to DOM if there is no other listener on the same placement yet
1610
+ if (cmpEventHandlers.length === 0) {
1611
+ // super.addEventListener() - this will not work on
1612
+ addEventListener.call(elm, type, domListener);
1613
+ }
1614
+ ArrayPush.call(cmpEventHandlers, wrappedListener);
1615
+ }
1616
+ function detachDOMListener(elm, type, wrappedListener) {
1617
+ var listenerMap = getEventMap(elm);
1618
+ var p;
1619
+ var listeners;
1620
+ if (!isUndefined(listeners = listenerMap[type]) && (p = ArrayIndexOf.call(listeners, wrappedListener)) !== -1) {
1621
+ ArraySplice.call(listeners, p, 1);
1622
+ // only remove from DOM if there is no other listener on the same placement
1623
+ if (listeners.length === 0) {
1624
+ removeEventListener.call(elm, type, domListener);
1630
1625
  }
1631
- rootNode = thisRootNode;
1632
1626
  }
1633
- };
1634
- function fauxElementsFromPoint(context, doc, left, top) {
1635
- var elements = elementsFromPoint.call(doc, left, top);
1636
- var result = [];
1637
- var rootNodes = getAllRootNodes(context);
1638
- // Filter the elements array to only include those elements that are in this shadow root or in one of its
1639
- // ancestor roots. This matches Chrome and Safari's implementation (but not Firefox's, which only includes
1640
- // elements in the immediate shadow root: https://crbug.com/1207863#c4).
1641
- if (!isNull(elements)) {
1642
- // can be null in IE https://developer.mozilla.org/en-US/docs/Web/API/Document/elementsFromPoint#browser_compatibility
1643
- for(var i = 0; i < elements.length; i++){
1644
- var element = elements[i];
1645
- if (isSyntheticSlotElement(element)) {
1646
- continue;
1647
- }
1648
- var elementRootNode = element.getRootNode();
1649
- if (ArrayIndexOf.call(rootNodes, elementRootNode) !== -1) {
1650
- ArrayPush.call(result, element);
1651
- continue;
1652
- }
1653
- // In cases where the host element is not visible but its shadow descendants are, then
1654
- // we may get the shadow descendant instead of the host element here. (The
1655
- // browser doesn't know the difference in synthetic shadow DOM.)
1656
- // In native shadow DOM, however, elementsFromPoint would return the host but not
1657
- // the child. So we need to detect if this shadow element's host is accessible from
1658
- // the context's shadow root. Note we also need to be careful not to add the host
1659
- // multiple times.
1660
- var ancestorHost = findAncestorHostInImmediateShadowRoot(elementRootNode, rootNodes[0]);
1661
- if (!isUndefined(ancestorHost) && ArrayIndexOf.call(elements, ancestorHost) === -1 && ArrayIndexOf.call(result, ancestorHost) === -1) {
1662
- ArrayPush.call(result, ancestorHost);
1663
- }
1627
+ }
1628
+ function addCustomElementEventListener(type, listener, _options) {
1629
+ if (process.env.NODE_ENV !== "production") {
1630
+ if (!isFunction(listener)) {
1631
+ throw new TypeError("Invalid second argument for Element.addEventListener() in ".concat(toString(this), ' for event "').concat(type, '". Expected an EventListener but received ').concat(listener, "."));
1632
+ }
1633
+ }
1634
+ // TODO [#1824]: Lift this restriction on the option parameter
1635
+ if (isFunction(listener)) {
1636
+ var wrappedListener = getWrappedCustomElementListener(listener);
1637
+ attachDOMListener(this, type, wrappedListener);
1638
+ }
1639
+ }
1640
+ function removeCustomElementEventListener(type, listener, _options) {
1641
+ // TODO [#1824]: Lift this restriction on the option parameter
1642
+ if (isFunction(listener)) {
1643
+ var wrappedListener = getWrappedCustomElementListener(listener);
1644
+ detachDOMListener(this, type, wrappedListener);
1645
+ }
1646
+ }
1647
+ function addShadowRootEventListener(sr, type, listener, _options) {
1648
+ if (process.env.NODE_ENV !== "production") {
1649
+ if (!isFunction(listener)) {
1650
+ throw new TypeError("Invalid second argument for ShadowRoot.addEventListener() in ".concat(toString(sr), ' for event "').concat(type, '". Expected an EventListener but received ').concat(listener, "."));
1664
1651
  }
1665
1652
  }
1666
- return result;
1653
+ // TODO [#1824]: Lift this restriction on the option parameter
1654
+ if (isFunction(listener)) {
1655
+ var elm = getHost(sr);
1656
+ var wrappedListener = getWrappedShadowRootListener(listener);
1657
+ attachDOMListener(elm, type, wrappedListener);
1658
+ }
1659
+ }
1660
+ function removeShadowRootEventListener(sr, type, listener, _options) {
1661
+ // TODO [#1824]: Lift this restriction on the option parameter
1662
+ if (isFunction(listener)) {
1663
+ var elm = getHost(sr);
1664
+ var wrappedListener = getWrappedShadowRootListener(listener);
1665
+ detachDOMListener(elm, type, wrappedListener);
1666
+ }
1667
1667
  }
1668
1668
  /*
1669
1669
  * Copyright (c) 2018, salesforce.com, inc.
@@ -3748,52 +3748,236 @@
3748
3748
  enumerable: true,
3749
3749
  configurable: true
3750
3750
  }
3751
- }); // The following APIs are used directly by Jest internally so we avoid patching them during testing.
3752
- if (process.env.NODE_ENV !== "test") {
3753
- defineProperties(Element.prototype, {
3754
- getElementsByClassName: {
3755
- value: function value() {
3756
- var elements = arrayFromCollection(getElementsByClassName$1.apply(this, ArraySlice.call(arguments)));
3757
- if (!runtimeFlags.ENABLE_HTML_COLLECTIONS_PATCH) {
3758
- return createStaticHTMLCollection(getNonPatchedFilteredArrayOfNodes(this, elements));
3759
- }
3760
- var filteredResults = getFilteredArrayOfNodes(this, elements, 1);
3761
- return createStaticHTMLCollection(filteredResults);
3762
- },
3763
- writable: true,
3764
- enumerable: true,
3765
- configurable: true
3766
- },
3767
- getElementsByTagName: {
3768
- value: function value() {
3769
- var elements = arrayFromCollection(getElementsByTagName$1.apply(this, ArraySlice.call(arguments)));
3770
- if (!runtimeFlags.ENABLE_HTML_COLLECTIONS_PATCH) {
3771
- return createStaticHTMLCollection(getNonPatchedFilteredArrayOfNodes(this, elements));
3772
- }
3773
- var filteredResults = getFilteredArrayOfNodes(this, elements, 1);
3774
- return createStaticHTMLCollection(filteredResults);
3775
- },
3776
- writable: true,
3777
- enumerable: true,
3778
- configurable: true
3779
- },
3780
- getElementsByTagNameNS: {
3781
- value: function value() {
3782
- var elements = arrayFromCollection(getElementsByTagNameNS$1.apply(this, ArraySlice.call(arguments)));
3783
- if (!runtimeFlags.ENABLE_HTML_COLLECTIONS_PATCH) {
3784
- return createStaticHTMLCollection(getNonPatchedFilteredArrayOfNodes(this, elements));
3751
+ }); // The following APIs are used directly by Jest internally so we avoid patching them during testing.
3752
+ if (process.env.NODE_ENV !== "test") {
3753
+ defineProperties(Element.prototype, {
3754
+ getElementsByClassName: {
3755
+ value: function value() {
3756
+ var elements = arrayFromCollection(getElementsByClassName$1.apply(this, ArraySlice.call(arguments)));
3757
+ if (!runtimeFlags.ENABLE_HTML_COLLECTIONS_PATCH) {
3758
+ return createStaticHTMLCollection(getNonPatchedFilteredArrayOfNodes(this, elements));
3759
+ }
3760
+ var filteredResults = getFilteredArrayOfNodes(this, elements, 1);
3761
+ return createStaticHTMLCollection(filteredResults);
3762
+ },
3763
+ writable: true,
3764
+ enumerable: true,
3765
+ configurable: true
3766
+ },
3767
+ getElementsByTagName: {
3768
+ value: function value() {
3769
+ var elements = arrayFromCollection(getElementsByTagName$1.apply(this, ArraySlice.call(arguments)));
3770
+ if (!runtimeFlags.ENABLE_HTML_COLLECTIONS_PATCH) {
3771
+ return createStaticHTMLCollection(getNonPatchedFilteredArrayOfNodes(this, elements));
3772
+ }
3773
+ var filteredResults = getFilteredArrayOfNodes(this, elements, 1);
3774
+ return createStaticHTMLCollection(filteredResults);
3775
+ },
3776
+ writable: true,
3777
+ enumerable: true,
3778
+ configurable: true
3779
+ },
3780
+ getElementsByTagNameNS: {
3781
+ value: function value() {
3782
+ var elements = arrayFromCollection(getElementsByTagNameNS$1.apply(this, ArraySlice.call(arguments)));
3783
+ if (!runtimeFlags.ENABLE_HTML_COLLECTIONS_PATCH) {
3784
+ return createStaticHTMLCollection(getNonPatchedFilteredArrayOfNodes(this, elements));
3785
+ }
3786
+ var filteredResults = getFilteredArrayOfNodes(this, elements, 1);
3787
+ return createStaticHTMLCollection(filteredResults);
3788
+ },
3789
+ writable: true,
3790
+ enumerable: true,
3791
+ configurable: true
3792
+ }
3793
+ });
3794
+ } // IE11 extra patches for wrong prototypes
3795
+ if (hasOwnProperty.call(HTMLElement.prototype, "getElementsByClassName")) {
3796
+ defineProperty(HTMLElement.prototype, "getElementsByClassName", getOwnPropertyDescriptor(Element.prototype, "getElementsByClassName"));
3797
+ }
3798
+ /*
3799
+ * Copyright (c) 2018, salesforce.com, inc.
3800
+ * All rights reserved.
3801
+ * SPDX-License-Identifier: MIT
3802
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3803
+ */ function getElementComputedStyle(element) {
3804
+ var win = getOwnerWindow(element);
3805
+ return windowGetComputedStyle.call(win, element);
3806
+ }
3807
+ function getWindowSelection(node) {
3808
+ var win = getOwnerWindow(node);
3809
+ return windowGetSelection.call(win);
3810
+ }
3811
+ function nodeIsBeingRendered(nodeComputedStyle) {
3812
+ return nodeComputedStyle.visibility === "visible" && nodeComputedStyle.display !== "none";
3813
+ }
3814
+ function getSelectionState(element) {
3815
+ var win = getOwnerWindow(element);
3816
+ var selection = getWindowSelection(element);
3817
+ if (selection === null) {
3818
+ return null;
3819
+ }
3820
+ var ranges = [];
3821
+ for(var i = 0; i < selection.rangeCount; i++){
3822
+ ranges.push(selection.getRangeAt(i));
3823
+ }
3824
+ var state = {
3825
+ element: element,
3826
+ onselect: win.onselect,
3827
+ onselectstart: win.onselectstart,
3828
+ onselectionchange: win.onselectionchange,
3829
+ ranges: ranges
3830
+ };
3831
+ win.onselect = null;
3832
+ win.onselectstart = null;
3833
+ win.onselectionchange = null;
3834
+ return state;
3835
+ }
3836
+ function restoreSelectionState(state) {
3837
+ if (state === null) {
3838
+ return;
3839
+ }
3840
+ var element = state.element, onselect = state.onselect, onselectstart = state.onselectstart, onselectionchange = state.onselectionchange, ranges = state.ranges;
3841
+ var win = getOwnerWindow(element);
3842
+ var selection = getWindowSelection(element);
3843
+ selection.removeAllRanges();
3844
+ for(var i = 0; i < ranges.length; i++){
3845
+ selection.addRange(ranges[i]);
3846
+ }
3847
+ win.onselect = onselect;
3848
+ win.onselectstart = onselectstart;
3849
+ win.onselectionchange = onselectionchange;
3850
+ }
3851
+ /**
3852
+ * Gets the "innerText" of a text node using the Selection API
3853
+ *
3854
+ * NOTE: For performance reasons, since this function will be called multiple times while calculating the innerText of
3855
+ * an element, it does not restore the current selection.
3856
+ */ function getTextNodeInnerText(textNode) {
3857
+ var selection = getWindowSelection(textNode);
3858
+ if (selection === null) {
3859
+ return textNode.textContent || "";
3860
+ }
3861
+ var range = document.createRange();
3862
+ range.selectNodeContents(textNode);
3863
+ var domRect = range.getBoundingClientRect();
3864
+ if (domRect.height <= 0 || domRect.width <= 0) {
3865
+ // the text node is not rendered
3866
+ return "";
3867
+ }
3868
+ // Needed to remove non rendered characters from the text node.
3869
+ selection.removeAllRanges();
3870
+ selection.addRange(range);
3871
+ var selectionText = selection.toString();
3872
+ // The textNode is visible, but it may not be selectable. When the text is not selectable,
3873
+ // textContent is the nearest approximation to innerText.
3874
+ return selectionText ? selectionText : textNode.textContent || "";
3875
+ }
3876
+ var nodeIsElement = function(node) {
3877
+ return node.nodeType === ELEMENT_NODE;
3878
+ };
3879
+ var nodeIsText = function(node) {
3880
+ return node.nodeType === TEXT_NODE;
3881
+ };
3882
+ /**
3883
+ * Spec: https://html.spec.whatwg.org/multipage/dom.html#inner-text-collection-steps
3884
+ * One spec implementation: https://github.com/servo/servo/blob/721271dcd3c20db5ca8cf146e2b5907647afb4d6/components/layout/query.rs#L1132
3885
+ */ function innerTextCollectionSteps(node) {
3886
+ var items = [];
3887
+ if (nodeIsElement(node)) {
3888
+ var tagName = node.tagName;
3889
+ var computedStyle = getElementComputedStyle(node);
3890
+ if (tagName === "OPTION") {
3891
+ // For options, is hard to get the "rendered" text, let's use the original getter.
3892
+ return [
3893
+ 1,
3894
+ innerTextGetter.call(node),
3895
+ 1
3896
+ ];
3897
+ } else if (tagName === "TEXTAREA") {
3898
+ return [];
3899
+ } else {
3900
+ var childNodes = node.childNodes;
3901
+ for(var i = 0, n = childNodes.length; i < n; i++){
3902
+ ArrayPush.apply(items, innerTextCollectionSteps(childNodes[i]));
3903
+ }
3904
+ }
3905
+ if (!nodeIsBeingRendered(computedStyle)) {
3906
+ if (tagName === "SELECT" || tagName === "DATALIST") {
3907
+ // the select is either: .visibility != 'visible' or .display === hidden, therefore this select should
3908
+ // not display any value.
3909
+ return [];
3910
+ }
3911
+ return items;
3912
+ }
3913
+ if (tagName === "BR") {
3914
+ items.push("\n" /* line feed */ );
3915
+ }
3916
+ var display = computedStyle.display;
3917
+ if (display === "table-cell") {
3918
+ // omitting case: and node's CSS box is not the last 'table-cell' box of its enclosing 'table-row' box
3919
+ items.push(" " /* tab */ );
3920
+ }
3921
+ if (display === "table-row") {
3922
+ // omitting case: and node's CSS box is not the last 'table-row' box of the nearest ancestor 'table' box
3923
+ items.push("\n" /* line feed */ );
3924
+ }
3925
+ if (tagName === "P") {
3926
+ items.unshift(2);
3927
+ items.push(2);
3928
+ }
3929
+ if (display === "block" || display === "table-caption" || display === "flex" || display === "table") {
3930
+ items.unshift(1);
3931
+ items.push(1);
3932
+ }
3933
+ } else if (nodeIsText(node)) {
3934
+ items.push(getTextNodeInnerText(node));
3935
+ }
3936
+ return items;
3937
+ }
3938
+ /**
3939
+ * InnerText getter spec: https://html.spec.whatwg.org/multipage/dom.html#the-innertext-idl-attribute
3940
+ *
3941
+ * One spec implementation: https://github.com/servo/servo/blob/721271dcd3c20db5ca8cf146e2b5907647afb4d6/components/layout/query.rs#L1087
3942
+ */ function getInnerText(element) {
3943
+ var thisComputedStyle = getElementComputedStyle(element);
3944
+ if (!nodeIsBeingRendered(thisComputedStyle)) {
3945
+ return getTextContent(element) || "";
3946
+ }
3947
+ var selectionState = getSelectionState(element);
3948
+ var results = [];
3949
+ var childNodes = element.childNodes;
3950
+ for(var i = 0, n = childNodes.length; i < n; i++){
3951
+ ArrayPush.apply(results, innerTextCollectionSteps(childNodes[i]));
3952
+ }
3953
+ restoreSelectionState(selectionState);
3954
+ var elementInnerText = "";
3955
+ var maxReqLineBreakCount = 0;
3956
+ for(var i1 = 0, n1 = results.length; i1 < n1; i1++){
3957
+ var item = results[i1];
3958
+ if (typeof item === "string") {
3959
+ if (maxReqLineBreakCount > 0) {
3960
+ for(var j = 0; j < maxReqLineBreakCount; j++){
3961
+ elementInnerText += "\n";
3785
3962
  }
3786
- var filteredResults = getFilteredArrayOfNodes(this, elements, 1);
3787
- return createStaticHTMLCollection(filteredResults);
3788
- },
3789
- writable: true,
3790
- enumerable: true,
3791
- configurable: true
3963
+ maxReqLineBreakCount = 0;
3964
+ }
3965
+ if (item.length > 0) {
3966
+ elementInnerText += item;
3967
+ }
3968
+ } else {
3969
+ if (elementInnerText.length == 0) {
3970
+ continue;
3971
+ }
3972
+ // Store the count if it's the max of this run,
3973
+ // but it may be ignored if no text item is found afterwards,
3974
+ // which means that these are consecutive line breaks at the end.
3975
+ if (item > maxReqLineBreakCount) {
3976
+ maxReqLineBreakCount = item;
3977
+ }
3792
3978
  }
3793
- });
3794
- } // IE11 extra patches for wrong prototypes
3795
- if (hasOwnProperty.call(HTMLElement.prototype, "getElementsByClassName")) {
3796
- defineProperty(HTMLElement.prototype, "getElementsByClassName", getOwnPropertyDescriptor(Element.prototype, "getElementsByClassName"));
3979
+ }
3980
+ return elementInnerText;
3797
3981
  }
3798
3982
  /*
3799
3983
  * Copyright (c) 2018, salesforce.com, inc.
@@ -4119,190 +4303,6 @@
4119
4303
  function ignoreFocusIn(elm) {
4120
4304
  removeEventListener.call(elm, "focusin", skipShadowHandler, true);
4121
4305
  }
4122
- /*
4123
- * Copyright (c) 2018, salesforce.com, inc.
4124
- * All rights reserved.
4125
- * SPDX-License-Identifier: MIT
4126
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4127
- */ function getElementComputedStyle(element) {
4128
- var win = getOwnerWindow(element);
4129
- return windowGetComputedStyle.call(win, element);
4130
- }
4131
- function getWindowSelection(node) {
4132
- var win = getOwnerWindow(node);
4133
- return windowGetSelection.call(win);
4134
- }
4135
- function nodeIsBeingRendered(nodeComputedStyle) {
4136
- return nodeComputedStyle.visibility === "visible" && nodeComputedStyle.display !== "none";
4137
- }
4138
- function getSelectionState(element) {
4139
- var win = getOwnerWindow(element);
4140
- var selection = getWindowSelection(element);
4141
- if (selection === null) {
4142
- return null;
4143
- }
4144
- var ranges = [];
4145
- for(var i = 0; i < selection.rangeCount; i++){
4146
- ranges.push(selection.getRangeAt(i));
4147
- }
4148
- var state = {
4149
- element: element,
4150
- onselect: win.onselect,
4151
- onselectstart: win.onselectstart,
4152
- onselectionchange: win.onselectionchange,
4153
- ranges: ranges
4154
- };
4155
- win.onselect = null;
4156
- win.onselectstart = null;
4157
- win.onselectionchange = null;
4158
- return state;
4159
- }
4160
- function restoreSelectionState(state) {
4161
- if (state === null) {
4162
- return;
4163
- }
4164
- var element = state.element, onselect = state.onselect, onselectstart = state.onselectstart, onselectionchange = state.onselectionchange, ranges = state.ranges;
4165
- var win = getOwnerWindow(element);
4166
- var selection = getWindowSelection(element);
4167
- selection.removeAllRanges();
4168
- for(var i = 0; i < ranges.length; i++){
4169
- selection.addRange(ranges[i]);
4170
- }
4171
- win.onselect = onselect;
4172
- win.onselectstart = onselectstart;
4173
- win.onselectionchange = onselectionchange;
4174
- }
4175
- /**
4176
- * Gets the "innerText" of a text node using the Selection API
4177
- *
4178
- * NOTE: For performance reasons, since this function will be called multiple times while calculating the innerText of
4179
- * an element, it does not restore the current selection.
4180
- */ function getTextNodeInnerText(textNode) {
4181
- var selection = getWindowSelection(textNode);
4182
- if (selection === null) {
4183
- return textNode.textContent || "";
4184
- }
4185
- var range = document.createRange();
4186
- range.selectNodeContents(textNode);
4187
- var domRect = range.getBoundingClientRect();
4188
- if (domRect.height <= 0 || domRect.width <= 0) {
4189
- // the text node is not rendered
4190
- return "";
4191
- }
4192
- // Needed to remove non rendered characters from the text node.
4193
- selection.removeAllRanges();
4194
- selection.addRange(range);
4195
- var selectionText = selection.toString();
4196
- // The textNode is visible, but it may not be selectable. When the text is not selectable,
4197
- // textContent is the nearest approximation to innerText.
4198
- return selectionText ? selectionText : textNode.textContent || "";
4199
- }
4200
- var nodeIsElement = function(node) {
4201
- return node.nodeType === ELEMENT_NODE;
4202
- };
4203
- var nodeIsText = function(node) {
4204
- return node.nodeType === TEXT_NODE;
4205
- };
4206
- /**
4207
- * Spec: https://html.spec.whatwg.org/multipage/dom.html#inner-text-collection-steps
4208
- * One spec implementation: https://github.com/servo/servo/blob/721271dcd3c20db5ca8cf146e2b5907647afb4d6/components/layout/query.rs#L1132
4209
- */ function innerTextCollectionSteps(node) {
4210
- var items = [];
4211
- if (nodeIsElement(node)) {
4212
- var tagName = node.tagName;
4213
- var computedStyle = getElementComputedStyle(node);
4214
- if (tagName === "OPTION") {
4215
- // For options, is hard to get the "rendered" text, let's use the original getter.
4216
- return [
4217
- 1,
4218
- innerTextGetter.call(node),
4219
- 1
4220
- ];
4221
- } else if (tagName === "TEXTAREA") {
4222
- return [];
4223
- } else {
4224
- var childNodes = node.childNodes;
4225
- for(var i = 0, n = childNodes.length; i < n; i++){
4226
- ArrayPush.apply(items, innerTextCollectionSteps(childNodes[i]));
4227
- }
4228
- }
4229
- if (!nodeIsBeingRendered(computedStyle)) {
4230
- if (tagName === "SELECT" || tagName === "DATALIST") {
4231
- // the select is either: .visibility != 'visible' or .display === hidden, therefore this select should
4232
- // not display any value.
4233
- return [];
4234
- }
4235
- return items;
4236
- }
4237
- if (tagName === "BR") {
4238
- items.push("\n" /* line feed */ );
4239
- }
4240
- var display = computedStyle.display;
4241
- if (display === "table-cell") {
4242
- // omitting case: and node's CSS box is not the last 'table-cell' box of its enclosing 'table-row' box
4243
- items.push(" " /* tab */ );
4244
- }
4245
- if (display === "table-row") {
4246
- // omitting case: and node's CSS box is not the last 'table-row' box of the nearest ancestor 'table' box
4247
- items.push("\n" /* line feed */ );
4248
- }
4249
- if (tagName === "P") {
4250
- items.unshift(2);
4251
- items.push(2);
4252
- }
4253
- if (display === "block" || display === "table-caption" || display === "flex" || display === "table") {
4254
- items.unshift(1);
4255
- items.push(1);
4256
- }
4257
- } else if (nodeIsText(node)) {
4258
- items.push(getTextNodeInnerText(node));
4259
- }
4260
- return items;
4261
- }
4262
- /**
4263
- * InnerText getter spec: https://html.spec.whatwg.org/multipage/dom.html#the-innertext-idl-attribute
4264
- *
4265
- * One spec implementation: https://github.com/servo/servo/blob/721271dcd3c20db5ca8cf146e2b5907647afb4d6/components/layout/query.rs#L1087
4266
- */ function getInnerText(element) {
4267
- var thisComputedStyle = getElementComputedStyle(element);
4268
- if (!nodeIsBeingRendered(thisComputedStyle)) {
4269
- return getTextContent(element) || "";
4270
- }
4271
- var selectionState = getSelectionState(element);
4272
- var results = [];
4273
- var childNodes = element.childNodes;
4274
- for(var i = 0, n = childNodes.length; i < n; i++){
4275
- ArrayPush.apply(results, innerTextCollectionSteps(childNodes[i]));
4276
- }
4277
- restoreSelectionState(selectionState);
4278
- var elementInnerText = "";
4279
- var maxReqLineBreakCount = 0;
4280
- for(var i1 = 0, n1 = results.length; i1 < n1; i1++){
4281
- var item = results[i1];
4282
- if (typeof item === "string") {
4283
- if (maxReqLineBreakCount > 0) {
4284
- for(var j = 0; j < maxReqLineBreakCount; j++){
4285
- elementInnerText += "\n";
4286
- }
4287
- maxReqLineBreakCount = 0;
4288
- }
4289
- if (item.length > 0) {
4290
- elementInnerText += item;
4291
- }
4292
- } else {
4293
- if (elementInnerText.length == 0) {
4294
- continue;
4295
- }
4296
- // Store the count if it's the max of this run,
4297
- // but it may be ignored if no text item is found afterwards,
4298
- // which means that these are consecutive line breaks at the end.
4299
- if (item > maxReqLineBreakCount) {
4300
- maxReqLineBreakCount = item;
4301
- }
4302
- }
4303
- }
4304
- return elementInnerText;
4305
- }
4306
4306
  /*
4307
4307
  * Copyright (c) 2018, salesforce.com, inc.
4308
4308
  * All rights reserved.
@@ -4637,6 +4637,6 @@
4637
4637
  return this[DomManualPrivateKey];
4638
4638
  },
4639
4639
  configurable: true
4640
- }); /** version: 2.13.0 */
4640
+ }); /** version: 2.13.1 */
4641
4641
 
4642
4642
  })();