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