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
@@ -101,7 +101,7 @@
101
101
  var KEY__SHADOW_TOKEN = "$shadowToken$";
102
102
  var KEY__SHADOW_TOKEN_PRIVATE = "$$ShadowTokenKey$$";
103
103
  var KEY__SYNTHETIC_MODE = "$$lwc-synthetic-mode";
104
- /** version: 2.13.0 */ /*
104
+ /** version: 2.13.3 */ /*
105
105
  * Copyright (c) 2018, salesforce.com, inc.
106
106
  * All rights reserved.
107
107
  * SPDX-License-Identifier: MIT
@@ -345,225 +345,6 @@
345
345
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
346
346
  */ var eventTargetPrototype = typeof EventTarget !== "undefined" ? EventTarget.prototype : _Node.prototype;
347
347
  var addEventListener = eventTargetPrototype.addEventListener, dispatchEvent = eventTargetPrototype.dispatchEvent, removeEventListener = eventTargetPrototype.removeEventListener;
348
- /*
349
- * Copyright (c) 2018, salesforce.com, inc.
350
- * All rights reserved.
351
- * SPDX-License-Identifier: MIT
352
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
353
- */ var EventListenerMap = new WeakMap();
354
- var ComposedPathMap = new WeakMap();
355
- function isEventListenerOrEventListenerObject(fnOrObj) {
356
- return isFunction(fnOrObj) || isObject(fnOrObj) && !isNull(fnOrObj) && isFunction(fnOrObj.handleEvent);
357
- }
358
- function shouldInvokeListener(event, target, currentTarget) {
359
- // Subsequent logic assumes that `currentTarget` must be contained in the composed path for the listener to be
360
- // invoked, but this is not always the case. `composedPath()` will sometimes return an empty array, even when the
361
- // listener should be invoked (e.g., a disconnected instance of EventTarget, an instance of XMLHttpRequest, etc).
362
- if (target === currentTarget) {
363
- return true;
364
- }
365
- var composedPath1 = ComposedPathMap.get(event);
366
- if (isUndefined(composedPath1)) {
367
- composedPath1 = event.composedPath();
368
- ComposedPathMap.set(event, composedPath1);
369
- }
370
- return composedPath1.includes(currentTarget);
371
- }
372
- function getEventListenerWrapper(fnOrObj) {
373
- if (!isEventListenerOrEventListenerObject(fnOrObj)) {
374
- return fnOrObj;
375
- }
376
- var wrapperFn = EventListenerMap.get(fnOrObj);
377
- if (isUndefined(wrapperFn)) {
378
- wrapperFn = function wrapperFn(event) {
379
- // This function is invoked from an event listener and currentTarget is always defined.
380
- var currentTarget = eventCurrentTargetGetter.call(event);
381
- var actualTarget = getActualTarget(event);
382
- if (!shouldInvokeListener(event, actualTarget, currentTarget)) {
383
- return;
384
- }
385
- return isFunction(fnOrObj) ? fnOrObj.call(this, event) : fnOrObj.handleEvent && fnOrObj.handleEvent(event);
386
- };
387
- EventListenerMap.set(fnOrObj, wrapperFn);
388
- }
389
- return wrapperFn;
390
- }
391
- /*
392
- * Copyright (c) 2018, salesforce.com, inc.
393
- * All rights reserved.
394
- * SPDX-License-Identifier: MIT
395
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
396
- */ var eventToContextMap = new WeakMap();
397
- var customElementToWrappedListeners = new WeakMap();
398
- function getEventMap(elm) {
399
- var listenerInfo = customElementToWrappedListeners.get(elm);
400
- if (isUndefined(listenerInfo)) {
401
- listenerInfo = create(null);
402
- customElementToWrappedListeners.set(elm, listenerInfo);
403
- }
404
- return listenerInfo;
405
- }
406
- /**
407
- * Events dispatched on shadow roots actually end up being dispatched on their hosts. This means that the event.target
408
- * property of events dispatched on shadow roots always resolve to their host. This function understands this
409
- * abstraction and properly returns a reference to the shadow root when appropriate.
410
- */ function getActualTarget(event) {
411
- var _a;
412
- return (_a = eventToShadowRootMap.get(event)) !== null && _a !== void 0 ? _a : eventTargetGetter.call(event);
413
- }
414
- var shadowRootEventListenerMap = new WeakMap();
415
- function getWrappedShadowRootListener(listener) {
416
- if (!isFunction(listener)) {
417
- throw new TypeError(); // avoiding problems with non-valid listeners
418
- }
419
- var shadowRootWrappedListener = shadowRootEventListenerMap.get(listener);
420
- if (isUndefined(shadowRootWrappedListener)) {
421
- shadowRootWrappedListener = function shadowRootWrappedListener(event) {
422
- // currentTarget is always defined inside an event listener
423
- var currentTarget = eventCurrentTargetGetter.call(event);
424
- // If currentTarget is not an instance of a native shadow root then we're dealing with a
425
- // host element whose synthetic shadow root must be accessed via getShadowRoot().
426
- if (!isInstanceOfNativeShadowRoot(currentTarget)) {
427
- currentTarget = getShadowRoot(currentTarget);
428
- }
429
- var actualTarget = getActualTarget(event);
430
- if (shouldInvokeListener(event, actualTarget, currentTarget)) {
431
- listener.call(currentTarget, event);
432
- }
433
- };
434
- shadowRootWrappedListener.placement = 1 /* SHADOW_ROOT_LISTENER */ ;
435
- shadowRootEventListenerMap.set(listener, shadowRootWrappedListener);
436
- }
437
- return shadowRootWrappedListener;
438
- }
439
- var customElementEventListenerMap = new WeakMap();
440
- function getWrappedCustomElementListener(listener) {
441
- if (!isFunction(listener)) {
442
- throw new TypeError(); // avoiding problems with non-valid listeners
443
- }
444
- var customElementWrappedListener = customElementEventListenerMap.get(listener);
445
- if (isUndefined(customElementWrappedListener)) {
446
- customElementWrappedListener = function customElementWrappedListener(event) {
447
- // currentTarget is always defined inside an event listener
448
- var currentTarget = eventCurrentTargetGetter.call(event);
449
- var actualTarget = getActualTarget(event);
450
- if (shouldInvokeListener(event, actualTarget, currentTarget)) {
451
- listener.call(currentTarget, event);
452
- }
453
- };
454
- customElementWrappedListener.placement = 0 /* CUSTOM_ELEMENT_LISTENER */ ;
455
- customElementEventListenerMap.set(listener, customElementWrappedListener);
456
- }
457
- return customElementWrappedListener;
458
- }
459
- function domListener(evt) {
460
- var invokeListenersByPlacement = function invokeListenersByPlacement(placement) {
461
- forEach.call(bookkeeping, function(listener) {
462
- if (isFalse(immediatePropagationStopped) && listener.placement === placement) {
463
- // making sure that the listener was not removed from the original listener queue
464
- if (ArrayIndexOf.call(listeners, listener) !== -1) {
465
- // all handlers on the custom element should be called with undefined 'this'
466
- listener.call(undefined, evt);
467
- }
468
- }
469
- });
470
- };
471
- var immediatePropagationStopped = false;
472
- var propagationStopped = false;
473
- var type = evt.type, stopImmediatePropagation = evt.stopImmediatePropagation, stopPropagation = evt.stopPropagation;
474
- // currentTarget is always defined
475
- var currentTarget = eventCurrentTargetGetter.call(evt);
476
- var listenerMap = getEventMap(currentTarget);
477
- var listeners = listenerMap[type]; // it must have listeners at this point
478
- defineProperty(evt, "stopImmediatePropagation", {
479
- value: function value() {
480
- immediatePropagationStopped = true;
481
- stopImmediatePropagation.call(evt);
482
- },
483
- writable: true,
484
- enumerable: true,
485
- configurable: true
486
- });
487
- defineProperty(evt, "stopPropagation", {
488
- value: function value() {
489
- propagationStopped = true;
490
- stopPropagation.call(evt);
491
- },
492
- writable: true,
493
- enumerable: true,
494
- configurable: true
495
- });
496
- // in case a listener adds or removes other listeners during invocation
497
- var bookkeeping = ArraySlice.call(listeners);
498
- eventToContextMap.set(evt, 1 /* SHADOW_ROOT_LISTENER */ );
499
- invokeListenersByPlacement(1 /* SHADOW_ROOT_LISTENER */ );
500
- if (isFalse(immediatePropagationStopped) && isFalse(propagationStopped)) {
501
- // doing the second iteration only if the first one didn't interrupt the event propagation
502
- eventToContextMap.set(evt, 0 /* CUSTOM_ELEMENT_LISTENER */ );
503
- invokeListenersByPlacement(0 /* CUSTOM_ELEMENT_LISTENER */ );
504
- }
505
- eventToContextMap.set(evt, 2 /* UNKNOWN_LISTENER */ );
506
- }
507
- function attachDOMListener(elm, type, wrappedListener) {
508
- var listenerMap = getEventMap(elm);
509
- var cmpEventHandlers = listenerMap[type];
510
- if (isUndefined(cmpEventHandlers)) {
511
- cmpEventHandlers = listenerMap[type] = [];
512
- }
513
- // Prevent identical listeners from subscribing to the same event type.
514
- // TODO [#1824]: Options will also play a factor when we introduce support for them (#1824).
515
- if (ArrayIndexOf.call(cmpEventHandlers, wrappedListener) !== -1) {
516
- return;
517
- }
518
- // only add to DOM if there is no other listener on the same placement yet
519
- if (cmpEventHandlers.length === 0) {
520
- // super.addEventListener() - this will not work on
521
- addEventListener.call(elm, type, domListener);
522
- }
523
- ArrayPush.call(cmpEventHandlers, wrappedListener);
524
- }
525
- function detachDOMListener(elm, type, wrappedListener) {
526
- var listenerMap = getEventMap(elm);
527
- var p;
528
- var listeners;
529
- if (!isUndefined(listeners = listenerMap[type]) && (p = ArrayIndexOf.call(listeners, wrappedListener)) !== -1) {
530
- ArraySplice.call(listeners, p, 1);
531
- // only remove from DOM if there is no other listener on the same placement
532
- if (listeners.length === 0) {
533
- removeEventListener.call(elm, type, domListener);
534
- }
535
- }
536
- }
537
- function addCustomElementEventListener(type, listener, _options) {
538
- // TODO [#1824]: Lift this restriction on the option parameter
539
- if (isFunction(listener)) {
540
- var wrappedListener = getWrappedCustomElementListener(listener);
541
- attachDOMListener(this, type, wrappedListener);
542
- }
543
- }
544
- function removeCustomElementEventListener(type, listener, _options) {
545
- // TODO [#1824]: Lift this restriction on the option parameter
546
- if (isFunction(listener)) {
547
- var wrappedListener = getWrappedCustomElementListener(listener);
548
- detachDOMListener(this, type, wrappedListener);
549
- }
550
- }
551
- function addShadowRootEventListener(sr, type, listener, _options) {
552
- // TODO [#1824]: Lift this restriction on the option parameter
553
- if (isFunction(listener)) {
554
- var elm = getHost(sr);
555
- var wrappedListener = getWrappedShadowRootListener(listener);
556
- attachDOMListener(elm, type, wrappedListener);
557
- }
558
- }
559
- function removeShadowRootEventListener(sr, type, listener, _options) {
560
- // TODO [#1824]: Lift this restriction on the option parameter
561
- if (isFunction(listener)) {
562
- var elm = getHost(sr);
563
- var wrappedListener = getWrappedShadowRootListener(listener);
564
- detachDOMListener(elm, type, wrappedListener);
565
- }
566
- }
567
348
  /*
568
349
  * Copyright (c) 2018, salesforce.com, inc.
569
350
  * All rights reserved.
@@ -809,44 +590,162 @@
809
590
  * All rights reserved.
810
591
  * SPDX-License-Identifier: MIT
811
592
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
812
- */ function getTextContent(node) {
813
- switch(node.nodeType){
814
- case ELEMENT_NODE:
815
- {
816
- var childNodes = getFilteredChildNodes(node);
817
- var content = "";
818
- for(var i = 0, len = childNodes.length; i < len; i += 1){
819
- var currentNode = childNodes[i];
820
- if (currentNode.nodeType !== COMMENT_NODE) {
821
- content += getTextContent(currentNode);
822
- }
823
- }
824
- return content;
825
- }
826
- default:
827
- return node.nodeValue;
593
+ */ function getInnerHTML(node) {
594
+ var s = "";
595
+ var childNodes = getFilteredChildNodes(node);
596
+ for(var i = 0, len = childNodes.length; i < len; i += 1){
597
+ s += getOuterHTML(childNodes[i]);
828
598
  }
599
+ return s;
829
600
  }
830
601
  /*
831
602
  * Copyright (c) 2018, salesforce.com, inc.
832
603
  * All rights reserved.
833
604
  * SPDX-License-Identifier: MIT
834
605
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
835
- */ var Items$1 = new WeakMap();
836
- function StaticNodeList() {
837
- throw new TypeError("Illegal constructor");
838
- }
839
- var _obj;
840
- StaticNodeList.prototype = create(NodeList.prototype, (_obj = {
841
- constructor: {
842
- writable: true,
843
- configurable: true,
844
- value: StaticNodeList
845
- },
846
- item: {
847
- writable: true,
848
- enumerable: true,
849
- configurable: true,
606
+ */ // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#escapingString
607
+ var escapeAttrRegExp = /[&\u00A0"]/g;
608
+ var escapeDataRegExp = /[&\u00A0<>]/g;
609
+ var _prototype5 = String.prototype, replace = _prototype5.replace, toLowerCase = _prototype5.toLowerCase;
610
+ function escapeReplace(c) {
611
+ switch(c){
612
+ case "&":
613
+ return "&amp;";
614
+ case "<":
615
+ return "&lt;";
616
+ case ">":
617
+ return "&gt;";
618
+ case '"':
619
+ return "&quot;";
620
+ case "\xa0":
621
+ return "&nbsp;";
622
+ default:
623
+ return "";
624
+ }
625
+ }
626
+ function escapeAttr(s) {
627
+ return replace.call(s, escapeAttrRegExp, escapeReplace);
628
+ }
629
+ function escapeData(s) {
630
+ return replace.call(s, escapeDataRegExp, escapeReplace);
631
+ }
632
+ // http://www.whatwg.org/specs/web-apps/current-work/#void-elements
633
+ var voidElements = new Set([
634
+ "AREA",
635
+ "BASE",
636
+ "BR",
637
+ "COL",
638
+ "COMMAND",
639
+ "EMBED",
640
+ "HR",
641
+ "IMG",
642
+ "INPUT",
643
+ "KEYGEN",
644
+ "LINK",
645
+ "META",
646
+ "PARAM",
647
+ "SOURCE",
648
+ "TRACK",
649
+ "WBR",
650
+ ]);
651
+ var plaintextParents = new Set([
652
+ "STYLE",
653
+ "SCRIPT",
654
+ "XMP",
655
+ "IFRAME",
656
+ "NOEMBED",
657
+ "NOFRAMES",
658
+ "PLAINTEXT",
659
+ "NOSCRIPT",
660
+ ]);
661
+ function getOuterHTML(node) {
662
+ switch(node.nodeType){
663
+ case ELEMENT_NODE:
664
+ {
665
+ var attrs = node.attributes;
666
+ var tagName = tagNameGetter.call(node);
667
+ var s = "<" + toLowerCase.call(tagName);
668
+ for(var i = 0, attr; attr = attrs[i]; i++){
669
+ s += " " + attr.name + '="' + escapeAttr(attr.value) + '"';
670
+ }
671
+ s += ">";
672
+ if (voidElements.has(tagName)) {
673
+ return s;
674
+ }
675
+ return s + getInnerHTML(node) + "</" + toLowerCase.call(tagName) + ">";
676
+ }
677
+ case TEXT_NODE:
678
+ {
679
+ var data = node.data, parentNode = node.parentNode;
680
+ if (_instanceof(parentNode, Element) && plaintextParents.has(tagNameGetter.call(parentNode))) {
681
+ return data;
682
+ }
683
+ return escapeData(data);
684
+ }
685
+ case CDATA_SECTION_NODE:
686
+ {
687
+ return "<!CDATA[[".concat(node.data, "]]>");
688
+ }
689
+ case PROCESSING_INSTRUCTION_NODE:
690
+ {
691
+ return "<?".concat(node.target, " ").concat(node.data, "?>");
692
+ }
693
+ case COMMENT_NODE:
694
+ {
695
+ return "<!--".concat(node.data, "-->");
696
+ }
697
+ default:
698
+ {
699
+ // intentionally ignoring unknown node types
700
+ // Note: since this routine is always invoked for childNodes
701
+ // we can safety ignore type 9, 10 and 99 (document, fragment and doctype)
702
+ return "";
703
+ }
704
+ }
705
+ }
706
+ /*
707
+ * Copyright (c) 2018, salesforce.com, inc.
708
+ * All rights reserved.
709
+ * SPDX-License-Identifier: MIT
710
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
711
+ */ function getTextContent(node) {
712
+ switch(node.nodeType){
713
+ case ELEMENT_NODE:
714
+ {
715
+ var childNodes = getFilteredChildNodes(node);
716
+ var content = "";
717
+ for(var i = 0, len = childNodes.length; i < len; i += 1){
718
+ var currentNode = childNodes[i];
719
+ if (currentNode.nodeType !== COMMENT_NODE) {
720
+ content += getTextContent(currentNode);
721
+ }
722
+ }
723
+ return content;
724
+ }
725
+ default:
726
+ return node.nodeValue;
727
+ }
728
+ }
729
+ /*
730
+ * Copyright (c) 2018, salesforce.com, inc.
731
+ * All rights reserved.
732
+ * SPDX-License-Identifier: MIT
733
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
734
+ */ var Items$1 = new WeakMap();
735
+ function StaticNodeList() {
736
+ throw new TypeError("Illegal constructor");
737
+ }
738
+ var _obj;
739
+ StaticNodeList.prototype = create(NodeList.prototype, (_obj = {
740
+ constructor: {
741
+ writable: true,
742
+ configurable: true,
743
+ value: StaticNodeList
744
+ },
745
+ item: {
746
+ writable: true,
747
+ enumerable: true,
748
+ configurable: true,
850
749
  value: function value(index) {
851
750
  return this[index];
852
751
  }
@@ -945,6 +844,67 @@
945
844
  });
946
845
  return nodeList;
947
846
  }
847
+ /*
848
+ * Copyright (c) 2018, salesforce.com, inc.
849
+ * All rights reserved.
850
+ * SPDX-License-Identifier: MIT
851
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
852
+ */ // Walk up the DOM tree, collecting all shadow roots plus the document root
853
+ function getAllRootNodes(node) {
854
+ var _a;
855
+ var rootNodes = [];
856
+ var currentRootNode = node.getRootNode();
857
+ while(!isUndefined(currentRootNode)){
858
+ rootNodes.push(currentRootNode);
859
+ currentRootNode = (_a = currentRootNode.host) === null || _a === void 0 ? void 0 : _a.getRootNode();
860
+ }
861
+ return rootNodes;
862
+ }
863
+ // Keep searching up the host tree until we find an element that is within the immediate shadow root
864
+ var findAncestorHostInImmediateShadowRoot = function(rootNode, targetRootNode) {
865
+ var host;
866
+ while(!isUndefined(host = rootNode.host)){
867
+ var thisRootNode = host.getRootNode();
868
+ if (thisRootNode === targetRootNode) {
869
+ return host;
870
+ }
871
+ rootNode = thisRootNode;
872
+ }
873
+ };
874
+ function fauxElementsFromPoint(context, doc, left, top) {
875
+ var elements = elementsFromPoint.call(doc, left, top);
876
+ var result = [];
877
+ var rootNodes = getAllRootNodes(context);
878
+ // Filter the elements array to only include those elements that are in this shadow root or in one of its
879
+ // ancestor roots. This matches Chrome and Safari's implementation (but not Firefox's, which only includes
880
+ // elements in the immediate shadow root: https://crbug.com/1207863#c4).
881
+ if (!isNull(elements)) {
882
+ // can be null in IE https://developer.mozilla.org/en-US/docs/Web/API/Document/elementsFromPoint#browser_compatibility
883
+ for(var i = 0; i < elements.length; i++){
884
+ var element = elements[i];
885
+ if (isSyntheticSlotElement(element)) {
886
+ continue;
887
+ }
888
+ var elementRootNode = element.getRootNode();
889
+ if (ArrayIndexOf.call(rootNodes, elementRootNode) !== -1) {
890
+ ArrayPush.call(result, element);
891
+ continue;
892
+ }
893
+ // In cases where the host element is not visible but its shadow descendants are, then
894
+ // we may get the shadow descendant instead of the host element here. (The
895
+ // browser doesn't know the difference in synthetic shadow DOM.)
896
+ // In native shadow DOM, however, elementsFromPoint would return the host but not
897
+ // the child. So we need to detect if this shadow element's host is accessible from
898
+ // the context's shadow root. Note we also need to be careful not to add the host
899
+ // multiple times.
900
+ var ancestorHost = findAncestorHostInImmediateShadowRoot(elementRootNode, rootNodes[0]);
901
+ if (!isUndefined(ancestorHost) && ArrayIndexOf.call(elements, ancestorHost) === -1 && ArrayIndexOf.call(result, ancestorHost) === -1) {
902
+ ArrayPush.call(result, ancestorHost);
903
+ }
904
+ }
905
+ }
906
+ return result;
907
+ }
948
908
  /*
949
909
  * Copyright (c) 2018, salesforce.com, inc.
950
910
  * All rights reserved.
@@ -972,175 +932,57 @@
972
932
  length: {
973
933
  enumerable: true,
974
934
  configurable: true,
975
- get: function get() {
976
- return Items.get(this).length;
977
- }
978
- },
979
- // https://dom.spec.whatwg.org/#dom-htmlcollection-nameditem-key
980
- namedItem: {
981
- writable: true,
982
- enumerable: true,
983
- configurable: true,
984
- value: function value(name) {
985
- if (name === "") {
986
- return null;
987
- }
988
- var items = Items.get(this);
989
- for(var i = 0, len = items.length; i < len; i++){
990
- var item = items[len];
991
- if (name === getAttribute.call(item, "id") || name === getAttribute.call(item, "name")) {
992
- return item;
993
- }
994
- }
995
- return null;
996
- }
997
- }
998
- }, _defineProperty(_obj1, Symbol.toStringTag, {
999
- configurable: true,
1000
- get: function get() {
1001
- return "HTMLCollection";
1002
- }
1003
- }), // IE11 doesn't support Symbol.toStringTag, in which case we
1004
- // provide the regular toString method.
1005
- _defineProperty(_obj1, "toString", {
1006
- writable: true,
1007
- configurable: true,
1008
- value: function value() {
1009
- return "[object HTMLCollection]";
1010
- }
1011
- }), _obj1));
1012
- // prototype inheritance dance
1013
- setPrototypeOf(StaticHTMLCollection, HTMLCollection);
1014
- function createStaticHTMLCollection(items) {
1015
- var collection = create(StaticHTMLCollection.prototype);
1016
- Items.set(collection, items);
1017
- // setting static indexes
1018
- forEach.call(items, function(item, index) {
1019
- defineProperty(collection, index, {
1020
- value: item,
1021
- enumerable: true,
1022
- configurable: true
1023
- });
1024
- });
1025
- return collection;
1026
- }
1027
- /*
1028
- * Copyright (c) 2018, salesforce.com, inc.
1029
- * All rights reserved.
1030
- * SPDX-License-Identifier: MIT
1031
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1032
- */ function getInnerHTML(node) {
1033
- var s = "";
1034
- var childNodes = getFilteredChildNodes(node);
1035
- for(var i = 0, len = childNodes.length; i < len; i += 1){
1036
- s += getOuterHTML(childNodes[i]);
1037
- }
1038
- return s;
1039
- }
1040
- /*
1041
- * Copyright (c) 2018, salesforce.com, inc.
1042
- * All rights reserved.
1043
- * SPDX-License-Identifier: MIT
1044
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1045
- */ // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#escapingString
1046
- var escapeAttrRegExp = /[&\u00A0"]/g;
1047
- var escapeDataRegExp = /[&\u00A0<>]/g;
1048
- var _prototype5 = String.prototype, replace = _prototype5.replace, toLowerCase = _prototype5.toLowerCase;
1049
- function escapeReplace(c) {
1050
- switch(c){
1051
- case "&":
1052
- return "&amp;";
1053
- case "<":
1054
- return "&lt;";
1055
- case ">":
1056
- return "&gt;";
1057
- case '"':
1058
- return "&quot;";
1059
- case "\xa0":
1060
- return "&nbsp;";
1061
- default:
1062
- return "";
1063
- }
1064
- }
1065
- function escapeAttr(s) {
1066
- return replace.call(s, escapeAttrRegExp, escapeReplace);
1067
- }
1068
- function escapeData(s) {
1069
- return replace.call(s, escapeDataRegExp, escapeReplace);
1070
- }
1071
- // http://www.whatwg.org/specs/web-apps/current-work/#void-elements
1072
- var voidElements = new Set([
1073
- "AREA",
1074
- "BASE",
1075
- "BR",
1076
- "COL",
1077
- "COMMAND",
1078
- "EMBED",
1079
- "HR",
1080
- "IMG",
1081
- "INPUT",
1082
- "KEYGEN",
1083
- "LINK",
1084
- "META",
1085
- "PARAM",
1086
- "SOURCE",
1087
- "TRACK",
1088
- "WBR",
1089
- ]);
1090
- var plaintextParents = new Set([
1091
- "STYLE",
1092
- "SCRIPT",
1093
- "XMP",
1094
- "IFRAME",
1095
- "NOEMBED",
1096
- "NOFRAMES",
1097
- "PLAINTEXT",
1098
- "NOSCRIPT",
1099
- ]);
1100
- function getOuterHTML(node) {
1101
- switch(node.nodeType){
1102
- case ELEMENT_NODE:
1103
- {
1104
- var attrs = node.attributes;
1105
- var tagName = tagNameGetter.call(node);
1106
- var s = "<" + toLowerCase.call(tagName);
1107
- for(var i = 0, attr; attr = attrs[i]; i++){
1108
- s += " " + attr.name + '="' + escapeAttr(attr.value) + '"';
1109
- }
1110
- s += ">";
1111
- if (voidElements.has(tagName)) {
1112
- return s;
1113
- }
1114
- return s + getInnerHTML(node) + "</" + toLowerCase.call(tagName) + ">";
1115
- }
1116
- case TEXT_NODE:
1117
- {
1118
- var data = node.data, parentNode = node.parentNode;
1119
- if (_instanceof(parentNode, Element) && plaintextParents.has(tagNameGetter.call(parentNode))) {
1120
- return data;
1121
- }
1122
- return escapeData(data);
1123
- }
1124
- case CDATA_SECTION_NODE:
1125
- {
1126
- return "<!CDATA[[".concat(node.data, "]]>");
1127
- }
1128
- case PROCESSING_INSTRUCTION_NODE:
1129
- {
1130
- return "<?".concat(node.target, " ").concat(node.data, "?>");
1131
- }
1132
- case COMMENT_NODE:
1133
- {
1134
- return "<!--".concat(node.data, "-->");
935
+ get: function get() {
936
+ return Items.get(this).length;
937
+ }
938
+ },
939
+ // https://dom.spec.whatwg.org/#dom-htmlcollection-nameditem-key
940
+ namedItem: {
941
+ writable: true,
942
+ enumerable: true,
943
+ configurable: true,
944
+ value: function value(name) {
945
+ if (name === "") {
946
+ return null;
1135
947
  }
1136
- default:
1137
- {
1138
- // intentionally ignoring unknown node types
1139
- // Note: since this routine is always invoked for childNodes
1140
- // we can safety ignore type 9, 10 and 99 (document, fragment and doctype)
1141
- return "";
948
+ var items = Items.get(this);
949
+ for(var i = 0, len = items.length; i < len; i++){
950
+ var item = items[len];
951
+ if (name === getAttribute.call(item, "id") || name === getAttribute.call(item, "name")) {
952
+ return item;
953
+ }
1142
954
  }
955
+ return null;
956
+ }
957
+ }
958
+ }, _defineProperty(_obj1, Symbol.toStringTag, {
959
+ configurable: true,
960
+ get: function get() {
961
+ return "HTMLCollection";
962
+ }
963
+ }), // IE11 doesn't support Symbol.toStringTag, in which case we
964
+ // provide the regular toString method.
965
+ _defineProperty(_obj1, "toString", {
966
+ writable: true,
967
+ configurable: true,
968
+ value: function value() {
969
+ return "[object HTMLCollection]";
1143
970
  }
971
+ }), _obj1));
972
+ // prototype inheritance dance
973
+ setPrototypeOf(StaticHTMLCollection, HTMLCollection);
974
+ function createStaticHTMLCollection(items) {
975
+ var collection = create(StaticHTMLCollection.prototype);
976
+ Items.set(collection, items);
977
+ // setting static indexes
978
+ forEach.call(items, function(item, index) {
979
+ defineProperty(collection, index, {
980
+ value: item,
981
+ enumerable: true,
982
+ configurable: true
983
+ });
984
+ });
985
+ return collection;
1144
986
  }
1145
987
  /**
1146
988
  * Copyright (C) 2018 salesforce.com, inc.
@@ -1150,7 +992,7 @@
1150
992
  });
1151
993
  }
1152
994
  var runtimeFlags = _globalThis.lwcRuntimeFlags;
1153
- /** version: 2.13.0 */ /*
995
+ /** version: 2.13.3 */ /*
1154
996
  * Copyright (c) 2018, salesforce.com, inc.
1155
997
  * All rights reserved.
1156
998
  * SPDX-License-Identifier: MIT
@@ -1491,61 +1333,219 @@
1491
1333
  * All rights reserved.
1492
1334
  * SPDX-License-Identifier: MIT
1493
1335
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1494
- */ // Walk up the DOM tree, collecting all shadow roots plus the document root
1495
- function getAllRootNodes(node) {
1336
+ */ var EventListenerMap = new WeakMap();
1337
+ var ComposedPathMap = new WeakMap();
1338
+ function isEventListenerOrEventListenerObject(fnOrObj) {
1339
+ return isFunction(fnOrObj) || isObject(fnOrObj) && !isNull(fnOrObj) && isFunction(fnOrObj.handleEvent);
1340
+ }
1341
+ function shouldInvokeListener(event, target, currentTarget) {
1342
+ // Subsequent logic assumes that `currentTarget` must be contained in the composed path for the listener to be
1343
+ // invoked, but this is not always the case. `composedPath()` will sometimes return an empty array, even when the
1344
+ // listener should be invoked (e.g., a disconnected instance of EventTarget, an instance of XMLHttpRequest, etc).
1345
+ if (target === currentTarget) {
1346
+ return true;
1347
+ }
1348
+ var composedPath1 = ComposedPathMap.get(event);
1349
+ if (isUndefined(composedPath1)) {
1350
+ composedPath1 = event.composedPath();
1351
+ ComposedPathMap.set(event, composedPath1);
1352
+ }
1353
+ return composedPath1.includes(currentTarget);
1354
+ }
1355
+ function getEventListenerWrapper(fnOrObj) {
1356
+ if (!isEventListenerOrEventListenerObject(fnOrObj)) {
1357
+ return fnOrObj;
1358
+ }
1359
+ var wrapperFn = EventListenerMap.get(fnOrObj);
1360
+ if (isUndefined(wrapperFn)) {
1361
+ wrapperFn = function wrapperFn(event) {
1362
+ // This function is invoked from an event listener and currentTarget is always defined.
1363
+ var currentTarget = eventCurrentTargetGetter.call(event);
1364
+ var actualTarget = getActualTarget(event);
1365
+ if (!shouldInvokeListener(event, actualTarget, currentTarget)) {
1366
+ return;
1367
+ }
1368
+ return isFunction(fnOrObj) ? fnOrObj.call(this, event) : fnOrObj.handleEvent && fnOrObj.handleEvent(event);
1369
+ };
1370
+ EventListenerMap.set(fnOrObj, wrapperFn);
1371
+ }
1372
+ return wrapperFn;
1373
+ }
1374
+ /*
1375
+ * Copyright (c) 2018, salesforce.com, inc.
1376
+ * All rights reserved.
1377
+ * SPDX-License-Identifier: MIT
1378
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1379
+ */ var eventToContextMap = new WeakMap();
1380
+ var customElementToWrappedListeners = new WeakMap();
1381
+ function getEventMap(elm) {
1382
+ var listenerInfo = customElementToWrappedListeners.get(elm);
1383
+ if (isUndefined(listenerInfo)) {
1384
+ listenerInfo = create(null);
1385
+ customElementToWrappedListeners.set(elm, listenerInfo);
1386
+ }
1387
+ return listenerInfo;
1388
+ }
1389
+ /**
1390
+ * Events dispatched on shadow roots actually end up being dispatched on their hosts. This means that the event.target
1391
+ * property of events dispatched on shadow roots always resolve to their host. This function understands this
1392
+ * abstraction and properly returns a reference to the shadow root when appropriate.
1393
+ */ function getActualTarget(event) {
1496
1394
  var _a;
1497
- var rootNodes = [];
1498
- var currentRootNode = node.getRootNode();
1499
- while(!isUndefined(currentRootNode)){
1500
- rootNodes.push(currentRootNode);
1501
- currentRootNode = (_a = currentRootNode.host) === null || _a === void 0 ? void 0 : _a.getRootNode();
1395
+ return (_a = eventToShadowRootMap.get(event)) !== null && _a !== void 0 ? _a : eventTargetGetter.call(event);
1396
+ }
1397
+ var shadowRootEventListenerMap = new WeakMap();
1398
+ function getWrappedShadowRootListener(listener) {
1399
+ if (!isFunction(listener)) {
1400
+ throw new TypeError(); // avoiding problems with non-valid listeners
1401
+ }
1402
+ var shadowRootWrappedListener = shadowRootEventListenerMap.get(listener);
1403
+ if (isUndefined(shadowRootWrappedListener)) {
1404
+ shadowRootWrappedListener = function shadowRootWrappedListener(event) {
1405
+ // currentTarget is always defined inside an event listener
1406
+ var currentTarget = eventCurrentTargetGetter.call(event);
1407
+ // If currentTarget is not an instance of a native shadow root then we're dealing with a
1408
+ // host element whose synthetic shadow root must be accessed via getShadowRoot().
1409
+ if (!isInstanceOfNativeShadowRoot(currentTarget)) {
1410
+ currentTarget = getShadowRoot(currentTarget);
1411
+ }
1412
+ var actualTarget = getActualTarget(event);
1413
+ if (shouldInvokeListener(event, actualTarget, currentTarget)) {
1414
+ listener.call(currentTarget, event);
1415
+ }
1416
+ };
1417
+ shadowRootWrappedListener.placement = 1 /* SHADOW_ROOT_LISTENER */ ;
1418
+ shadowRootEventListenerMap.set(listener, shadowRootWrappedListener);
1419
+ }
1420
+ return shadowRootWrappedListener;
1421
+ }
1422
+ var customElementEventListenerMap = new WeakMap();
1423
+ function getWrappedCustomElementListener(listener) {
1424
+ if (!isFunction(listener)) {
1425
+ throw new TypeError(); // avoiding problems with non-valid listeners
1426
+ }
1427
+ var customElementWrappedListener = customElementEventListenerMap.get(listener);
1428
+ if (isUndefined(customElementWrappedListener)) {
1429
+ customElementWrappedListener = function customElementWrappedListener(event) {
1430
+ // currentTarget is always defined inside an event listener
1431
+ var currentTarget = eventCurrentTargetGetter.call(event);
1432
+ var actualTarget = getActualTarget(event);
1433
+ if (shouldInvokeListener(event, actualTarget, currentTarget)) {
1434
+ listener.call(currentTarget, event);
1435
+ }
1436
+ };
1437
+ customElementWrappedListener.placement = 0 /* CUSTOM_ELEMENT_LISTENER */ ;
1438
+ customElementEventListenerMap.set(listener, customElementWrappedListener);
1439
+ }
1440
+ return customElementWrappedListener;
1441
+ }
1442
+ function domListener(evt) {
1443
+ var invokeListenersByPlacement = function invokeListenersByPlacement(placement) {
1444
+ forEach.call(bookkeeping, function(listener) {
1445
+ if (isFalse(immediatePropagationStopped) && listener.placement === placement) {
1446
+ // making sure that the listener was not removed from the original listener queue
1447
+ if (ArrayIndexOf.call(listeners, listener) !== -1) {
1448
+ // all handlers on the custom element should be called with undefined 'this'
1449
+ listener.call(undefined, evt);
1450
+ }
1451
+ }
1452
+ });
1453
+ };
1454
+ var immediatePropagationStopped = false;
1455
+ var propagationStopped = false;
1456
+ var type = evt.type, stopImmediatePropagation = evt.stopImmediatePropagation, stopPropagation = evt.stopPropagation;
1457
+ // currentTarget is always defined
1458
+ var currentTarget = eventCurrentTargetGetter.call(evt);
1459
+ var listenerMap = getEventMap(currentTarget);
1460
+ var listeners = listenerMap[type]; // it must have listeners at this point
1461
+ defineProperty(evt, "stopImmediatePropagation", {
1462
+ value: function value() {
1463
+ immediatePropagationStopped = true;
1464
+ stopImmediatePropagation.call(evt);
1465
+ },
1466
+ writable: true,
1467
+ enumerable: true,
1468
+ configurable: true
1469
+ });
1470
+ defineProperty(evt, "stopPropagation", {
1471
+ value: function value() {
1472
+ propagationStopped = true;
1473
+ stopPropagation.call(evt);
1474
+ },
1475
+ writable: true,
1476
+ enumerable: true,
1477
+ configurable: true
1478
+ });
1479
+ // in case a listener adds or removes other listeners during invocation
1480
+ var bookkeeping = ArraySlice.call(listeners);
1481
+ eventToContextMap.set(evt, 1 /* SHADOW_ROOT_LISTENER */ );
1482
+ invokeListenersByPlacement(1 /* SHADOW_ROOT_LISTENER */ );
1483
+ if (isFalse(immediatePropagationStopped) && isFalse(propagationStopped)) {
1484
+ // doing the second iteration only if the first one didn't interrupt the event propagation
1485
+ eventToContextMap.set(evt, 0 /* CUSTOM_ELEMENT_LISTENER */ );
1486
+ invokeListenersByPlacement(0 /* CUSTOM_ELEMENT_LISTENER */ );
1487
+ }
1488
+ eventToContextMap.set(evt, 2 /* UNKNOWN_LISTENER */ );
1489
+ }
1490
+ function attachDOMListener(elm, type, wrappedListener) {
1491
+ var listenerMap = getEventMap(elm);
1492
+ var cmpEventHandlers = listenerMap[type];
1493
+ if (isUndefined(cmpEventHandlers)) {
1494
+ cmpEventHandlers = listenerMap[type] = [];
1495
+ }
1496
+ // Prevent identical listeners from subscribing to the same event type.
1497
+ // TODO [#1824]: Options will also play a factor when we introduce support for them (#1824).
1498
+ if (ArrayIndexOf.call(cmpEventHandlers, wrappedListener) !== -1) {
1499
+ return;
1500
+ }
1501
+ // only add to DOM if there is no other listener on the same placement yet
1502
+ if (cmpEventHandlers.length === 0) {
1503
+ // super.addEventListener() - this will not work on
1504
+ addEventListener.call(elm, type, domListener);
1505
+ }
1506
+ ArrayPush.call(cmpEventHandlers, wrappedListener);
1507
+ }
1508
+ function detachDOMListener(elm, type, wrappedListener) {
1509
+ var listenerMap = getEventMap(elm);
1510
+ var p;
1511
+ var listeners;
1512
+ if (!isUndefined(listeners = listenerMap[type]) && (p = ArrayIndexOf.call(listeners, wrappedListener)) !== -1) {
1513
+ ArraySplice.call(listeners, p, 1);
1514
+ // only remove from DOM if there is no other listener on the same placement
1515
+ if (listeners.length === 0) {
1516
+ removeEventListener.call(elm, type, domListener);
1517
+ }
1518
+ }
1519
+ }
1520
+ function addCustomElementEventListener(type, listener, _options) {
1521
+ // TODO [#1824]: Lift this restriction on the option parameter
1522
+ if (isFunction(listener)) {
1523
+ var wrappedListener = getWrappedCustomElementListener(listener);
1524
+ attachDOMListener(this, type, wrappedListener);
1525
+ }
1526
+ }
1527
+ function removeCustomElementEventListener(type, listener, _options) {
1528
+ // TODO [#1824]: Lift this restriction on the option parameter
1529
+ if (isFunction(listener)) {
1530
+ var wrappedListener = getWrappedCustomElementListener(listener);
1531
+ detachDOMListener(this, type, wrappedListener);
1502
1532
  }
1503
- return rootNodes;
1504
1533
  }
1505
- // Keep searching up the host tree until we find an element that is within the immediate shadow root
1506
- var findAncestorHostInImmediateShadowRoot = function(rootNode, targetRootNode) {
1507
- var host;
1508
- while(!isUndefined(host = rootNode.host)){
1509
- var thisRootNode = host.getRootNode();
1510
- if (thisRootNode === targetRootNode) {
1511
- return host;
1512
- }
1513
- rootNode = thisRootNode;
1534
+ function addShadowRootEventListener(sr, type, listener, _options) {
1535
+ // TODO [#1824]: Lift this restriction on the option parameter
1536
+ if (isFunction(listener)) {
1537
+ var elm = getHost(sr);
1538
+ var wrappedListener = getWrappedShadowRootListener(listener);
1539
+ attachDOMListener(elm, type, wrappedListener);
1514
1540
  }
1515
- };
1516
- function fauxElementsFromPoint(context, doc, left, top) {
1517
- var elements = elementsFromPoint.call(doc, left, top);
1518
- var result = [];
1519
- var rootNodes = getAllRootNodes(context);
1520
- // Filter the elements array to only include those elements that are in this shadow root or in one of its
1521
- // ancestor roots. This matches Chrome and Safari's implementation (but not Firefox's, which only includes
1522
- // elements in the immediate shadow root: https://crbug.com/1207863#c4).
1523
- if (!isNull(elements)) {
1524
- // can be null in IE https://developer.mozilla.org/en-US/docs/Web/API/Document/elementsFromPoint#browser_compatibility
1525
- for(var i = 0; i < elements.length; i++){
1526
- var element = elements[i];
1527
- if (isSyntheticSlotElement(element)) {
1528
- continue;
1529
- }
1530
- var elementRootNode = element.getRootNode();
1531
- if (ArrayIndexOf.call(rootNodes, elementRootNode) !== -1) {
1532
- ArrayPush.call(result, element);
1533
- continue;
1534
- }
1535
- // In cases where the host element is not visible but its shadow descendants are, then
1536
- // we may get the shadow descendant instead of the host element here. (The
1537
- // browser doesn't know the difference in synthetic shadow DOM.)
1538
- // In native shadow DOM, however, elementsFromPoint would return the host but not
1539
- // the child. So we need to detect if this shadow element's host is accessible from
1540
- // the context's shadow root. Note we also need to be careful not to add the host
1541
- // multiple times.
1542
- var ancestorHost = findAncestorHostInImmediateShadowRoot(elementRootNode, rootNodes[0]);
1543
- if (!isUndefined(ancestorHost) && ArrayIndexOf.call(elements, ancestorHost) === -1 && ArrayIndexOf.call(result, ancestorHost) === -1) {
1544
- ArrayPush.call(result, ancestorHost);
1545
- }
1546
- }
1541
+ }
1542
+ function removeShadowRootEventListener(sr, type, listener, _options) {
1543
+ // TODO [#1824]: Lift this restriction on the option parameter
1544
+ if (isFunction(listener)) {
1545
+ var elm = getHost(sr);
1546
+ var wrappedListener = getWrappedShadowRootListener(listener);
1547
+ detachDOMListener(elm, type, wrappedListener);
1547
1548
  }
1548
- return result;
1549
1549
  }
1550
1550
  /*
1551
1551
  * Copyright (c) 2018, salesforce.com, inc.
@@ -3592,52 +3592,236 @@
3592
3592
  enumerable: true,
3593
3593
  configurable: true
3594
3594
  }
3595
- }); // The following APIs are used directly by Jest internally so we avoid patching them during testing.
3596
- {
3597
- defineProperties(Element.prototype, {
3598
- getElementsByClassName: {
3599
- value: function value() {
3600
- var elements = arrayFromCollection(getElementsByClassName$1.apply(this, ArraySlice.call(arguments)));
3601
- if (!runtimeFlags.ENABLE_HTML_COLLECTIONS_PATCH) {
3602
- return createStaticHTMLCollection(getNonPatchedFilteredArrayOfNodes(this, elements));
3603
- }
3604
- var filteredResults = getFilteredArrayOfNodes(this, elements, 1);
3605
- return createStaticHTMLCollection(filteredResults);
3606
- },
3607
- writable: true,
3608
- enumerable: true,
3609
- configurable: true
3610
- },
3611
- getElementsByTagName: {
3612
- value: function value() {
3613
- var elements = arrayFromCollection(getElementsByTagName$1.apply(this, ArraySlice.call(arguments)));
3614
- if (!runtimeFlags.ENABLE_HTML_COLLECTIONS_PATCH) {
3615
- return createStaticHTMLCollection(getNonPatchedFilteredArrayOfNodes(this, elements));
3616
- }
3617
- var filteredResults = getFilteredArrayOfNodes(this, elements, 1);
3618
- return createStaticHTMLCollection(filteredResults);
3619
- },
3620
- writable: true,
3621
- enumerable: true,
3622
- configurable: true
3623
- },
3624
- getElementsByTagNameNS: {
3625
- value: function value() {
3626
- var elements = arrayFromCollection(getElementsByTagNameNS$1.apply(this, ArraySlice.call(arguments)));
3627
- if (!runtimeFlags.ENABLE_HTML_COLLECTIONS_PATCH) {
3628
- return createStaticHTMLCollection(getNonPatchedFilteredArrayOfNodes(this, elements));
3595
+ }); // The following APIs are used directly by Jest internally so we avoid patching them during testing.
3596
+ {
3597
+ defineProperties(Element.prototype, {
3598
+ getElementsByClassName: {
3599
+ value: function value() {
3600
+ var elements = arrayFromCollection(getElementsByClassName$1.apply(this, ArraySlice.call(arguments)));
3601
+ if (!runtimeFlags.ENABLE_HTML_COLLECTIONS_PATCH) {
3602
+ return createStaticHTMLCollection(getNonPatchedFilteredArrayOfNodes(this, elements));
3603
+ }
3604
+ var filteredResults = getFilteredArrayOfNodes(this, elements, 1);
3605
+ return createStaticHTMLCollection(filteredResults);
3606
+ },
3607
+ writable: true,
3608
+ enumerable: true,
3609
+ configurable: true
3610
+ },
3611
+ getElementsByTagName: {
3612
+ value: function value() {
3613
+ var elements = arrayFromCollection(getElementsByTagName$1.apply(this, ArraySlice.call(arguments)));
3614
+ if (!runtimeFlags.ENABLE_HTML_COLLECTIONS_PATCH) {
3615
+ return createStaticHTMLCollection(getNonPatchedFilteredArrayOfNodes(this, elements));
3616
+ }
3617
+ var filteredResults = getFilteredArrayOfNodes(this, elements, 1);
3618
+ return createStaticHTMLCollection(filteredResults);
3619
+ },
3620
+ writable: true,
3621
+ enumerable: true,
3622
+ configurable: true
3623
+ },
3624
+ getElementsByTagNameNS: {
3625
+ value: function value() {
3626
+ var elements = arrayFromCollection(getElementsByTagNameNS$1.apply(this, ArraySlice.call(arguments)));
3627
+ if (!runtimeFlags.ENABLE_HTML_COLLECTIONS_PATCH) {
3628
+ return createStaticHTMLCollection(getNonPatchedFilteredArrayOfNodes(this, elements));
3629
+ }
3630
+ var filteredResults = getFilteredArrayOfNodes(this, elements, 1);
3631
+ return createStaticHTMLCollection(filteredResults);
3632
+ },
3633
+ writable: true,
3634
+ enumerable: true,
3635
+ configurable: true
3636
+ }
3637
+ });
3638
+ } // IE11 extra patches for wrong prototypes
3639
+ if (hasOwnProperty.call(HTMLElement.prototype, "getElementsByClassName")) {
3640
+ defineProperty(HTMLElement.prototype, "getElementsByClassName", getOwnPropertyDescriptor(Element.prototype, "getElementsByClassName"));
3641
+ }
3642
+ /*
3643
+ * Copyright (c) 2018, salesforce.com, inc.
3644
+ * All rights reserved.
3645
+ * SPDX-License-Identifier: MIT
3646
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3647
+ */ function getElementComputedStyle(element) {
3648
+ var win = getOwnerWindow(element);
3649
+ return windowGetComputedStyle.call(win, element);
3650
+ }
3651
+ function getWindowSelection(node) {
3652
+ var win = getOwnerWindow(node);
3653
+ return windowGetSelection.call(win);
3654
+ }
3655
+ function nodeIsBeingRendered(nodeComputedStyle) {
3656
+ return nodeComputedStyle.visibility === "visible" && nodeComputedStyle.display !== "none";
3657
+ }
3658
+ function getSelectionState(element) {
3659
+ var win = getOwnerWindow(element);
3660
+ var selection = getWindowSelection(element);
3661
+ if (selection === null) {
3662
+ return null;
3663
+ }
3664
+ var ranges = [];
3665
+ for(var i = 0; i < selection.rangeCount; i++){
3666
+ ranges.push(selection.getRangeAt(i));
3667
+ }
3668
+ var state = {
3669
+ element: element,
3670
+ onselect: win.onselect,
3671
+ onselectstart: win.onselectstart,
3672
+ onselectionchange: win.onselectionchange,
3673
+ ranges: ranges
3674
+ };
3675
+ win.onselect = null;
3676
+ win.onselectstart = null;
3677
+ win.onselectionchange = null;
3678
+ return state;
3679
+ }
3680
+ function restoreSelectionState(state) {
3681
+ if (state === null) {
3682
+ return;
3683
+ }
3684
+ var element = state.element, onselect = state.onselect, onselectstart = state.onselectstart, onselectionchange = state.onselectionchange, ranges = state.ranges;
3685
+ var win = getOwnerWindow(element);
3686
+ var selection = getWindowSelection(element);
3687
+ selection.removeAllRanges();
3688
+ for(var i = 0; i < ranges.length; i++){
3689
+ selection.addRange(ranges[i]);
3690
+ }
3691
+ win.onselect = onselect;
3692
+ win.onselectstart = onselectstart;
3693
+ win.onselectionchange = onselectionchange;
3694
+ }
3695
+ /**
3696
+ * Gets the "innerText" of a text node using the Selection API
3697
+ *
3698
+ * NOTE: For performance reasons, since this function will be called multiple times while calculating the innerText of
3699
+ * an element, it does not restore the current selection.
3700
+ */ function getTextNodeInnerText(textNode) {
3701
+ var selection = getWindowSelection(textNode);
3702
+ if (selection === null) {
3703
+ return textNode.textContent || "";
3704
+ }
3705
+ var range = document.createRange();
3706
+ range.selectNodeContents(textNode);
3707
+ var domRect = range.getBoundingClientRect();
3708
+ if (domRect.height <= 0 || domRect.width <= 0) {
3709
+ // the text node is not rendered
3710
+ return "";
3711
+ }
3712
+ // Needed to remove non rendered characters from the text node.
3713
+ selection.removeAllRanges();
3714
+ selection.addRange(range);
3715
+ var selectionText = selection.toString();
3716
+ // The textNode is visible, but it may not be selectable. When the text is not selectable,
3717
+ // textContent is the nearest approximation to innerText.
3718
+ return selectionText ? selectionText : textNode.textContent || "";
3719
+ }
3720
+ var nodeIsElement = function(node) {
3721
+ return node.nodeType === ELEMENT_NODE;
3722
+ };
3723
+ var nodeIsText = function(node) {
3724
+ return node.nodeType === TEXT_NODE;
3725
+ };
3726
+ /**
3727
+ * Spec: https://html.spec.whatwg.org/multipage/dom.html#inner-text-collection-steps
3728
+ * One spec implementation: https://github.com/servo/servo/blob/721271dcd3c20db5ca8cf146e2b5907647afb4d6/components/layout/query.rs#L1132
3729
+ */ function innerTextCollectionSteps(node) {
3730
+ var items = [];
3731
+ if (nodeIsElement(node)) {
3732
+ var tagName = node.tagName;
3733
+ var computedStyle = getElementComputedStyle(node);
3734
+ if (tagName === "OPTION") {
3735
+ // For options, is hard to get the "rendered" text, let's use the original getter.
3736
+ return [
3737
+ 1,
3738
+ innerTextGetter.call(node),
3739
+ 1
3740
+ ];
3741
+ } else if (tagName === "TEXTAREA") {
3742
+ return [];
3743
+ } else {
3744
+ var childNodes = node.childNodes;
3745
+ for(var i = 0, n = childNodes.length; i < n; i++){
3746
+ ArrayPush.apply(items, innerTextCollectionSteps(childNodes[i]));
3747
+ }
3748
+ }
3749
+ if (!nodeIsBeingRendered(computedStyle)) {
3750
+ if (tagName === "SELECT" || tagName === "DATALIST") {
3751
+ // the select is either: .visibility != 'visible' or .display === hidden, therefore this select should
3752
+ // not display any value.
3753
+ return [];
3754
+ }
3755
+ return items;
3756
+ }
3757
+ if (tagName === "BR") {
3758
+ items.push("\n" /* line feed */ );
3759
+ }
3760
+ var display = computedStyle.display;
3761
+ if (display === "table-cell") {
3762
+ // omitting case: and node's CSS box is not the last 'table-cell' box of its enclosing 'table-row' box
3763
+ items.push(" " /* tab */ );
3764
+ }
3765
+ if (display === "table-row") {
3766
+ // omitting case: and node's CSS box is not the last 'table-row' box of the nearest ancestor 'table' box
3767
+ items.push("\n" /* line feed */ );
3768
+ }
3769
+ if (tagName === "P") {
3770
+ items.unshift(2);
3771
+ items.push(2);
3772
+ }
3773
+ if (display === "block" || display === "table-caption" || display === "flex" || display === "table") {
3774
+ items.unshift(1);
3775
+ items.push(1);
3776
+ }
3777
+ } else if (nodeIsText(node)) {
3778
+ items.push(getTextNodeInnerText(node));
3779
+ }
3780
+ return items;
3781
+ }
3782
+ /**
3783
+ * InnerText getter spec: https://html.spec.whatwg.org/multipage/dom.html#the-innertext-idl-attribute
3784
+ *
3785
+ * One spec implementation: https://github.com/servo/servo/blob/721271dcd3c20db5ca8cf146e2b5907647afb4d6/components/layout/query.rs#L1087
3786
+ */ function getInnerText(element) {
3787
+ var thisComputedStyle = getElementComputedStyle(element);
3788
+ if (!nodeIsBeingRendered(thisComputedStyle)) {
3789
+ return getTextContent(element) || "";
3790
+ }
3791
+ var selectionState = getSelectionState(element);
3792
+ var results = [];
3793
+ var childNodes = element.childNodes;
3794
+ for(var i = 0, n = childNodes.length; i < n; i++){
3795
+ ArrayPush.apply(results, innerTextCollectionSteps(childNodes[i]));
3796
+ }
3797
+ restoreSelectionState(selectionState);
3798
+ var elementInnerText = "";
3799
+ var maxReqLineBreakCount = 0;
3800
+ for(var i1 = 0, n1 = results.length; i1 < n1; i1++){
3801
+ var item = results[i1];
3802
+ if (typeof item === "string") {
3803
+ if (maxReqLineBreakCount > 0) {
3804
+ for(var j = 0; j < maxReqLineBreakCount; j++){
3805
+ elementInnerText += "\n";
3629
3806
  }
3630
- var filteredResults = getFilteredArrayOfNodes(this, elements, 1);
3631
- return createStaticHTMLCollection(filteredResults);
3632
- },
3633
- writable: true,
3634
- enumerable: true,
3635
- configurable: true
3807
+ maxReqLineBreakCount = 0;
3808
+ }
3809
+ if (item.length > 0) {
3810
+ elementInnerText += item;
3811
+ }
3812
+ } else {
3813
+ if (elementInnerText.length == 0) {
3814
+ continue;
3815
+ }
3816
+ // Store the count if it's the max of this run,
3817
+ // but it may be ignored if no text item is found afterwards,
3818
+ // which means that these are consecutive line breaks at the end.
3819
+ if (item > maxReqLineBreakCount) {
3820
+ maxReqLineBreakCount = item;
3821
+ }
3636
3822
  }
3637
- });
3638
- } // IE11 extra patches for wrong prototypes
3639
- if (hasOwnProperty.call(HTMLElement.prototype, "getElementsByClassName")) {
3640
- defineProperty(HTMLElement.prototype, "getElementsByClassName", getOwnPropertyDescriptor(Element.prototype, "getElementsByClassName"));
3823
+ }
3824
+ return elementInnerText;
3641
3825
  }
3642
3826
  /*
3643
3827
  * Copyright (c) 2018, salesforce.com, inc.
@@ -3954,190 +4138,6 @@
3954
4138
  function ignoreFocusIn(elm) {
3955
4139
  removeEventListener.call(elm, "focusin", skipShadowHandler, true);
3956
4140
  }
3957
- /*
3958
- * Copyright (c) 2018, salesforce.com, inc.
3959
- * All rights reserved.
3960
- * SPDX-License-Identifier: MIT
3961
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3962
- */ function getElementComputedStyle(element) {
3963
- var win = getOwnerWindow(element);
3964
- return windowGetComputedStyle.call(win, element);
3965
- }
3966
- function getWindowSelection(node) {
3967
- var win = getOwnerWindow(node);
3968
- return windowGetSelection.call(win);
3969
- }
3970
- function nodeIsBeingRendered(nodeComputedStyle) {
3971
- return nodeComputedStyle.visibility === "visible" && nodeComputedStyle.display !== "none";
3972
- }
3973
- function getSelectionState(element) {
3974
- var win = getOwnerWindow(element);
3975
- var selection = getWindowSelection(element);
3976
- if (selection === null) {
3977
- return null;
3978
- }
3979
- var ranges = [];
3980
- for(var i = 0; i < selection.rangeCount; i++){
3981
- ranges.push(selection.getRangeAt(i));
3982
- }
3983
- var state = {
3984
- element: element,
3985
- onselect: win.onselect,
3986
- onselectstart: win.onselectstart,
3987
- onselectionchange: win.onselectionchange,
3988
- ranges: ranges
3989
- };
3990
- win.onselect = null;
3991
- win.onselectstart = null;
3992
- win.onselectionchange = null;
3993
- return state;
3994
- }
3995
- function restoreSelectionState(state) {
3996
- if (state === null) {
3997
- return;
3998
- }
3999
- var element = state.element, onselect = state.onselect, onselectstart = state.onselectstart, onselectionchange = state.onselectionchange, ranges = state.ranges;
4000
- var win = getOwnerWindow(element);
4001
- var selection = getWindowSelection(element);
4002
- selection.removeAllRanges();
4003
- for(var i = 0; i < ranges.length; i++){
4004
- selection.addRange(ranges[i]);
4005
- }
4006
- win.onselect = onselect;
4007
- win.onselectstart = onselectstart;
4008
- win.onselectionchange = onselectionchange;
4009
- }
4010
- /**
4011
- * Gets the "innerText" of a text node using the Selection API
4012
- *
4013
- * NOTE: For performance reasons, since this function will be called multiple times while calculating the innerText of
4014
- * an element, it does not restore the current selection.
4015
- */ function getTextNodeInnerText(textNode) {
4016
- var selection = getWindowSelection(textNode);
4017
- if (selection === null) {
4018
- return textNode.textContent || "";
4019
- }
4020
- var range = document.createRange();
4021
- range.selectNodeContents(textNode);
4022
- var domRect = range.getBoundingClientRect();
4023
- if (domRect.height <= 0 || domRect.width <= 0) {
4024
- // the text node is not rendered
4025
- return "";
4026
- }
4027
- // Needed to remove non rendered characters from the text node.
4028
- selection.removeAllRanges();
4029
- selection.addRange(range);
4030
- var selectionText = selection.toString();
4031
- // The textNode is visible, but it may not be selectable. When the text is not selectable,
4032
- // textContent is the nearest approximation to innerText.
4033
- return selectionText ? selectionText : textNode.textContent || "";
4034
- }
4035
- var nodeIsElement = function(node) {
4036
- return node.nodeType === ELEMENT_NODE;
4037
- };
4038
- var nodeIsText = function(node) {
4039
- return node.nodeType === TEXT_NODE;
4040
- };
4041
- /**
4042
- * Spec: https://html.spec.whatwg.org/multipage/dom.html#inner-text-collection-steps
4043
- * One spec implementation: https://github.com/servo/servo/blob/721271dcd3c20db5ca8cf146e2b5907647afb4d6/components/layout/query.rs#L1132
4044
- */ function innerTextCollectionSteps(node) {
4045
- var items = [];
4046
- if (nodeIsElement(node)) {
4047
- var tagName = node.tagName;
4048
- var computedStyle = getElementComputedStyle(node);
4049
- if (tagName === "OPTION") {
4050
- // For options, is hard to get the "rendered" text, let's use the original getter.
4051
- return [
4052
- 1,
4053
- innerTextGetter.call(node),
4054
- 1
4055
- ];
4056
- } else if (tagName === "TEXTAREA") {
4057
- return [];
4058
- } else {
4059
- var childNodes = node.childNodes;
4060
- for(var i = 0, n = childNodes.length; i < n; i++){
4061
- ArrayPush.apply(items, innerTextCollectionSteps(childNodes[i]));
4062
- }
4063
- }
4064
- if (!nodeIsBeingRendered(computedStyle)) {
4065
- if (tagName === "SELECT" || tagName === "DATALIST") {
4066
- // the select is either: .visibility != 'visible' or .display === hidden, therefore this select should
4067
- // not display any value.
4068
- return [];
4069
- }
4070
- return items;
4071
- }
4072
- if (tagName === "BR") {
4073
- items.push("\n" /* line feed */ );
4074
- }
4075
- var display = computedStyle.display;
4076
- if (display === "table-cell") {
4077
- // omitting case: and node's CSS box is not the last 'table-cell' box of its enclosing 'table-row' box
4078
- items.push(" " /* tab */ );
4079
- }
4080
- if (display === "table-row") {
4081
- // omitting case: and node's CSS box is not the last 'table-row' box of the nearest ancestor 'table' box
4082
- items.push("\n" /* line feed */ );
4083
- }
4084
- if (tagName === "P") {
4085
- items.unshift(2);
4086
- items.push(2);
4087
- }
4088
- if (display === "block" || display === "table-caption" || display === "flex" || display === "table") {
4089
- items.unshift(1);
4090
- items.push(1);
4091
- }
4092
- } else if (nodeIsText(node)) {
4093
- items.push(getTextNodeInnerText(node));
4094
- }
4095
- return items;
4096
- }
4097
- /**
4098
- * InnerText getter spec: https://html.spec.whatwg.org/multipage/dom.html#the-innertext-idl-attribute
4099
- *
4100
- * One spec implementation: https://github.com/servo/servo/blob/721271dcd3c20db5ca8cf146e2b5907647afb4d6/components/layout/query.rs#L1087
4101
- */ function getInnerText(element) {
4102
- var thisComputedStyle = getElementComputedStyle(element);
4103
- if (!nodeIsBeingRendered(thisComputedStyle)) {
4104
- return getTextContent(element) || "";
4105
- }
4106
- var selectionState = getSelectionState(element);
4107
- var results = [];
4108
- var childNodes = element.childNodes;
4109
- for(var i = 0, n = childNodes.length; i < n; i++){
4110
- ArrayPush.apply(results, innerTextCollectionSteps(childNodes[i]));
4111
- }
4112
- restoreSelectionState(selectionState);
4113
- var elementInnerText = "";
4114
- var maxReqLineBreakCount = 0;
4115
- for(var i1 = 0, n1 = results.length; i1 < n1; i1++){
4116
- var item = results[i1];
4117
- if (typeof item === "string") {
4118
- if (maxReqLineBreakCount > 0) {
4119
- for(var j = 0; j < maxReqLineBreakCount; j++){
4120
- elementInnerText += "\n";
4121
- }
4122
- maxReqLineBreakCount = 0;
4123
- }
4124
- if (item.length > 0) {
4125
- elementInnerText += item;
4126
- }
4127
- } else {
4128
- if (elementInnerText.length == 0) {
4129
- continue;
4130
- }
4131
- // Store the count if it's the max of this run,
4132
- // but it may be ignored if no text item is found afterwards,
4133
- // which means that these are consecutive line breaks at the end.
4134
- if (item > maxReqLineBreakCount) {
4135
- maxReqLineBreakCount = item;
4136
- }
4137
- }
4138
- }
4139
- return elementInnerText;
4140
- }
4141
4141
  /*
4142
4142
  * Copyright (c) 2018, salesforce.com, inc.
4143
4143
  * All rights reserved.
@@ -4472,6 +4472,6 @@
4472
4472
  return this[DomManualPrivateKey];
4473
4473
  },
4474
4474
  configurable: true
4475
- }); /** version: 2.13.0 */
4475
+ }); /** version: 2.13.3 */
4476
4476
 
4477
4477
  })();