@lwc/engine-core 2.7.2 → 2.7.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.
- package/dist/engine-core.cjs.js +893 -1030
- package/dist/engine-core.js +894 -1031
- package/package.json +4 -4
- package/types/3rdparty/snabbdom/types.d.ts +1 -1
- package/types/framework/hooks.d.ts +2 -6
- package/types/framework/modules/attrs.d.ts +1 -6
- package/types/framework/modules/computed-class-attr.d.ts +1 -6
- package/types/framework/modules/computed-style-attr.d.ts +2 -7
- package/types/framework/modules/events.d.ts +2 -14
- package/types/framework/modules/props.d.ts +1 -6
- package/types/framework/modules/static-class-attr.d.ts +2 -6
- package/types/framework/modules/static-style-attr.d.ts +2 -6
- package/types/framework/vm.d.ts +0 -1
package/dist/engine-core.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* proxy-compat-disable */
|
|
2
|
-
import { seal, create, isFunction as isFunction$1, ArrayPush as ArrayPush$1, isUndefined as isUndefined$1, ArrayIndexOf, ArraySplice, StringToLowerCase, ArrayJoin, isNull, assign,
|
|
2
|
+
import { seal, create, isFunction as isFunction$1, ArrayPush as ArrayPush$1, isUndefined as isUndefined$1, ArrayIndexOf, ArraySplice, StringToLowerCase, ArrayJoin, isNull, assign, defineProperties, forEach, getOwnPropertyNames as getOwnPropertyNames$1, getPrototypeOf as getPrototypeOf$1, setPrototypeOf, getPropertyDescriptor, isObject, keys, AriaPropNameToAttrNameMap, assert, defineProperty, KEY__SYNTHETIC_MODE, toString as toString$1, isFalse, isTrue, getOwnPropertyDescriptor as getOwnPropertyDescriptor$1, freeze, htmlPropertyToAttribute, ArraySlice, hasOwnProperty as hasOwnProperty$1, StringCharCodeAt, isString, StringSlice, ArrayFilter, isArray as isArray$1, isNumber, StringReplace, KEY__SHADOW_RESOLVER, KEY__SCOPED_CSS, noop, ArrayUnshift, isFrozen } from '@lwc/shared';
|
|
3
3
|
import { runtimeFlags } from '@lwc/features';
|
|
4
4
|
export { setFeatureFlag, setFeatureFlagForTest } from '@lwc/features';
|
|
5
5
|
|
|
@@ -439,62 +439,204 @@ function logWarn(message, vm) {
|
|
|
439
439
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
440
440
|
*/
|
|
441
441
|
|
|
442
|
-
function
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
442
|
+
function isUndef(s) {
|
|
443
|
+
return s === undefined;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
function sameVnode(vnode1, vnode2) {
|
|
447
|
+
return vnode1.key === vnode2.key && vnode1.sel === vnode2.sel;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
function isVNode(vnode) {
|
|
451
|
+
return vnode != null;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
function createKeyToOldIdx(children, beginIdx, endIdx) {
|
|
455
|
+
const map = {};
|
|
456
|
+
let j, key, ch; // TODO [#1637]: simplify this by assuming that all vnodes has keys
|
|
457
|
+
|
|
458
|
+
for (j = beginIdx; j <= endIdx; ++j) {
|
|
459
|
+
ch = children[j];
|
|
452
460
|
|
|
453
|
-
|
|
454
|
-
|
|
461
|
+
if (isVNode(ch)) {
|
|
462
|
+
key = ch.key;
|
|
463
|
+
|
|
464
|
+
if (key !== undefined) {
|
|
465
|
+
map[key] = j;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
455
468
|
}
|
|
469
|
+
|
|
470
|
+
return map;
|
|
456
471
|
}
|
|
457
472
|
|
|
458
|
-
function
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
473
|
+
function addVnodes(parentElm, before, vnodes, startIdx, endIdx) {
|
|
474
|
+
for (; startIdx <= endIdx; ++startIdx) {
|
|
475
|
+
const ch = vnodes[startIdx];
|
|
476
|
+
|
|
477
|
+
if (isVNode(ch)) {
|
|
478
|
+
ch.hook.create(ch);
|
|
479
|
+
ch.hook.insert(ch, parentElm, before);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
462
482
|
}
|
|
463
483
|
|
|
464
|
-
function
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
484
|
+
function removeVnodes(parentElm, vnodes, startIdx, endIdx) {
|
|
485
|
+
for (; startIdx <= endIdx; ++startIdx) {
|
|
486
|
+
const ch = vnodes[startIdx]; // text nodes do not have logic associated to them
|
|
487
|
+
|
|
488
|
+
if (isVNode(ch)) {
|
|
489
|
+
ch.hook.remove(ch, parentElm);
|
|
490
|
+
}
|
|
470
491
|
}
|
|
471
492
|
}
|
|
472
493
|
|
|
473
|
-
function
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
494
|
+
function updateDynamicChildren(parentElm, oldCh, newCh) {
|
|
495
|
+
let oldStartIdx = 0;
|
|
496
|
+
let newStartIdx = 0;
|
|
497
|
+
let oldEndIdx = oldCh.length - 1;
|
|
498
|
+
let oldStartVnode = oldCh[0];
|
|
499
|
+
let oldEndVnode = oldCh[oldEndIdx];
|
|
500
|
+
const newChEnd = newCh.length - 1;
|
|
501
|
+
let newEndIdx = newChEnd;
|
|
502
|
+
let newStartVnode = newCh[0];
|
|
503
|
+
let newEndVnode = newCh[newEndIdx];
|
|
504
|
+
let oldKeyToIdx;
|
|
505
|
+
let idxInOld;
|
|
506
|
+
let elmToMove;
|
|
507
|
+
let before;
|
|
508
|
+
|
|
509
|
+
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
|
510
|
+
if (!isVNode(oldStartVnode)) {
|
|
511
|
+
oldStartVnode = oldCh[++oldStartIdx]; // Vnode might have been moved left
|
|
512
|
+
} else if (!isVNode(oldEndVnode)) {
|
|
513
|
+
oldEndVnode = oldCh[--oldEndIdx];
|
|
514
|
+
} else if (!isVNode(newStartVnode)) {
|
|
515
|
+
newStartVnode = newCh[++newStartIdx];
|
|
516
|
+
} else if (!isVNode(newEndVnode)) {
|
|
517
|
+
newEndVnode = newCh[--newEndIdx];
|
|
518
|
+
} else if (sameVnode(oldStartVnode, newStartVnode)) {
|
|
519
|
+
patchVnode(oldStartVnode, newStartVnode);
|
|
520
|
+
oldStartVnode = oldCh[++oldStartIdx];
|
|
521
|
+
newStartVnode = newCh[++newStartIdx];
|
|
522
|
+
} else if (sameVnode(oldEndVnode, newEndVnode)) {
|
|
523
|
+
patchVnode(oldEndVnode, newEndVnode);
|
|
524
|
+
oldEndVnode = oldCh[--oldEndIdx];
|
|
525
|
+
newEndVnode = newCh[--newEndIdx];
|
|
526
|
+
} else if (sameVnode(oldStartVnode, newEndVnode)) {
|
|
527
|
+
// Vnode moved right
|
|
528
|
+
patchVnode(oldStartVnode, newEndVnode);
|
|
529
|
+
newEndVnode.hook.move(oldStartVnode, parentElm, nextSibling(oldEndVnode.elm));
|
|
530
|
+
oldStartVnode = oldCh[++oldStartIdx];
|
|
531
|
+
newEndVnode = newCh[--newEndIdx];
|
|
532
|
+
} else if (sameVnode(oldEndVnode, newStartVnode)) {
|
|
533
|
+
// Vnode moved left
|
|
534
|
+
patchVnode(oldEndVnode, newStartVnode);
|
|
535
|
+
newStartVnode.hook.move(oldEndVnode, parentElm, oldStartVnode.elm);
|
|
536
|
+
oldEndVnode = oldCh[--oldEndIdx];
|
|
537
|
+
newStartVnode = newCh[++newStartIdx];
|
|
538
|
+
} else {
|
|
539
|
+
if (oldKeyToIdx === undefined) {
|
|
540
|
+
oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
idxInOld = oldKeyToIdx[newStartVnode.key];
|
|
544
|
+
|
|
545
|
+
if (isUndef(idxInOld)) {
|
|
546
|
+
// New element
|
|
547
|
+
newStartVnode.hook.create(newStartVnode);
|
|
548
|
+
newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
|
|
549
|
+
newStartVnode = newCh[++newStartIdx];
|
|
550
|
+
} else {
|
|
551
|
+
elmToMove = oldCh[idxInOld];
|
|
552
|
+
|
|
553
|
+
if (isVNode(elmToMove)) {
|
|
554
|
+
if (elmToMove.sel !== newStartVnode.sel) {
|
|
555
|
+
// New element
|
|
556
|
+
newStartVnode.hook.create(newStartVnode);
|
|
557
|
+
newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
|
|
558
|
+
} else {
|
|
559
|
+
patchVnode(elmToMove, newStartVnode);
|
|
560
|
+
oldCh[idxInOld] = undefined;
|
|
561
|
+
newStartVnode.hook.move(elmToMove, parentElm, oldStartVnode.elm);
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
newStartVnode = newCh[++newStartIdx];
|
|
566
|
+
}
|
|
478
567
|
}
|
|
479
|
-
}
|
|
568
|
+
}
|
|
480
569
|
|
|
481
|
-
if (
|
|
570
|
+
if (oldStartIdx <= oldEndIdx || newStartIdx <= newEndIdx) {
|
|
571
|
+
if (oldStartIdx > oldEndIdx) {
|
|
572
|
+
// There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
|
|
573
|
+
// already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
|
|
574
|
+
let i = newEndIdx;
|
|
575
|
+
let n;
|
|
576
|
+
|
|
577
|
+
do {
|
|
578
|
+
n = newCh[++i];
|
|
579
|
+
} while (!isVNode(n) && i < newChEnd);
|
|
580
|
+
|
|
581
|
+
before = isVNode(n) ? n.elm : null;
|
|
582
|
+
addVnodes(parentElm, before, newCh, newStartIdx, newEndIdx);
|
|
583
|
+
} else {
|
|
584
|
+
removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
function updateStaticChildren(parentElm, oldCh, newCh) {
|
|
589
|
+
const oldChLength = oldCh.length;
|
|
590
|
+
const newChLength = newCh.length;
|
|
591
|
+
|
|
592
|
+
if (oldChLength === 0) {
|
|
593
|
+
// the old list is empty, we can directly insert anything new
|
|
594
|
+
addVnodes(parentElm, null, newCh, 0, newChLength);
|
|
482
595
|
return;
|
|
483
596
|
}
|
|
484
597
|
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
598
|
+
if (newChLength === 0) {
|
|
599
|
+
// the old list is nonempty and the new list is empty so we can directly remove all old nodes
|
|
600
|
+
// this is the case in which the dynamic children of an if-directive should be removed
|
|
601
|
+
removeVnodes(parentElm, oldCh, 0, oldChLength);
|
|
602
|
+
return;
|
|
603
|
+
} // if the old list is not empty, the new list MUST have the same
|
|
604
|
+
// amount of nodes, that's why we call this static children
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
let referenceElm = null;
|
|
608
|
+
|
|
609
|
+
for (let i = newChLength - 1; i >= 0; i -= 1) {
|
|
610
|
+
const vnode = newCh[i];
|
|
611
|
+
const oldVNode = oldCh[i];
|
|
612
|
+
|
|
613
|
+
if (vnode !== oldVNode) {
|
|
614
|
+
if (isVNode(oldVNode)) {
|
|
615
|
+
if (isVNode(vnode)) {
|
|
616
|
+
// both vnodes must be equivalent, and se just need to patch them
|
|
617
|
+
patchVnode(oldVNode, vnode);
|
|
618
|
+
referenceElm = vnode.elm;
|
|
619
|
+
} else {
|
|
620
|
+
// removing the old vnode since the new one is null
|
|
621
|
+
oldVNode.hook.remove(oldVNode, parentElm);
|
|
622
|
+
}
|
|
623
|
+
} else if (isVNode(vnode)) {
|
|
624
|
+
// this condition is unnecessary
|
|
625
|
+
vnode.hook.create(vnode); // insert the new node one since the old one is null
|
|
488
626
|
|
|
489
|
-
|
|
490
|
-
|
|
627
|
+
vnode.hook.insert(vnode, parentElm, referenceElm);
|
|
628
|
+
referenceElm = vnode.elm;
|
|
629
|
+
}
|
|
630
|
+
}
|
|
491
631
|
}
|
|
492
632
|
}
|
|
493
633
|
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
634
|
+
function patchVnode(oldVnode, vnode) {
|
|
635
|
+
if (oldVnode !== vnode) {
|
|
636
|
+
vnode.elm = oldVnode.elm;
|
|
637
|
+
vnode.hook.update(oldVnode, vnode);
|
|
638
|
+
}
|
|
639
|
+
}
|
|
498
640
|
|
|
499
641
|
/*
|
|
500
642
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -618,573 +760,49 @@ function unlockAttribute(elm, key) {
|
|
|
618
760
|
* SPDX-License-Identifier: MIT
|
|
619
761
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
620
762
|
*/
|
|
621
|
-
const xlinkNS = 'http://www.w3.org/1999/xlink';
|
|
622
|
-
const xmlNS = 'http://www.w3.org/XML/1998/namespace';
|
|
623
|
-
const ColonCharCode = 58;
|
|
624
|
-
|
|
625
|
-
function updateAttrs(oldVnode, vnode) {
|
|
626
|
-
const {
|
|
627
|
-
data: {
|
|
628
|
-
attrs
|
|
629
|
-
}
|
|
630
|
-
} = vnode;
|
|
631
763
|
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
764
|
+
function generateDataDescriptor(options) {
|
|
765
|
+
return assign({
|
|
766
|
+
configurable: true,
|
|
767
|
+
enumerable: true,
|
|
768
|
+
writable: true
|
|
769
|
+
}, options);
|
|
770
|
+
}
|
|
635
771
|
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
}
|
|
772
|
+
function generateAccessorDescriptor(options) {
|
|
773
|
+
return assign({
|
|
774
|
+
configurable: true,
|
|
775
|
+
enumerable: true
|
|
776
|
+
}, options);
|
|
777
|
+
}
|
|
641
778
|
|
|
642
|
-
|
|
643
|
-
|
|
779
|
+
let isDomMutationAllowed = false;
|
|
780
|
+
function unlockDomMutation() {
|
|
781
|
+
if (process.env.NODE_ENV === 'production') {
|
|
782
|
+
// this method should never leak to prod
|
|
783
|
+
throw new ReferenceError();
|
|
644
784
|
}
|
|
645
785
|
|
|
646
|
-
|
|
647
|
-
|
|
786
|
+
isDomMutationAllowed = true;
|
|
787
|
+
}
|
|
788
|
+
function lockDomMutation() {
|
|
789
|
+
if (process.env.NODE_ENV === 'production') {
|
|
790
|
+
// this method should never leak to prod
|
|
791
|
+
throw new ReferenceError();
|
|
648
792
|
}
|
|
649
793
|
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
oldAttrs = isUndefined$1(oldAttrs) ? EmptyObject : oldAttrs; // update modified attributes, add new attributes
|
|
653
|
-
// this routine is only useful for data-* attributes in all kind of elements
|
|
654
|
-
// and aria-* in standard elements (custom elements will use props for these)
|
|
794
|
+
isDomMutationAllowed = false;
|
|
795
|
+
}
|
|
655
796
|
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
797
|
+
function logMissingPortalError(name, type) {
|
|
798
|
+
return logError(`The \`${name}\` ${type} is available only on elements that use the \`lwc:dom="manual"\` directive.`);
|
|
799
|
+
}
|
|
659
800
|
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
setAttribute(elm, key, cur, xmlNS);
|
|
666
|
-
} else if (StringCharCodeAt.call(key, 5) === ColonCharCode) {
|
|
667
|
-
// Assume xlink namespace
|
|
668
|
-
setAttribute(elm, key, cur, xlinkNS);
|
|
669
|
-
} else if (isNull(cur) || isUndefined$1(cur)) {
|
|
670
|
-
removeAttribute(elm, key);
|
|
671
|
-
} else {
|
|
672
|
-
setAttribute(elm, key, cur);
|
|
673
|
-
}
|
|
674
|
-
|
|
675
|
-
lockAttribute();
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
const emptyVNode$3 = {
|
|
681
|
-
data: {}
|
|
682
|
-
};
|
|
683
|
-
var modAttrs = {
|
|
684
|
-
create: vnode => updateAttrs(emptyVNode$3, vnode),
|
|
685
|
-
update: updateAttrs
|
|
686
|
-
};
|
|
687
|
-
|
|
688
|
-
/*
|
|
689
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
690
|
-
* All rights reserved.
|
|
691
|
-
* SPDX-License-Identifier: MIT
|
|
692
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
693
|
-
*/
|
|
694
|
-
|
|
695
|
-
function isLiveBindingProp(sel, key) {
|
|
696
|
-
// For properties with live bindings, we read values from the DOM element
|
|
697
|
-
// instead of relying on internally tracked values.
|
|
698
|
-
return sel === 'input' && (key === 'value' || key === 'checked');
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
function update(oldVnode, vnode) {
|
|
702
|
-
const props = vnode.data.props;
|
|
703
|
-
|
|
704
|
-
if (isUndefined$1(props)) {
|
|
705
|
-
return;
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
const oldProps = oldVnode.data.props;
|
|
709
|
-
|
|
710
|
-
if (oldProps === props) {
|
|
711
|
-
return;
|
|
712
|
-
}
|
|
713
|
-
|
|
714
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
715
|
-
assert.invariant(isUndefined$1(oldProps) || keys(oldProps).join(',') === keys(props).join(','), 'vnode.data.props cannot change shape.');
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
const isFirstPatch = isUndefined$1(oldProps);
|
|
719
|
-
const {
|
|
720
|
-
elm,
|
|
721
|
-
sel
|
|
722
|
-
} = vnode;
|
|
723
|
-
|
|
724
|
-
for (const key in props) {
|
|
725
|
-
const cur = props[key]; // if it is the first time this element is patched, or the current value is different to the previous value...
|
|
726
|
-
|
|
727
|
-
if (isFirstPatch || cur !== (isLiveBindingProp(sel, key) ? getProperty(elm, key) : oldProps[key])) {
|
|
728
|
-
setProperty(elm, key, cur);
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
}
|
|
732
|
-
|
|
733
|
-
const emptyVNode$2 = {
|
|
734
|
-
data: {}
|
|
735
|
-
};
|
|
736
|
-
var modProps = {
|
|
737
|
-
create: vnode => update(emptyVNode$2, vnode),
|
|
738
|
-
update
|
|
739
|
-
};
|
|
740
|
-
|
|
741
|
-
/*
|
|
742
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
743
|
-
* All rights reserved.
|
|
744
|
-
* SPDX-License-Identifier: MIT
|
|
745
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
746
|
-
*/
|
|
747
|
-
const classNameToClassMap = create(null);
|
|
748
|
-
|
|
749
|
-
function getMapFromClassName(className) {
|
|
750
|
-
// Intentionally using == to match undefined and null values from computed style attribute
|
|
751
|
-
if (className == null) {
|
|
752
|
-
return EmptyObject;
|
|
753
|
-
} // computed class names must be string
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
className = isString(className) ? className : className + '';
|
|
757
|
-
let map = classNameToClassMap[className];
|
|
758
|
-
|
|
759
|
-
if (map) {
|
|
760
|
-
return map;
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
map = create(null);
|
|
764
|
-
let start = 0;
|
|
765
|
-
let o;
|
|
766
|
-
const len = className.length;
|
|
767
|
-
|
|
768
|
-
for (o = 0; o < len; o++) {
|
|
769
|
-
if (StringCharCodeAt.call(className, o) === SPACE_CHAR) {
|
|
770
|
-
if (o > start) {
|
|
771
|
-
map[StringSlice.call(className, start, o)] = true;
|
|
772
|
-
}
|
|
773
|
-
|
|
774
|
-
start = o + 1;
|
|
775
|
-
}
|
|
776
|
-
}
|
|
777
|
-
|
|
778
|
-
if (o > start) {
|
|
779
|
-
map[StringSlice.call(className, start, o)] = true;
|
|
780
|
-
}
|
|
781
|
-
|
|
782
|
-
classNameToClassMap[className] = map;
|
|
783
|
-
|
|
784
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
785
|
-
// just to make sure that this object never changes as part of the diffing algo
|
|
786
|
-
freeze(map);
|
|
787
|
-
}
|
|
788
|
-
|
|
789
|
-
return map;
|
|
790
|
-
}
|
|
791
|
-
|
|
792
|
-
function updateClassAttribute(oldVnode, vnode) {
|
|
793
|
-
const {
|
|
794
|
-
elm,
|
|
795
|
-
data: {
|
|
796
|
-
className: newClass
|
|
797
|
-
}
|
|
798
|
-
} = vnode;
|
|
799
|
-
const {
|
|
800
|
-
data: {
|
|
801
|
-
className: oldClass
|
|
802
|
-
}
|
|
803
|
-
} = oldVnode;
|
|
804
|
-
|
|
805
|
-
if (oldClass === newClass) {
|
|
806
|
-
return;
|
|
807
|
-
}
|
|
808
|
-
|
|
809
|
-
const classList = getClassList(elm);
|
|
810
|
-
const newClassMap = getMapFromClassName(newClass);
|
|
811
|
-
const oldClassMap = getMapFromClassName(oldClass);
|
|
812
|
-
let name;
|
|
813
|
-
|
|
814
|
-
for (name in oldClassMap) {
|
|
815
|
-
// remove only if it is not in the new class collection and it is not set from within the instance
|
|
816
|
-
if (isUndefined$1(newClassMap[name])) {
|
|
817
|
-
classList.remove(name);
|
|
818
|
-
}
|
|
819
|
-
}
|
|
820
|
-
|
|
821
|
-
for (name in newClassMap) {
|
|
822
|
-
if (isUndefined$1(oldClassMap[name])) {
|
|
823
|
-
classList.add(name);
|
|
824
|
-
}
|
|
825
|
-
}
|
|
826
|
-
}
|
|
827
|
-
|
|
828
|
-
const emptyVNode$1 = {
|
|
829
|
-
data: {}
|
|
830
|
-
};
|
|
831
|
-
var modComputedClassName = {
|
|
832
|
-
create: vnode => updateClassAttribute(emptyVNode$1, vnode),
|
|
833
|
-
update: updateClassAttribute
|
|
834
|
-
};
|
|
835
|
-
|
|
836
|
-
/*
|
|
837
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
838
|
-
* All rights reserved.
|
|
839
|
-
* SPDX-License-Identifier: MIT
|
|
840
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
841
|
-
*/
|
|
842
|
-
|
|
843
|
-
function updateStyleAttribute(oldVnode, vnode) {
|
|
844
|
-
const {
|
|
845
|
-
elm,
|
|
846
|
-
data: {
|
|
847
|
-
style: newStyle
|
|
848
|
-
}
|
|
849
|
-
} = vnode;
|
|
850
|
-
|
|
851
|
-
if (oldVnode.data.style === newStyle) {
|
|
852
|
-
return;
|
|
853
|
-
}
|
|
854
|
-
|
|
855
|
-
if (!isString(newStyle) || newStyle === '') {
|
|
856
|
-
removeAttribute(elm, 'style');
|
|
857
|
-
} else {
|
|
858
|
-
setAttribute(elm, 'style', newStyle);
|
|
859
|
-
}
|
|
860
|
-
}
|
|
861
|
-
|
|
862
|
-
const emptyVNode = {
|
|
863
|
-
data: {}
|
|
864
|
-
};
|
|
865
|
-
var modComputedStyle = {
|
|
866
|
-
create: vnode => updateStyleAttribute(emptyVNode, vnode),
|
|
867
|
-
update: updateStyleAttribute
|
|
868
|
-
};
|
|
869
|
-
|
|
870
|
-
/*
|
|
871
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
872
|
-
* All rights reserved.
|
|
873
|
-
* SPDX-License-Identifier: MIT
|
|
874
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
875
|
-
*/
|
|
876
|
-
// The compiler takes care of transforming the inline classnames into an object. It's faster to set the
|
|
877
|
-
// different classnames properties individually instead of via a string.
|
|
878
|
-
|
|
879
|
-
function createClassAttribute(vnode) {
|
|
880
|
-
const {
|
|
881
|
-
elm,
|
|
882
|
-
data: {
|
|
883
|
-
classMap
|
|
884
|
-
}
|
|
885
|
-
} = vnode;
|
|
886
|
-
|
|
887
|
-
if (isUndefined$1(classMap)) {
|
|
888
|
-
return;
|
|
889
|
-
}
|
|
890
|
-
|
|
891
|
-
const classList = getClassList(elm);
|
|
892
|
-
|
|
893
|
-
for (const name in classMap) {
|
|
894
|
-
classList.add(name);
|
|
895
|
-
}
|
|
896
|
-
}
|
|
897
|
-
|
|
898
|
-
var modStaticClassName = {
|
|
899
|
-
create: createClassAttribute
|
|
900
|
-
};
|
|
901
|
-
|
|
902
|
-
/*
|
|
903
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
904
|
-
* All rights reserved.
|
|
905
|
-
* SPDX-License-Identifier: MIT
|
|
906
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
907
|
-
*/
|
|
908
|
-
// The compiler takes care of transforming the inline style into an object. It's faster to set the
|
|
909
|
-
// different style properties individually instead of via a string.
|
|
910
|
-
|
|
911
|
-
function createStyleAttribute(vnode) {
|
|
912
|
-
const {
|
|
913
|
-
elm,
|
|
914
|
-
data: {
|
|
915
|
-
styleDecls
|
|
916
|
-
}
|
|
917
|
-
} = vnode;
|
|
918
|
-
|
|
919
|
-
if (isUndefined$1(styleDecls)) {
|
|
920
|
-
return;
|
|
921
|
-
}
|
|
922
|
-
|
|
923
|
-
for (let i = 0; i < styleDecls.length; i++) {
|
|
924
|
-
const [prop, value, important] = styleDecls[i];
|
|
925
|
-
setCSSStyleProperty(elm, prop, value, important);
|
|
926
|
-
}
|
|
927
|
-
}
|
|
928
|
-
|
|
929
|
-
var modStaticStyle = {
|
|
930
|
-
create: createStyleAttribute
|
|
931
|
-
};
|
|
932
|
-
|
|
933
|
-
/*
|
|
934
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
935
|
-
* All rights reserved.
|
|
936
|
-
* SPDX-License-Identifier: MIT
|
|
937
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
938
|
-
*/
|
|
939
|
-
|
|
940
|
-
function isUndef(s) {
|
|
941
|
-
return s === undefined;
|
|
942
|
-
}
|
|
943
|
-
|
|
944
|
-
function sameVnode(vnode1, vnode2) {
|
|
945
|
-
return vnode1.key === vnode2.key && vnode1.sel === vnode2.sel;
|
|
946
|
-
}
|
|
947
|
-
|
|
948
|
-
function isVNode(vnode) {
|
|
949
|
-
return vnode != null;
|
|
950
|
-
}
|
|
951
|
-
|
|
952
|
-
function createKeyToOldIdx(children, beginIdx, endIdx) {
|
|
953
|
-
const map = {};
|
|
954
|
-
let j, key, ch; // TODO [#1637]: simplify this by assuming that all vnodes has keys
|
|
955
|
-
|
|
956
|
-
for (j = beginIdx; j <= endIdx; ++j) {
|
|
957
|
-
ch = children[j];
|
|
958
|
-
|
|
959
|
-
if (isVNode(ch)) {
|
|
960
|
-
key = ch.key;
|
|
961
|
-
|
|
962
|
-
if (key !== undefined) {
|
|
963
|
-
map[key] = j;
|
|
964
|
-
}
|
|
965
|
-
}
|
|
966
|
-
}
|
|
967
|
-
|
|
968
|
-
return map;
|
|
969
|
-
}
|
|
970
|
-
|
|
971
|
-
function addVnodes(parentElm, before, vnodes, startIdx, endIdx) {
|
|
972
|
-
for (; startIdx <= endIdx; ++startIdx) {
|
|
973
|
-
const ch = vnodes[startIdx];
|
|
974
|
-
|
|
975
|
-
if (isVNode(ch)) {
|
|
976
|
-
ch.hook.create(ch);
|
|
977
|
-
ch.hook.insert(ch, parentElm, before);
|
|
978
|
-
}
|
|
979
|
-
}
|
|
980
|
-
}
|
|
981
|
-
|
|
982
|
-
function removeVnodes(parentElm, vnodes, startIdx, endIdx) {
|
|
983
|
-
for (; startIdx <= endIdx; ++startIdx) {
|
|
984
|
-
const ch = vnodes[startIdx]; // text nodes do not have logic associated to them
|
|
985
|
-
|
|
986
|
-
if (isVNode(ch)) {
|
|
987
|
-
ch.hook.remove(ch, parentElm);
|
|
988
|
-
}
|
|
989
|
-
}
|
|
990
|
-
}
|
|
991
|
-
|
|
992
|
-
function updateDynamicChildren(parentElm, oldCh, newCh) {
|
|
993
|
-
let oldStartIdx = 0;
|
|
994
|
-
let newStartIdx = 0;
|
|
995
|
-
let oldEndIdx = oldCh.length - 1;
|
|
996
|
-
let oldStartVnode = oldCh[0];
|
|
997
|
-
let oldEndVnode = oldCh[oldEndIdx];
|
|
998
|
-
const newChEnd = newCh.length - 1;
|
|
999
|
-
let newEndIdx = newChEnd;
|
|
1000
|
-
let newStartVnode = newCh[0];
|
|
1001
|
-
let newEndVnode = newCh[newEndIdx];
|
|
1002
|
-
let oldKeyToIdx;
|
|
1003
|
-
let idxInOld;
|
|
1004
|
-
let elmToMove;
|
|
1005
|
-
let before;
|
|
1006
|
-
|
|
1007
|
-
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
|
1008
|
-
if (!isVNode(oldStartVnode)) {
|
|
1009
|
-
oldStartVnode = oldCh[++oldStartIdx]; // Vnode might have been moved left
|
|
1010
|
-
} else if (!isVNode(oldEndVnode)) {
|
|
1011
|
-
oldEndVnode = oldCh[--oldEndIdx];
|
|
1012
|
-
} else if (!isVNode(newStartVnode)) {
|
|
1013
|
-
newStartVnode = newCh[++newStartIdx];
|
|
1014
|
-
} else if (!isVNode(newEndVnode)) {
|
|
1015
|
-
newEndVnode = newCh[--newEndIdx];
|
|
1016
|
-
} else if (sameVnode(oldStartVnode, newStartVnode)) {
|
|
1017
|
-
patchVnode(oldStartVnode, newStartVnode);
|
|
1018
|
-
oldStartVnode = oldCh[++oldStartIdx];
|
|
1019
|
-
newStartVnode = newCh[++newStartIdx];
|
|
1020
|
-
} else if (sameVnode(oldEndVnode, newEndVnode)) {
|
|
1021
|
-
patchVnode(oldEndVnode, newEndVnode);
|
|
1022
|
-
oldEndVnode = oldCh[--oldEndIdx];
|
|
1023
|
-
newEndVnode = newCh[--newEndIdx];
|
|
1024
|
-
} else if (sameVnode(oldStartVnode, newEndVnode)) {
|
|
1025
|
-
// Vnode moved right
|
|
1026
|
-
patchVnode(oldStartVnode, newEndVnode);
|
|
1027
|
-
newEndVnode.hook.move(oldStartVnode, parentElm, nextSibling(oldEndVnode.elm));
|
|
1028
|
-
oldStartVnode = oldCh[++oldStartIdx];
|
|
1029
|
-
newEndVnode = newCh[--newEndIdx];
|
|
1030
|
-
} else if (sameVnode(oldEndVnode, newStartVnode)) {
|
|
1031
|
-
// Vnode moved left
|
|
1032
|
-
patchVnode(oldEndVnode, newStartVnode);
|
|
1033
|
-
newStartVnode.hook.move(oldEndVnode, parentElm, oldStartVnode.elm);
|
|
1034
|
-
oldEndVnode = oldCh[--oldEndIdx];
|
|
1035
|
-
newStartVnode = newCh[++newStartIdx];
|
|
1036
|
-
} else {
|
|
1037
|
-
if (oldKeyToIdx === undefined) {
|
|
1038
|
-
oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
|
|
1039
|
-
}
|
|
1040
|
-
|
|
1041
|
-
idxInOld = oldKeyToIdx[newStartVnode.key];
|
|
1042
|
-
|
|
1043
|
-
if (isUndef(idxInOld)) {
|
|
1044
|
-
// New element
|
|
1045
|
-
newStartVnode.hook.create(newStartVnode);
|
|
1046
|
-
newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
|
|
1047
|
-
newStartVnode = newCh[++newStartIdx];
|
|
1048
|
-
} else {
|
|
1049
|
-
elmToMove = oldCh[idxInOld];
|
|
1050
|
-
|
|
1051
|
-
if (isVNode(elmToMove)) {
|
|
1052
|
-
if (elmToMove.sel !== newStartVnode.sel) {
|
|
1053
|
-
// New element
|
|
1054
|
-
newStartVnode.hook.create(newStartVnode);
|
|
1055
|
-
newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
|
|
1056
|
-
} else {
|
|
1057
|
-
patchVnode(elmToMove, newStartVnode);
|
|
1058
|
-
oldCh[idxInOld] = undefined;
|
|
1059
|
-
newStartVnode.hook.move(elmToMove, parentElm, oldStartVnode.elm);
|
|
1060
|
-
}
|
|
1061
|
-
}
|
|
1062
|
-
|
|
1063
|
-
newStartVnode = newCh[++newStartIdx];
|
|
1064
|
-
}
|
|
1065
|
-
}
|
|
1066
|
-
}
|
|
1067
|
-
|
|
1068
|
-
if (oldStartIdx <= oldEndIdx || newStartIdx <= newEndIdx) {
|
|
1069
|
-
if (oldStartIdx > oldEndIdx) {
|
|
1070
|
-
// There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
|
|
1071
|
-
// already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
|
|
1072
|
-
let i = newEndIdx;
|
|
1073
|
-
let n;
|
|
1074
|
-
|
|
1075
|
-
do {
|
|
1076
|
-
n = newCh[++i];
|
|
1077
|
-
} while (!isVNode(n) && i < newChEnd);
|
|
1078
|
-
|
|
1079
|
-
before = isVNode(n) ? n.elm : null;
|
|
1080
|
-
addVnodes(parentElm, before, newCh, newStartIdx, newEndIdx);
|
|
1081
|
-
} else {
|
|
1082
|
-
removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
|
|
1083
|
-
}
|
|
1084
|
-
}
|
|
1085
|
-
}
|
|
1086
|
-
function updateStaticChildren(parentElm, oldCh, newCh) {
|
|
1087
|
-
const oldChLength = oldCh.length;
|
|
1088
|
-
const newChLength = newCh.length;
|
|
1089
|
-
|
|
1090
|
-
if (oldChLength === 0) {
|
|
1091
|
-
// the old list is empty, we can directly insert anything new
|
|
1092
|
-
addVnodes(parentElm, null, newCh, 0, newChLength);
|
|
1093
|
-
return;
|
|
1094
|
-
}
|
|
1095
|
-
|
|
1096
|
-
if (newChLength === 0) {
|
|
1097
|
-
// the old list is nonempty and the new list is empty so we can directly remove all old nodes
|
|
1098
|
-
// this is the case in which the dynamic children of an if-directive should be removed
|
|
1099
|
-
removeVnodes(parentElm, oldCh, 0, oldChLength);
|
|
1100
|
-
return;
|
|
1101
|
-
} // if the old list is not empty, the new list MUST have the same
|
|
1102
|
-
// amount of nodes, that's why we call this static children
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
let referenceElm = null;
|
|
1106
|
-
|
|
1107
|
-
for (let i = newChLength - 1; i >= 0; i -= 1) {
|
|
1108
|
-
const vnode = newCh[i];
|
|
1109
|
-
const oldVNode = oldCh[i];
|
|
1110
|
-
|
|
1111
|
-
if (vnode !== oldVNode) {
|
|
1112
|
-
if (isVNode(oldVNode)) {
|
|
1113
|
-
if (isVNode(vnode)) {
|
|
1114
|
-
// both vnodes must be equivalent, and se just need to patch them
|
|
1115
|
-
patchVnode(oldVNode, vnode);
|
|
1116
|
-
referenceElm = vnode.elm;
|
|
1117
|
-
} else {
|
|
1118
|
-
// removing the old vnode since the new one is null
|
|
1119
|
-
oldVNode.hook.remove(oldVNode, parentElm);
|
|
1120
|
-
}
|
|
1121
|
-
} else if (isVNode(vnode)) {
|
|
1122
|
-
// this condition is unnecessary
|
|
1123
|
-
vnode.hook.create(vnode); // insert the new node one since the old one is null
|
|
1124
|
-
|
|
1125
|
-
vnode.hook.insert(vnode, parentElm, referenceElm);
|
|
1126
|
-
referenceElm = vnode.elm;
|
|
1127
|
-
}
|
|
1128
|
-
}
|
|
1129
|
-
}
|
|
1130
|
-
}
|
|
1131
|
-
|
|
1132
|
-
function patchVnode(oldVnode, vnode) {
|
|
1133
|
-
if (oldVnode !== vnode) {
|
|
1134
|
-
vnode.elm = oldVnode.elm;
|
|
1135
|
-
vnode.hook.update(oldVnode, vnode);
|
|
1136
|
-
}
|
|
1137
|
-
}
|
|
1138
|
-
|
|
1139
|
-
/*
|
|
1140
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
1141
|
-
* All rights reserved.
|
|
1142
|
-
* SPDX-License-Identifier: MIT
|
|
1143
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1144
|
-
*/
|
|
1145
|
-
|
|
1146
|
-
function generateDataDescriptor(options) {
|
|
1147
|
-
return assign({
|
|
1148
|
-
configurable: true,
|
|
1149
|
-
enumerable: true,
|
|
1150
|
-
writable: true
|
|
1151
|
-
}, options);
|
|
1152
|
-
}
|
|
1153
|
-
|
|
1154
|
-
function generateAccessorDescriptor(options) {
|
|
1155
|
-
return assign({
|
|
1156
|
-
configurable: true,
|
|
1157
|
-
enumerable: true
|
|
1158
|
-
}, options);
|
|
1159
|
-
}
|
|
1160
|
-
|
|
1161
|
-
let isDomMutationAllowed = false;
|
|
1162
|
-
function unlockDomMutation() {
|
|
1163
|
-
if (process.env.NODE_ENV === 'production') {
|
|
1164
|
-
// this method should never leak to prod
|
|
1165
|
-
throw new ReferenceError();
|
|
1166
|
-
}
|
|
1167
|
-
|
|
1168
|
-
isDomMutationAllowed = true;
|
|
1169
|
-
}
|
|
1170
|
-
function lockDomMutation() {
|
|
1171
|
-
if (process.env.NODE_ENV === 'production') {
|
|
1172
|
-
// this method should never leak to prod
|
|
1173
|
-
throw new ReferenceError();
|
|
1174
|
-
}
|
|
1175
|
-
|
|
1176
|
-
isDomMutationAllowed = false;
|
|
1177
|
-
}
|
|
1178
|
-
|
|
1179
|
-
function logMissingPortalError(name, type) {
|
|
1180
|
-
return logError(`The \`${name}\` ${type} is available only on elements that use the \`lwc:dom="manual"\` directive.`);
|
|
1181
|
-
}
|
|
1182
|
-
|
|
1183
|
-
function patchElementWithRestrictions(elm, options) {
|
|
1184
|
-
if (process.env.NODE_ENV === 'production') {
|
|
1185
|
-
// this method should never leak to prod
|
|
1186
|
-
throw new ReferenceError();
|
|
1187
|
-
}
|
|
801
|
+
function patchElementWithRestrictions(elm, options) {
|
|
802
|
+
if (process.env.NODE_ENV === 'production') {
|
|
803
|
+
// this method should never leak to prod
|
|
804
|
+
throw new ReferenceError();
|
|
805
|
+
}
|
|
1188
806
|
|
|
1189
807
|
const originalOuterHTMLDescriptor = getPropertyDescriptor(elm, 'outerHTML');
|
|
1190
808
|
const descriptors = {
|
|
@@ -3704,145 +3322,461 @@ function setActiveVM(vm) {
|
|
|
3704
3322
|
throw new ReferenceError();
|
|
3705
3323
|
}
|
|
3706
3324
|
|
|
3707
|
-
if (runtimeFlags.ENABLE_HMR) {
|
|
3708
|
-
// tracking active component
|
|
3709
|
-
const Ctor = vm.def.ctor;
|
|
3710
|
-
let componentVMs = activeComponents.get(Ctor);
|
|
3325
|
+
if (runtimeFlags.ENABLE_HMR) {
|
|
3326
|
+
// tracking active component
|
|
3327
|
+
const Ctor = vm.def.ctor;
|
|
3328
|
+
let componentVMs = activeComponents.get(Ctor);
|
|
3329
|
+
|
|
3330
|
+
if (isUndefined$1(componentVMs)) {
|
|
3331
|
+
componentVMs = new Set();
|
|
3332
|
+
activeComponents.set(Ctor, componentVMs);
|
|
3333
|
+
} // this will allow us to keep track of the hot components
|
|
3334
|
+
|
|
3335
|
+
|
|
3336
|
+
componentVMs.add(vm); // tracking active template
|
|
3337
|
+
|
|
3338
|
+
const tpl = vm.cmpTemplate;
|
|
3339
|
+
|
|
3340
|
+
if (tpl) {
|
|
3341
|
+
let templateVMs = activeTemplates.get(tpl);
|
|
3342
|
+
|
|
3343
|
+
if (isUndefined$1(templateVMs)) {
|
|
3344
|
+
templateVMs = new Set();
|
|
3345
|
+
activeTemplates.set(tpl, templateVMs);
|
|
3346
|
+
} // this will allow us to keep track of the templates that are
|
|
3347
|
+
// being used by a hot component
|
|
3348
|
+
|
|
3349
|
+
|
|
3350
|
+
templateVMs.add(vm); // tracking active styles associated to template
|
|
3351
|
+
|
|
3352
|
+
const stylesheets = tpl.stylesheets;
|
|
3353
|
+
|
|
3354
|
+
if (!isUndefined$1(stylesheets)) {
|
|
3355
|
+
flattenStylesheets(stylesheets).forEach(stylesheet => {
|
|
3356
|
+
// this is necessary because we don't hold the list of styles
|
|
3357
|
+
// in the vm, we only hold the selected (already swapped template)
|
|
3358
|
+
// but the styles attached to the template might not be the actual
|
|
3359
|
+
// active ones, but the swapped versions of those.
|
|
3360
|
+
stylesheet = getStyleOrSwappedStyle(stylesheet);
|
|
3361
|
+
let stylesheetVMs = activeStyles.get(stylesheet);
|
|
3362
|
+
|
|
3363
|
+
if (isUndefined$1(stylesheetVMs)) {
|
|
3364
|
+
stylesheetVMs = new Set();
|
|
3365
|
+
activeStyles.set(stylesheet, stylesheetVMs);
|
|
3366
|
+
} // this will allow us to keep track of the stylesheet that are
|
|
3367
|
+
// being used by a hot component
|
|
3368
|
+
|
|
3369
|
+
|
|
3370
|
+
stylesheetVMs.add(vm);
|
|
3371
|
+
});
|
|
3372
|
+
}
|
|
3373
|
+
}
|
|
3374
|
+
}
|
|
3375
|
+
}
|
|
3376
|
+
function removeActiveVM(vm) {
|
|
3377
|
+
if (process.env.NODE_ENV === 'production') {
|
|
3378
|
+
// this method should never leak to prod
|
|
3379
|
+
throw new ReferenceError();
|
|
3380
|
+
}
|
|
3381
|
+
|
|
3382
|
+
if (runtimeFlags.ENABLE_HMR) {
|
|
3383
|
+
// tracking inactive component
|
|
3384
|
+
const Ctor = vm.def.ctor;
|
|
3385
|
+
let list = activeComponents.get(Ctor);
|
|
3386
|
+
|
|
3387
|
+
if (!isUndefined$1(list)) {
|
|
3388
|
+
// deleting the vm from the set to avoid leaking memory
|
|
3389
|
+
list.delete(vm);
|
|
3390
|
+
} // removing inactive template
|
|
3391
|
+
|
|
3392
|
+
|
|
3393
|
+
const tpl = vm.cmpTemplate;
|
|
3394
|
+
|
|
3395
|
+
if (tpl) {
|
|
3396
|
+
list = activeTemplates.get(tpl);
|
|
3397
|
+
|
|
3398
|
+
if (!isUndefined$1(list)) {
|
|
3399
|
+
// deleting the vm from the set to avoid leaking memory
|
|
3400
|
+
list.delete(vm);
|
|
3401
|
+
} // removing active styles associated to template
|
|
3402
|
+
|
|
3403
|
+
|
|
3404
|
+
const styles = tpl.stylesheets;
|
|
3405
|
+
|
|
3406
|
+
if (!isUndefined$1(styles)) {
|
|
3407
|
+
flattenStylesheets(styles).forEach(style => {
|
|
3408
|
+
list = activeStyles.get(style);
|
|
3409
|
+
|
|
3410
|
+
if (!isUndefined$1(list)) {
|
|
3411
|
+
// deleting the vm from the set to avoid leaking memory
|
|
3412
|
+
list.delete(vm);
|
|
3413
|
+
}
|
|
3414
|
+
});
|
|
3415
|
+
}
|
|
3416
|
+
}
|
|
3417
|
+
}
|
|
3418
|
+
}
|
|
3419
|
+
function swapTemplate(oldTpl, newTpl) {
|
|
3420
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3421
|
+
if (isTemplateRegistered(oldTpl) && isTemplateRegistered(newTpl)) {
|
|
3422
|
+
swappedTemplateMap.set(oldTpl, newTpl);
|
|
3423
|
+
return rehydrateHotTemplate(oldTpl);
|
|
3424
|
+
} else {
|
|
3425
|
+
throw new TypeError(`Invalid Template`);
|
|
3426
|
+
}
|
|
3427
|
+
}
|
|
3428
|
+
|
|
3429
|
+
if (!runtimeFlags.ENABLE_HMR) {
|
|
3430
|
+
throw new Error('HMR is not enabled');
|
|
3431
|
+
}
|
|
3432
|
+
|
|
3433
|
+
return false;
|
|
3434
|
+
}
|
|
3435
|
+
function swapComponent(oldComponent, newComponent) {
|
|
3436
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3437
|
+
if (isComponentConstructor(oldComponent) && isComponentConstructor(newComponent)) {
|
|
3438
|
+
swappedComponentMap.set(oldComponent, newComponent);
|
|
3439
|
+
return rehydrateHotComponent(oldComponent);
|
|
3440
|
+
} else {
|
|
3441
|
+
throw new TypeError(`Invalid Component`);
|
|
3442
|
+
}
|
|
3443
|
+
}
|
|
3444
|
+
|
|
3445
|
+
if (!runtimeFlags.ENABLE_HMR) {
|
|
3446
|
+
throw new Error('HMR is not enabled');
|
|
3447
|
+
}
|
|
3448
|
+
|
|
3449
|
+
return false;
|
|
3450
|
+
}
|
|
3451
|
+
function swapStyle(oldStyle, newStyle) {
|
|
3452
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3453
|
+
// TODO [#1887]: once the support for registering styles is implemented
|
|
3454
|
+
// we can add the validation of both styles around this block.
|
|
3455
|
+
swappedStyleMap.set(oldStyle, newStyle);
|
|
3456
|
+
return rehydrateHotStyle(oldStyle);
|
|
3457
|
+
}
|
|
3458
|
+
|
|
3459
|
+
if (!runtimeFlags.ENABLE_HMR) {
|
|
3460
|
+
throw new Error('HMR is not enabled');
|
|
3461
|
+
}
|
|
3462
|
+
|
|
3463
|
+
return false;
|
|
3464
|
+
}
|
|
3465
|
+
|
|
3466
|
+
/*
|
|
3467
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
3468
|
+
* All rights reserved.
|
|
3469
|
+
* SPDX-License-Identifier: MIT
|
|
3470
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3471
|
+
*/
|
|
3472
|
+
const CtorToDefMap = new WeakMap();
|
|
3473
|
+
|
|
3474
|
+
function getCtorProto(Ctor) {
|
|
3475
|
+
let proto = getPrototypeOf$1(Ctor);
|
|
3476
|
+
|
|
3477
|
+
if (isNull(proto)) {
|
|
3478
|
+
throw new ReferenceError(`Invalid prototype chain for ${Ctor.name}, you must extend LightningElement.`);
|
|
3479
|
+
} // covering the cases where the ref is circular in AMD
|
|
3480
|
+
|
|
3481
|
+
|
|
3482
|
+
if (isCircularModuleDependency(proto)) {
|
|
3483
|
+
const p = resolveCircularModuleDependency(proto);
|
|
3484
|
+
|
|
3485
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3486
|
+
if (isNull(p)) {
|
|
3487
|
+
throw new ReferenceError(`Circular module dependency for ${Ctor.name}, must resolve to a constructor that extends LightningElement.`);
|
|
3488
|
+
}
|
|
3489
|
+
} // escape hatch for Locker and other abstractions to provide their own base class instead
|
|
3490
|
+
// of our Base class without having to leak it to user-land. If the circular function returns
|
|
3491
|
+
// itself, that's the signal that we have hit the end of the proto chain, which must always
|
|
3492
|
+
// be base.
|
|
3493
|
+
|
|
3494
|
+
|
|
3495
|
+
proto = p === proto ? LightningElement : p;
|
|
3496
|
+
}
|
|
3497
|
+
|
|
3498
|
+
return proto;
|
|
3499
|
+
}
|
|
3500
|
+
|
|
3501
|
+
function createComponentDef(Ctor) {
|
|
3502
|
+
const {
|
|
3503
|
+
shadowSupportMode: ctorShadowSupportMode,
|
|
3504
|
+
renderMode: ctorRenderMode
|
|
3505
|
+
} = Ctor;
|
|
3506
|
+
|
|
3507
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3508
|
+
const ctorName = Ctor.name; // Removing the following assert until https://bugs.webkit.org/show_bug.cgi?id=190140 is fixed.
|
|
3509
|
+
// assert.isTrue(ctorName && isString(ctorName), `${toString(Ctor)} should have a "name" property with string value, but found ${ctorName}.`);
|
|
3510
|
+
|
|
3511
|
+
assert.isTrue(Ctor.constructor, `Missing ${ctorName}.constructor, ${ctorName} should have a "constructor" property.`);
|
|
3512
|
+
|
|
3513
|
+
if (!isUndefined$1(ctorShadowSupportMode)) {
|
|
3514
|
+
assert.invariant(ctorShadowSupportMode === "any"
|
|
3515
|
+
/* Any */
|
|
3516
|
+
|| ctorShadowSupportMode === "reset"
|
|
3517
|
+
/* Default */
|
|
3518
|
+
, `Invalid value for static property shadowSupportMode: '${ctorShadowSupportMode}'`);
|
|
3519
|
+
}
|
|
3520
|
+
|
|
3521
|
+
if (!isUndefined$1(ctorRenderMode)) {
|
|
3522
|
+
assert.invariant(ctorRenderMode === 'light' || ctorRenderMode === 'shadow', `Invalid value for static property renderMode: '${ctorRenderMode}'. renderMode must be either 'light' or 'shadow'.`);
|
|
3523
|
+
}
|
|
3524
|
+
}
|
|
3525
|
+
|
|
3526
|
+
const decoratorsMeta = getDecoratorsMeta(Ctor);
|
|
3527
|
+
const {
|
|
3528
|
+
apiFields,
|
|
3529
|
+
apiFieldsConfig,
|
|
3530
|
+
apiMethods,
|
|
3531
|
+
wiredFields,
|
|
3532
|
+
wiredMethods,
|
|
3533
|
+
observedFields
|
|
3534
|
+
} = decoratorsMeta;
|
|
3535
|
+
const proto = Ctor.prototype;
|
|
3536
|
+
let {
|
|
3537
|
+
connectedCallback,
|
|
3538
|
+
disconnectedCallback,
|
|
3539
|
+
renderedCallback,
|
|
3540
|
+
errorCallback,
|
|
3541
|
+
render
|
|
3542
|
+
} = proto;
|
|
3543
|
+
const superProto = getCtorProto(Ctor);
|
|
3544
|
+
const superDef = superProto !== LightningElement ? getComponentInternalDef(superProto) : lightingElementDef;
|
|
3545
|
+
const bridge = HTMLBridgeElementFactory(superDef.bridge, keys(apiFields), keys(apiMethods));
|
|
3546
|
+
const props = assign(create(null), superDef.props, apiFields);
|
|
3547
|
+
const propsConfig = assign(create(null), superDef.propsConfig, apiFieldsConfig);
|
|
3548
|
+
const methods = assign(create(null), superDef.methods, apiMethods);
|
|
3549
|
+
const wire = assign(create(null), superDef.wire, wiredFields, wiredMethods);
|
|
3550
|
+
connectedCallback = connectedCallback || superDef.connectedCallback;
|
|
3551
|
+
disconnectedCallback = disconnectedCallback || superDef.disconnectedCallback;
|
|
3552
|
+
renderedCallback = renderedCallback || superDef.renderedCallback;
|
|
3553
|
+
errorCallback = errorCallback || superDef.errorCallback;
|
|
3554
|
+
render = render || superDef.render;
|
|
3555
|
+
let shadowSupportMode = superDef.shadowSupportMode;
|
|
3556
|
+
|
|
3557
|
+
if (!isUndefined$1(ctorShadowSupportMode)) {
|
|
3558
|
+
shadowSupportMode = ctorShadowSupportMode;
|
|
3559
|
+
}
|
|
3560
|
+
|
|
3561
|
+
let renderMode = superDef.renderMode;
|
|
3711
3562
|
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3563
|
+
if (!isUndefined$1(ctorRenderMode)) {
|
|
3564
|
+
renderMode = ctorRenderMode === 'light' ? 0
|
|
3565
|
+
/* Light */
|
|
3566
|
+
: 1
|
|
3567
|
+
/* Shadow */
|
|
3568
|
+
;
|
|
3569
|
+
}
|
|
3716
3570
|
|
|
3571
|
+
const template = getComponentRegisteredTemplate(Ctor) || superDef.template;
|
|
3572
|
+
const name = Ctor.name || superDef.name; // installing observed fields into the prototype.
|
|
3717
3573
|
|
|
3718
|
-
|
|
3574
|
+
defineProperties(proto, observedFields);
|
|
3575
|
+
const def = {
|
|
3576
|
+
ctor: Ctor,
|
|
3577
|
+
name,
|
|
3578
|
+
wire,
|
|
3579
|
+
props,
|
|
3580
|
+
propsConfig,
|
|
3581
|
+
methods,
|
|
3582
|
+
bridge,
|
|
3583
|
+
template,
|
|
3584
|
+
renderMode,
|
|
3585
|
+
shadowSupportMode,
|
|
3586
|
+
connectedCallback,
|
|
3587
|
+
disconnectedCallback,
|
|
3588
|
+
renderedCallback,
|
|
3589
|
+
errorCallback,
|
|
3590
|
+
render
|
|
3591
|
+
};
|
|
3719
3592
|
|
|
3720
|
-
|
|
3593
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3594
|
+
freeze(Ctor.prototype);
|
|
3595
|
+
}
|
|
3721
3596
|
|
|
3722
|
-
|
|
3723
|
-
|
|
3597
|
+
return def;
|
|
3598
|
+
}
|
|
3599
|
+
/**
|
|
3600
|
+
* EXPERIMENTAL: This function allows for the identification of LWC constructors. This API is
|
|
3601
|
+
* subject to change or being removed.
|
|
3602
|
+
*/
|
|
3724
3603
|
|
|
3725
|
-
if (isUndefined$1(templateVMs)) {
|
|
3726
|
-
templateVMs = new Set();
|
|
3727
|
-
activeTemplates.set(tpl, templateVMs);
|
|
3728
|
-
} // this will allow us to keep track of the templates that are
|
|
3729
|
-
// being used by a hot component
|
|
3730
3604
|
|
|
3605
|
+
function isComponentConstructor(ctor) {
|
|
3606
|
+
if (!isFunction$1(ctor)) {
|
|
3607
|
+
return false;
|
|
3608
|
+
} // Fast path: LightningElement is part of the prototype chain of the constructor.
|
|
3731
3609
|
|
|
3732
|
-
templateVMs.add(vm); // tracking active styles associated to template
|
|
3733
3610
|
|
|
3734
|
-
|
|
3611
|
+
if (ctor.prototype instanceof LightningElement) {
|
|
3612
|
+
return true;
|
|
3613
|
+
} // Slow path: LightningElement is not part of the prototype chain of the constructor, we need
|
|
3614
|
+
// climb up the constructor prototype chain to check in case there are circular dependencies
|
|
3615
|
+
// to resolve.
|
|
3735
3616
|
|
|
3736
|
-
if (!isUndefined$1(stylesheets)) {
|
|
3737
|
-
flattenStylesheets(stylesheets).forEach(stylesheet => {
|
|
3738
|
-
// this is necessary because we don't hold the list of styles
|
|
3739
|
-
// in the vm, we only hold the selected (already swapped template)
|
|
3740
|
-
// but the styles attached to the template might not be the actual
|
|
3741
|
-
// active ones, but the swapped versions of those.
|
|
3742
|
-
stylesheet = getStyleOrSwappedStyle(stylesheet);
|
|
3743
|
-
let stylesheetVMs = activeStyles.get(stylesheet);
|
|
3744
3617
|
|
|
3745
|
-
|
|
3746
|
-
stylesheetVMs = new Set();
|
|
3747
|
-
activeStyles.set(stylesheet, stylesheetVMs);
|
|
3748
|
-
} // this will allow us to keep track of the stylesheet that are
|
|
3749
|
-
// being used by a hot component
|
|
3618
|
+
let current = ctor;
|
|
3750
3619
|
|
|
3620
|
+
do {
|
|
3621
|
+
if (isCircularModuleDependency(current)) {
|
|
3622
|
+
const circularResolved = resolveCircularModuleDependency(current); // If the circular function returns itself, that's the signal that we have hit the end
|
|
3623
|
+
// of the proto chain, which must always be a valid base constructor.
|
|
3751
3624
|
|
|
3752
|
-
|
|
3753
|
-
|
|
3625
|
+
if (circularResolved === current) {
|
|
3626
|
+
return true;
|
|
3754
3627
|
}
|
|
3628
|
+
|
|
3629
|
+
current = circularResolved;
|
|
3755
3630
|
}
|
|
3756
|
-
|
|
3631
|
+
|
|
3632
|
+
if (current === LightningElement) {
|
|
3633
|
+
return true;
|
|
3634
|
+
}
|
|
3635
|
+
} while (!isNull(current) && (current = getPrototypeOf$1(current))); // Finally return false if the LightningElement is not part of the prototype chain.
|
|
3636
|
+
|
|
3637
|
+
|
|
3638
|
+
return false;
|
|
3757
3639
|
}
|
|
3758
|
-
function
|
|
3759
|
-
if (process.env.NODE_ENV
|
|
3760
|
-
|
|
3761
|
-
throw new ReferenceError();
|
|
3640
|
+
function getComponentInternalDef(Ctor) {
|
|
3641
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3642
|
+
Ctor = getComponentOrSwappedComponent(Ctor);
|
|
3762
3643
|
}
|
|
3763
3644
|
|
|
3764
|
-
|
|
3765
|
-
// tracking inactive component
|
|
3766
|
-
const Ctor = vm.def.ctor;
|
|
3767
|
-
let list = activeComponents.get(Ctor);
|
|
3768
|
-
|
|
3769
|
-
if (!isUndefined$1(list)) {
|
|
3770
|
-
// deleting the vm from the set to avoid leaking memory
|
|
3771
|
-
list.delete(vm);
|
|
3772
|
-
} // removing inactive template
|
|
3645
|
+
let def = CtorToDefMap.get(Ctor);
|
|
3773
3646
|
|
|
3647
|
+
if (isUndefined$1(def)) {
|
|
3648
|
+
if (isCircularModuleDependency(Ctor)) {
|
|
3649
|
+
const resolvedCtor = resolveCircularModuleDependency(Ctor);
|
|
3650
|
+
def = getComponentInternalDef(resolvedCtor); // Cache the unresolved component ctor too. The next time if the same unresolved ctor is used,
|
|
3651
|
+
// look up the definition in cache instead of re-resolving and recreating the def.
|
|
3774
3652
|
|
|
3775
|
-
|
|
3653
|
+
CtorToDefMap.set(Ctor, def);
|
|
3654
|
+
return def;
|
|
3655
|
+
}
|
|
3776
3656
|
|
|
3777
|
-
if (
|
|
3778
|
-
|
|
3657
|
+
if (!isComponentConstructor(Ctor)) {
|
|
3658
|
+
throw new TypeError(`${Ctor} is not a valid component, or does not extends LightningElement from "lwc". You probably forgot to add the extend clause on the class declaration.`);
|
|
3659
|
+
}
|
|
3779
3660
|
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
} // removing active styles associated to template
|
|
3661
|
+
def = createComponentDef(Ctor);
|
|
3662
|
+
CtorToDefMap.set(Ctor, def);
|
|
3663
|
+
}
|
|
3784
3664
|
|
|
3665
|
+
return def;
|
|
3666
|
+
}
|
|
3667
|
+
const lightingElementDef = {
|
|
3668
|
+
ctor: LightningElement,
|
|
3669
|
+
name: LightningElement.name,
|
|
3670
|
+
props: lightningBasedDescriptors,
|
|
3671
|
+
propsConfig: EmptyObject,
|
|
3672
|
+
methods: EmptyObject,
|
|
3673
|
+
renderMode: 1
|
|
3674
|
+
/* Shadow */
|
|
3675
|
+
,
|
|
3676
|
+
shadowSupportMode: "reset"
|
|
3677
|
+
/* Default */
|
|
3678
|
+
,
|
|
3679
|
+
wire: EmptyObject,
|
|
3680
|
+
bridge: BaseBridgeElement,
|
|
3681
|
+
template: defaultEmptyTemplate,
|
|
3682
|
+
render: LightningElement.prototype.render
|
|
3683
|
+
};
|
|
3684
|
+
/**
|
|
3685
|
+
* EXPERIMENTAL: This function allows for the collection of internal component metadata. This API is
|
|
3686
|
+
* subject to change or being removed.
|
|
3687
|
+
*/
|
|
3785
3688
|
|
|
3786
|
-
|
|
3689
|
+
function getComponentDef(Ctor) {
|
|
3690
|
+
const def = getComponentInternalDef(Ctor); // From the internal def object, we need to extract the info that is useful
|
|
3691
|
+
// for some external services, e.g.: Locker Service, usually, all they care
|
|
3692
|
+
// is about the shape of the constructor, the internals of it are not relevant
|
|
3693
|
+
// because they don't have a way to mess with that.
|
|
3787
3694
|
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3695
|
+
const {
|
|
3696
|
+
ctor,
|
|
3697
|
+
name,
|
|
3698
|
+
props,
|
|
3699
|
+
propsConfig,
|
|
3700
|
+
methods
|
|
3701
|
+
} = def;
|
|
3702
|
+
const publicProps = {};
|
|
3791
3703
|
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
}
|
|
3801
|
-
function swapTemplate(oldTpl, newTpl) {
|
|
3802
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
3803
|
-
if (isTemplateRegistered(oldTpl) && isTemplateRegistered(newTpl)) {
|
|
3804
|
-
swappedTemplateMap.set(oldTpl, newTpl);
|
|
3805
|
-
return rehydrateHotTemplate(oldTpl);
|
|
3806
|
-
} else {
|
|
3807
|
-
throw new TypeError(`Invalid Template`);
|
|
3808
|
-
}
|
|
3704
|
+
for (const key in props) {
|
|
3705
|
+
// avoid leaking the reference to the public props descriptors
|
|
3706
|
+
publicProps[key] = {
|
|
3707
|
+
config: propsConfig[key] || 0,
|
|
3708
|
+
type: "any"
|
|
3709
|
+
/* any */
|
|
3710
|
+
,
|
|
3711
|
+
attr: htmlPropertyToAttribute(key)
|
|
3712
|
+
};
|
|
3809
3713
|
}
|
|
3810
3714
|
|
|
3811
|
-
|
|
3812
|
-
|
|
3715
|
+
const publicMethods = {};
|
|
3716
|
+
|
|
3717
|
+
for (const key in methods) {
|
|
3718
|
+
// avoid leaking the reference to the public method descriptors
|
|
3719
|
+
publicMethods[key] = methods[key].value;
|
|
3813
3720
|
}
|
|
3814
3721
|
|
|
3815
|
-
return
|
|
3722
|
+
return {
|
|
3723
|
+
ctor,
|
|
3724
|
+
name,
|
|
3725
|
+
props: publicProps,
|
|
3726
|
+
methods: publicMethods
|
|
3727
|
+
};
|
|
3816
3728
|
}
|
|
3817
|
-
function swapComponent(oldComponent, newComponent) {
|
|
3818
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
3819
|
-
if (isComponentConstructor(oldComponent) && isComponentConstructor(newComponent)) {
|
|
3820
|
-
swappedComponentMap.set(oldComponent, newComponent);
|
|
3821
|
-
return rehydrateHotComponent(oldComponent);
|
|
3822
|
-
} else {
|
|
3823
|
-
throw new TypeError(`Invalid Component`);
|
|
3824
|
-
}
|
|
3825
|
-
}
|
|
3826
3729
|
|
|
3827
|
-
|
|
3828
|
-
|
|
3730
|
+
/*
|
|
3731
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
3732
|
+
* All rights reserved.
|
|
3733
|
+
* SPDX-License-Identifier: MIT
|
|
3734
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3735
|
+
*/
|
|
3736
|
+
const xlinkNS = 'http://www.w3.org/1999/xlink';
|
|
3737
|
+
const xmlNS = 'http://www.w3.org/XML/1998/namespace';
|
|
3738
|
+
const ColonCharCode = 58;
|
|
3739
|
+
function patchAttributes(oldVnode, vnode) {
|
|
3740
|
+
const {
|
|
3741
|
+
attrs
|
|
3742
|
+
} = vnode.data;
|
|
3743
|
+
|
|
3744
|
+
if (isUndefined$1(attrs)) {
|
|
3745
|
+
return;
|
|
3829
3746
|
}
|
|
3830
3747
|
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
// TODO [#1887]: once the support for registering styles is implemented
|
|
3836
|
-
// we can add the validation of both styles around this block.
|
|
3837
|
-
swappedStyleMap.set(oldStyle, newStyle);
|
|
3838
|
-
return rehydrateHotStyle(oldStyle);
|
|
3748
|
+
const oldAttrs = isNull(oldVnode) ? EmptyObject : oldVnode.data.attrs;
|
|
3749
|
+
|
|
3750
|
+
if (oldAttrs === attrs) {
|
|
3751
|
+
return;
|
|
3839
3752
|
}
|
|
3840
3753
|
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
}
|
|
3754
|
+
const {
|
|
3755
|
+
elm
|
|
3756
|
+
} = vnode;
|
|
3757
|
+
|
|
3758
|
+
for (const key in attrs) {
|
|
3759
|
+
const cur = attrs[key];
|
|
3760
|
+
const old = oldAttrs[key];
|
|
3761
|
+
|
|
3762
|
+
if (old !== cur) {
|
|
3763
|
+
unlockAttribute(elm, key);
|
|
3844
3764
|
|
|
3845
|
-
|
|
3765
|
+
if (StringCharCodeAt.call(key, 3) === ColonCharCode) {
|
|
3766
|
+
// Assume xml namespace
|
|
3767
|
+
setAttribute(elm, key, cur, xmlNS);
|
|
3768
|
+
} else if (StringCharCodeAt.call(key, 5) === ColonCharCode) {
|
|
3769
|
+
// Assume xlink namespace
|
|
3770
|
+
setAttribute(elm, key, cur, xlinkNS);
|
|
3771
|
+
} else if (isNull(cur) || isUndefined$1(cur)) {
|
|
3772
|
+
removeAttribute(elm, key);
|
|
3773
|
+
} else {
|
|
3774
|
+
setAttribute(elm, key, cur);
|
|
3775
|
+
}
|
|
3776
|
+
|
|
3777
|
+
lockAttribute();
|
|
3778
|
+
}
|
|
3779
|
+
}
|
|
3846
3780
|
}
|
|
3847
3781
|
|
|
3848
3782
|
/*
|
|
@@ -3851,262 +3785,231 @@ function swapStyle(oldStyle, newStyle) {
|
|
|
3851
3785
|
* SPDX-License-Identifier: MIT
|
|
3852
3786
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3853
3787
|
*/
|
|
3854
|
-
const CtorToDefMap = new WeakMap();
|
|
3855
3788
|
|
|
3856
|
-
function
|
|
3857
|
-
|
|
3789
|
+
function isLiveBindingProp(sel, key) {
|
|
3790
|
+
// For properties with live bindings, we read values from the DOM element
|
|
3791
|
+
// instead of relying on internally tracked values.
|
|
3792
|
+
return sel === 'input' && (key === 'value' || key === 'checked');
|
|
3793
|
+
}
|
|
3858
3794
|
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3795
|
+
function patchProps(oldVnode, vnode) {
|
|
3796
|
+
const {
|
|
3797
|
+
props
|
|
3798
|
+
} = vnode.data;
|
|
3862
3799
|
|
|
3800
|
+
if (isUndefined$1(props)) {
|
|
3801
|
+
return;
|
|
3802
|
+
}
|
|
3863
3803
|
|
|
3864
|
-
|
|
3865
|
-
const p = resolveCircularModuleDependency(proto);
|
|
3804
|
+
const oldProps = isNull(oldVnode) ? EmptyObject : oldVnode.data.props;
|
|
3866
3805
|
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
}
|
|
3871
|
-
} // escape hatch for Locker and other abstractions to provide their own base class instead
|
|
3872
|
-
// of our Base class without having to leak it to user-land. If the circular function returns
|
|
3873
|
-
// itself, that's the signal that we have hit the end of the proto chain, which must always
|
|
3874
|
-
// be base.
|
|
3806
|
+
if (oldProps === props) {
|
|
3807
|
+
return;
|
|
3808
|
+
}
|
|
3875
3809
|
|
|
3810
|
+
const isFirstPatch = isNull(oldVnode);
|
|
3811
|
+
const {
|
|
3812
|
+
elm,
|
|
3813
|
+
sel
|
|
3814
|
+
} = vnode;
|
|
3876
3815
|
|
|
3877
|
-
|
|
3878
|
-
|
|
3816
|
+
for (const key in props) {
|
|
3817
|
+
const cur = props[key]; // Set the property if it's the first time is is patched or if the previous property is
|
|
3818
|
+
// different than the one previously set.
|
|
3879
3819
|
|
|
3880
|
-
|
|
3820
|
+
if (isFirstPatch || cur !== (isLiveBindingProp(sel, key) ? getProperty(elm, key) : oldProps[key])) {
|
|
3821
|
+
setProperty(elm, key, cur);
|
|
3822
|
+
}
|
|
3823
|
+
}
|
|
3881
3824
|
}
|
|
3882
3825
|
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3826
|
+
/*
|
|
3827
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
3828
|
+
* All rights reserved.
|
|
3829
|
+
* SPDX-License-Identifier: MIT
|
|
3830
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3831
|
+
*/
|
|
3832
|
+
const classNameToClassMap = create(null);
|
|
3888
3833
|
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3834
|
+
function getMapFromClassName(className) {
|
|
3835
|
+
// Intentionally using == to match undefined and null values from computed style attribute
|
|
3836
|
+
if (className == null) {
|
|
3837
|
+
return EmptyObject;
|
|
3838
|
+
} // computed class names must be string
|
|
3892
3839
|
|
|
3893
|
-
assert.isTrue(Ctor.constructor, `Missing ${ctorName}.constructor, ${ctorName} should have a "constructor" property.`);
|
|
3894
3840
|
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
/* Any */
|
|
3898
|
-
|| ctorShadowSupportMode === "reset"
|
|
3899
|
-
/* Default */
|
|
3900
|
-
, `Invalid value for static property shadowSupportMode: '${ctorShadowSupportMode}'`);
|
|
3901
|
-
}
|
|
3841
|
+
className = isString(className) ? className : className + '';
|
|
3842
|
+
let map = classNameToClassMap[className];
|
|
3902
3843
|
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
}
|
|
3844
|
+
if (map) {
|
|
3845
|
+
return map;
|
|
3906
3846
|
}
|
|
3907
3847
|
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
apiMethods,
|
|
3913
|
-
wiredFields,
|
|
3914
|
-
wiredMethods,
|
|
3915
|
-
observedFields
|
|
3916
|
-
} = decoratorsMeta;
|
|
3917
|
-
const proto = Ctor.prototype;
|
|
3918
|
-
let {
|
|
3919
|
-
connectedCallback,
|
|
3920
|
-
disconnectedCallback,
|
|
3921
|
-
renderedCallback,
|
|
3922
|
-
errorCallback,
|
|
3923
|
-
render
|
|
3924
|
-
} = proto;
|
|
3925
|
-
const superProto = getCtorProto(Ctor);
|
|
3926
|
-
const superDef = superProto !== LightningElement ? getComponentInternalDef(superProto) : lightingElementDef;
|
|
3927
|
-
const bridge = HTMLBridgeElementFactory(superDef.bridge, keys(apiFields), keys(apiMethods));
|
|
3928
|
-
const props = assign(create(null), superDef.props, apiFields);
|
|
3929
|
-
const propsConfig = assign(create(null), superDef.propsConfig, apiFieldsConfig);
|
|
3930
|
-
const methods = assign(create(null), superDef.methods, apiMethods);
|
|
3931
|
-
const wire = assign(create(null), superDef.wire, wiredFields, wiredMethods);
|
|
3932
|
-
connectedCallback = connectedCallback || superDef.connectedCallback;
|
|
3933
|
-
disconnectedCallback = disconnectedCallback || superDef.disconnectedCallback;
|
|
3934
|
-
renderedCallback = renderedCallback || superDef.renderedCallback;
|
|
3935
|
-
errorCallback = errorCallback || superDef.errorCallback;
|
|
3936
|
-
render = render || superDef.render;
|
|
3937
|
-
let shadowSupportMode = superDef.shadowSupportMode;
|
|
3938
|
-
|
|
3939
|
-
if (!isUndefined$1(ctorShadowSupportMode)) {
|
|
3940
|
-
shadowSupportMode = ctorShadowSupportMode;
|
|
3941
|
-
}
|
|
3848
|
+
map = create(null);
|
|
3849
|
+
let start = 0;
|
|
3850
|
+
let o;
|
|
3851
|
+
const len = className.length;
|
|
3942
3852
|
|
|
3943
|
-
|
|
3853
|
+
for (o = 0; o < len; o++) {
|
|
3854
|
+
if (StringCharCodeAt.call(className, o) === SPACE_CHAR) {
|
|
3855
|
+
if (o > start) {
|
|
3856
|
+
map[StringSlice.call(className, start, o)] = true;
|
|
3857
|
+
}
|
|
3944
3858
|
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
/* Light */
|
|
3948
|
-
: 1
|
|
3949
|
-
/* Shadow */
|
|
3950
|
-
;
|
|
3859
|
+
start = o + 1;
|
|
3860
|
+
}
|
|
3951
3861
|
}
|
|
3952
3862
|
|
|
3953
|
-
|
|
3954
|
-
|
|
3863
|
+
if (o > start) {
|
|
3864
|
+
map[StringSlice.call(className, start, o)] = true;
|
|
3865
|
+
}
|
|
3955
3866
|
|
|
3956
|
-
|
|
3957
|
-
const def = {
|
|
3958
|
-
ctor: Ctor,
|
|
3959
|
-
name,
|
|
3960
|
-
wire,
|
|
3961
|
-
props,
|
|
3962
|
-
propsConfig,
|
|
3963
|
-
methods,
|
|
3964
|
-
bridge,
|
|
3965
|
-
template,
|
|
3966
|
-
renderMode,
|
|
3967
|
-
shadowSupportMode,
|
|
3968
|
-
connectedCallback,
|
|
3969
|
-
disconnectedCallback,
|
|
3970
|
-
renderedCallback,
|
|
3971
|
-
errorCallback,
|
|
3972
|
-
render
|
|
3973
|
-
};
|
|
3867
|
+
classNameToClassMap[className] = map;
|
|
3974
3868
|
|
|
3975
3869
|
if (process.env.NODE_ENV !== 'production') {
|
|
3976
|
-
|
|
3870
|
+
// just to make sure that this object never changes as part of the diffing algo
|
|
3871
|
+
freeze(map);
|
|
3977
3872
|
}
|
|
3978
3873
|
|
|
3979
|
-
return
|
|
3874
|
+
return map;
|
|
3980
3875
|
}
|
|
3981
|
-
/**
|
|
3982
|
-
* EXPERIMENTAL: This function allows for the identification of LWC constructors. This API is
|
|
3983
|
-
* subject to change or being removed.
|
|
3984
|
-
*/
|
|
3985
3876
|
|
|
3877
|
+
function patchClassAttribute(oldVnode, vnode) {
|
|
3878
|
+
const {
|
|
3879
|
+
elm,
|
|
3880
|
+
data: {
|
|
3881
|
+
className: newClass
|
|
3882
|
+
}
|
|
3883
|
+
} = vnode;
|
|
3884
|
+
const oldClass = isNull(oldVnode) ? undefined : oldVnode.data.className;
|
|
3986
3885
|
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
} // Fast path: LightningElement is part of the prototype chain of the constructor.
|
|
3886
|
+
if (oldClass === newClass) {
|
|
3887
|
+
return;
|
|
3888
|
+
}
|
|
3991
3889
|
|
|
3890
|
+
const classList = getClassList(elm);
|
|
3891
|
+
const newClassMap = getMapFromClassName(newClass);
|
|
3892
|
+
const oldClassMap = getMapFromClassName(oldClass);
|
|
3893
|
+
let name;
|
|
3992
3894
|
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3895
|
+
for (name in oldClassMap) {
|
|
3896
|
+
// remove only if it is not in the new class collection and it is not set from within the instance
|
|
3897
|
+
if (isUndefined$1(newClassMap[name])) {
|
|
3898
|
+
classList.remove(name);
|
|
3899
|
+
}
|
|
3900
|
+
}
|
|
3998
3901
|
|
|
3902
|
+
for (name in newClassMap) {
|
|
3903
|
+
if (isUndefined$1(oldClassMap[name])) {
|
|
3904
|
+
classList.add(name);
|
|
3905
|
+
}
|
|
3906
|
+
}
|
|
3907
|
+
}
|
|
3999
3908
|
|
|
4000
|
-
|
|
3909
|
+
/*
|
|
3910
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
3911
|
+
* All rights reserved.
|
|
3912
|
+
* SPDX-License-Identifier: MIT
|
|
3913
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3914
|
+
*/
|
|
4001
3915
|
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
3916
|
+
function patchStyleAttribute(oldVnode, vnode) {
|
|
3917
|
+
const {
|
|
3918
|
+
elm,
|
|
3919
|
+
data: {
|
|
3920
|
+
style: newStyle
|
|
3921
|
+
}
|
|
3922
|
+
} = vnode;
|
|
3923
|
+
const oldStyle = isNull(oldVnode) ? undefined : oldVnode.data.style;
|
|
4006
3924
|
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
3925
|
+
if (oldStyle === newStyle) {
|
|
3926
|
+
return;
|
|
3927
|
+
}
|
|
4010
3928
|
|
|
4011
|
-
|
|
4012
|
-
|
|
3929
|
+
if (!isString(newStyle) || newStyle === '') {
|
|
3930
|
+
removeAttribute(elm, 'style');
|
|
3931
|
+
} else {
|
|
3932
|
+
setAttribute(elm, 'style', newStyle);
|
|
3933
|
+
}
|
|
3934
|
+
}
|
|
4013
3935
|
|
|
4014
|
-
|
|
4015
|
-
|
|
3936
|
+
/*
|
|
3937
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
3938
|
+
* All rights reserved.
|
|
3939
|
+
* SPDX-License-Identifier: MIT
|
|
3940
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3941
|
+
*/
|
|
3942
|
+
function applyEventListeners(vnode) {
|
|
3943
|
+
const {
|
|
3944
|
+
elm,
|
|
3945
|
+
data: {
|
|
3946
|
+
on
|
|
4016
3947
|
}
|
|
4017
|
-
}
|
|
4018
|
-
|
|
3948
|
+
} = vnode;
|
|
4019
3949
|
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
function getComponentInternalDef(Ctor) {
|
|
4023
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
4024
|
-
Ctor = getComponentOrSwappedComponent(Ctor);
|
|
3950
|
+
if (isUndefined$1(on)) {
|
|
3951
|
+
return;
|
|
4025
3952
|
}
|
|
4026
3953
|
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
def = getComponentInternalDef(resolvedCtor); // Cache the unresolved component ctor too. The next time if the same unresolved ctor is used,
|
|
4033
|
-
// look up the definition in cache instead of re-resolving and recreating the def.
|
|
3954
|
+
for (const name in on) {
|
|
3955
|
+
const handler = on[name];
|
|
3956
|
+
addEventListener(elm, name, handler);
|
|
3957
|
+
}
|
|
3958
|
+
}
|
|
4034
3959
|
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
3960
|
+
/*
|
|
3961
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
3962
|
+
* All rights reserved.
|
|
3963
|
+
* SPDX-License-Identifier: MIT
|
|
3964
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3965
|
+
*/
|
|
3966
|
+
// The compiler takes care of transforming the inline classnames into an object. It's faster to set the
|
|
3967
|
+
// different classnames properties individually instead of via a string.
|
|
4038
3968
|
|
|
4039
|
-
|
|
4040
|
-
|
|
3969
|
+
function applyStaticClassAttribute(vnode) {
|
|
3970
|
+
const {
|
|
3971
|
+
elm,
|
|
3972
|
+
data: {
|
|
3973
|
+
classMap
|
|
4041
3974
|
}
|
|
3975
|
+
} = vnode;
|
|
4042
3976
|
|
|
4043
|
-
|
|
4044
|
-
|
|
3977
|
+
if (isUndefined$1(classMap)) {
|
|
3978
|
+
return;
|
|
4045
3979
|
}
|
|
4046
3980
|
|
|
4047
|
-
|
|
3981
|
+
const classList = getClassList(elm);
|
|
3982
|
+
|
|
3983
|
+
for (const name in classMap) {
|
|
3984
|
+
classList.add(name);
|
|
3985
|
+
}
|
|
4048
3986
|
}
|
|
4049
|
-
const lightingElementDef = {
|
|
4050
|
-
ctor: LightningElement,
|
|
4051
|
-
name: LightningElement.name,
|
|
4052
|
-
props: lightningBasedDescriptors,
|
|
4053
|
-
propsConfig: EmptyObject,
|
|
4054
|
-
methods: EmptyObject,
|
|
4055
|
-
renderMode: 1
|
|
4056
|
-
/* Shadow */
|
|
4057
|
-
,
|
|
4058
|
-
shadowSupportMode: "reset"
|
|
4059
|
-
/* Default */
|
|
4060
|
-
,
|
|
4061
|
-
wire: EmptyObject,
|
|
4062
|
-
bridge: BaseBridgeElement,
|
|
4063
|
-
template: defaultEmptyTemplate,
|
|
4064
|
-
render: LightningElement.prototype.render
|
|
4065
|
-
};
|
|
4066
|
-
/**
|
|
4067
|
-
* EXPERIMENTAL: This function allows for the collection of internal component metadata. This API is
|
|
4068
|
-
* subject to change or being removed.
|
|
4069
|
-
*/
|
|
4070
3987
|
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
3988
|
+
/*
|
|
3989
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
3990
|
+
* All rights reserved.
|
|
3991
|
+
* SPDX-License-Identifier: MIT
|
|
3992
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3993
|
+
*/
|
|
3994
|
+
// The compiler takes care of transforming the inline style into an object. It's faster to set the
|
|
3995
|
+
// different style properties individually instead of via a string.
|
|
4076
3996
|
|
|
3997
|
+
function applyStaticStyleAttribute(vnode) {
|
|
4077
3998
|
const {
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
} = def;
|
|
4084
|
-
const publicProps = {};
|
|
3999
|
+
elm,
|
|
4000
|
+
data: {
|
|
4001
|
+
styleDecls
|
|
4002
|
+
}
|
|
4003
|
+
} = vnode;
|
|
4085
4004
|
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
publicProps[key] = {
|
|
4089
|
-
config: propsConfig[key] || 0,
|
|
4090
|
-
type: "any"
|
|
4091
|
-
/* any */
|
|
4092
|
-
,
|
|
4093
|
-
attr: htmlPropertyToAttribute(key)
|
|
4094
|
-
};
|
|
4005
|
+
if (isUndefined$1(styleDecls)) {
|
|
4006
|
+
return;
|
|
4095
4007
|
}
|
|
4096
4008
|
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
// avoid leaking the reference to the public method descriptors
|
|
4101
|
-
publicMethods[key] = methods[key].value;
|
|
4009
|
+
for (let i = 0; i < styleDecls.length; i++) {
|
|
4010
|
+
const [prop, value, important] = styleDecls[i];
|
|
4011
|
+
setCSSStyleProperty(elm, prop, value, important);
|
|
4102
4012
|
}
|
|
4103
|
-
|
|
4104
|
-
return {
|
|
4105
|
-
ctor,
|
|
4106
|
-
name,
|
|
4107
|
-
props: publicProps,
|
|
4108
|
-
methods: publicMethods
|
|
4109
|
-
};
|
|
4110
4013
|
}
|
|
4111
4014
|
|
|
4112
4015
|
/*
|
|
@@ -4177,27 +4080,23 @@ function removeNodeHook(vnode, parentNode) {
|
|
|
4177
4080
|
lockDomMutation();
|
|
4178
4081
|
}
|
|
4179
4082
|
}
|
|
4180
|
-
function
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4083
|
+
function patchElementPropsAndAttrs(oldVnode, vnode) {
|
|
4084
|
+
if (isNull(oldVnode)) {
|
|
4085
|
+
applyEventListeners(vnode);
|
|
4086
|
+
applyStaticClassAttribute(vnode);
|
|
4087
|
+
applyStaticStyleAttribute(vnode);
|
|
4088
|
+
} // Attrs need to be applied to element before props IE11 will wipe out value on radio inputs if
|
|
4089
|
+
// value is set before type=radio.
|
|
4184
4090
|
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
modComputedStyle.create(vnode);
|
|
4091
|
+
|
|
4092
|
+
patchClassAttribute(oldVnode, vnode);
|
|
4093
|
+
patchStyleAttribute(oldVnode, vnode);
|
|
4094
|
+
patchAttributes(oldVnode, vnode);
|
|
4095
|
+
patchProps(oldVnode, vnode);
|
|
4191
4096
|
}
|
|
4192
4097
|
function hydrateElmHook(vnode) {
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
modProps.create(vnode); // Already set.
|
|
4197
|
-
// modStaticClassName.create(vnode);
|
|
4198
|
-
// modStaticStyle.create(vnode);
|
|
4199
|
-
// modComputedClassName.create(vnode);
|
|
4200
|
-
// modComputedStyle.create(vnode);
|
|
4098
|
+
applyEventListeners(vnode);
|
|
4099
|
+
patchProps(null, vnode);
|
|
4201
4100
|
}
|
|
4202
4101
|
function fallbackElmHook(elm, vnode) {
|
|
4203
4102
|
const {
|
|
@@ -4247,25 +4146,11 @@ function fallbackElmHook(elm, vnode) {
|
|
|
4247
4146
|
});
|
|
4248
4147
|
}
|
|
4249
4148
|
}
|
|
4250
|
-
function
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
// is set before type=radio.
|
|
4254
|
-
modAttrs.update(oldVnode, vnode);
|
|
4255
|
-
modProps.update(oldVnode, vnode);
|
|
4256
|
-
modComputedClassName.update(oldVnode, vnode);
|
|
4257
|
-
modComputedStyle.update(oldVnode, vnode);
|
|
4258
|
-
}
|
|
4259
|
-
function updateChildrenHook(oldVnode, vnode) {
|
|
4260
|
-
const {
|
|
4261
|
-
elm,
|
|
4262
|
-
children
|
|
4263
|
-
} = vnode;
|
|
4264
|
-
|
|
4265
|
-
if (hasDynamicChildren(children)) {
|
|
4266
|
-
updateDynamicChildren(elm, oldVnode.children, children);
|
|
4149
|
+
function patchChildren(parent, oldCh, newCh) {
|
|
4150
|
+
if (hasDynamicChildren(newCh)) {
|
|
4151
|
+
updateDynamicChildren(parent, oldCh, newCh);
|
|
4267
4152
|
} else {
|
|
4268
|
-
updateStaticChildren(
|
|
4153
|
+
updateStaticChildren(parent, oldCh, newCh);
|
|
4269
4154
|
}
|
|
4270
4155
|
}
|
|
4271
4156
|
function allocateChildrenHook(vnode, vm) {
|
|
@@ -4337,18 +4222,6 @@ function createViewModelHook(elm, vnode) {
|
|
|
4337
4222
|
assert.isTrue(isArray$1(vnode.children), `Invalid vnode for a custom element, it must have children defined.`);
|
|
4338
4223
|
}
|
|
4339
4224
|
}
|
|
4340
|
-
function createCustomElmHook(vnode) {
|
|
4341
|
-
modEvents.create(vnode); // Attrs need to be applied to element before props
|
|
4342
|
-
// IE11 will wipe out value on radio inputs if value
|
|
4343
|
-
// is set before type=radio.
|
|
4344
|
-
|
|
4345
|
-
modAttrs.create(vnode);
|
|
4346
|
-
modProps.create(vnode);
|
|
4347
|
-
modStaticClassName.create(vnode);
|
|
4348
|
-
modStaticStyle.create(vnode);
|
|
4349
|
-
modComputedClassName.create(vnode);
|
|
4350
|
-
modComputedStyle.create(vnode);
|
|
4351
|
-
}
|
|
4352
4225
|
function createChildrenHook(vnode) {
|
|
4353
4226
|
const {
|
|
4354
4227
|
elm,
|
|
@@ -4528,15 +4401,6 @@ function hydrateChildrenHook(elmChildren, children, vm) {
|
|
|
4528
4401
|
}
|
|
4529
4402
|
}
|
|
4530
4403
|
}
|
|
4531
|
-
function updateCustomElmHook(oldVnode, vnode) {
|
|
4532
|
-
// Attrs need to be applied to element before props
|
|
4533
|
-
// IE11 will wipe out value on radio inputs if value
|
|
4534
|
-
// is set before type=radio.
|
|
4535
|
-
modAttrs.update(oldVnode, vnode);
|
|
4536
|
-
modProps.update(oldVnode, vnode);
|
|
4537
|
-
modComputedClassName.update(oldVnode, vnode);
|
|
4538
|
-
modComputedStyle.update(oldVnode, vnode);
|
|
4539
|
-
}
|
|
4540
4404
|
function removeElmHook(vnode) {
|
|
4541
4405
|
// this method only needs to search on child vnodes from template
|
|
4542
4406
|
// to trigger the remove hook just in case some of those children
|
|
@@ -4553,14 +4417,76 @@ function removeElmHook(vnode) {
|
|
|
4553
4417
|
ch.hook.remove(ch, elm);
|
|
4554
4418
|
}
|
|
4555
4419
|
}
|
|
4420
|
+
}
|
|
4421
|
+
|
|
4422
|
+
function allocateInSlot(vm, children) {
|
|
4423
|
+
const {
|
|
4424
|
+
cmpSlots: oldSlots
|
|
4425
|
+
} = vm;
|
|
4426
|
+
const cmpSlots = vm.cmpSlots = create(null);
|
|
4427
|
+
|
|
4428
|
+
for (let i = 0, len = children.length; i < len; i += 1) {
|
|
4429
|
+
const vnode = children[i];
|
|
4430
|
+
|
|
4431
|
+
if (isNull(vnode)) {
|
|
4432
|
+
continue;
|
|
4433
|
+
}
|
|
4434
|
+
|
|
4435
|
+
const {
|
|
4436
|
+
data
|
|
4437
|
+
} = vnode;
|
|
4438
|
+
const slotName = data.attrs && data.attrs.slot || '';
|
|
4439
|
+
const vnodes = cmpSlots[slotName] = cmpSlots[slotName] || []; // re-keying the vnodes is necessary to avoid conflicts with default content for the slot
|
|
4440
|
+
// which might have similar keys. Each vnode will always have a key that
|
|
4441
|
+
// starts with a numeric character from compiler. In this case, we add a unique
|
|
4442
|
+
// notation for slotted vnodes keys, e.g.: `@foo:1:1`
|
|
4443
|
+
|
|
4444
|
+
if (!isUndefined$1(vnode.key)) {
|
|
4445
|
+
vnode.key = `@${slotName}:${vnode.key}`;
|
|
4446
|
+
}
|
|
4447
|
+
|
|
4448
|
+
ArrayPush$1.call(vnodes, vnode);
|
|
4449
|
+
}
|
|
4450
|
+
|
|
4451
|
+
if (isFalse(vm.isDirty)) {
|
|
4452
|
+
// We need to determine if the old allocation is really different from the new one
|
|
4453
|
+
// and mark the vm as dirty
|
|
4454
|
+
const oldKeys = keys(oldSlots);
|
|
4455
|
+
|
|
4456
|
+
if (oldKeys.length !== keys(cmpSlots).length) {
|
|
4457
|
+
markComponentAsDirty(vm);
|
|
4458
|
+
return;
|
|
4459
|
+
}
|
|
4460
|
+
|
|
4461
|
+
for (let i = 0, len = oldKeys.length; i < len; i += 1) {
|
|
4462
|
+
const key = oldKeys[i];
|
|
4463
|
+
|
|
4464
|
+
if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
|
|
4465
|
+
markComponentAsDirty(vm);
|
|
4466
|
+
return;
|
|
4467
|
+
}
|
|
4468
|
+
|
|
4469
|
+
const oldVNodes = oldSlots[key];
|
|
4470
|
+
const vnodes = cmpSlots[key];
|
|
4471
|
+
|
|
4472
|
+
for (let j = 0, a = cmpSlots[key].length; j < a; j += 1) {
|
|
4473
|
+
if (oldVNodes[j] !== vnodes[j]) {
|
|
4474
|
+
markComponentAsDirty(vm);
|
|
4475
|
+
return;
|
|
4476
|
+
}
|
|
4477
|
+
}
|
|
4478
|
+
}
|
|
4479
|
+
}
|
|
4556
4480
|
} // Using a WeakMap instead of a WeakSet because this one works in IE11 :(
|
|
4557
4481
|
|
|
4482
|
+
|
|
4558
4483
|
const FromIteration = new WeakMap(); // dynamic children means it was generated by an iteration
|
|
4559
4484
|
// in a template, and will require a more complex diffing algo.
|
|
4560
4485
|
|
|
4561
4486
|
function markAsDynamicChildren(children) {
|
|
4562
4487
|
FromIteration.set(children, 1);
|
|
4563
4488
|
}
|
|
4489
|
+
|
|
4564
4490
|
function hasDynamicChildren(children) {
|
|
4565
4491
|
return FromIteration.has(children);
|
|
4566
4492
|
}
|
|
@@ -4695,11 +4621,11 @@ const ElementHook = {
|
|
|
4695
4621
|
linkNodeToShadow(elm, owner);
|
|
4696
4622
|
fallbackElmHook(elm, vnode);
|
|
4697
4623
|
vnode.elm = elm;
|
|
4698
|
-
|
|
4624
|
+
patchElementPropsAndAttrs(null, vnode);
|
|
4699
4625
|
},
|
|
4700
4626
|
update: (oldVnode, vnode) => {
|
|
4701
|
-
|
|
4702
|
-
|
|
4627
|
+
patchElementPropsAndAttrs(oldVnode, vnode);
|
|
4628
|
+
patchChildren(vnode.elm, oldVnode.children, vnode.children);
|
|
4703
4629
|
},
|
|
4704
4630
|
insert: (vnode, parentNode, referenceNode) => {
|
|
4705
4631
|
insertNodeHook(vnode, parentNode, referenceNode);
|
|
@@ -4773,10 +4699,10 @@ const CustomElementHook = {
|
|
|
4773
4699
|
throw new TypeError(`Incorrect Component Constructor`);
|
|
4774
4700
|
}
|
|
4775
4701
|
|
|
4776
|
-
|
|
4702
|
+
patchElementPropsAndAttrs(null, vnode);
|
|
4777
4703
|
},
|
|
4778
4704
|
update: (oldVnode, vnode) => {
|
|
4779
|
-
|
|
4705
|
+
patchElementPropsAndAttrs(oldVnode, vnode);
|
|
4780
4706
|
const vm = getAssociatedVMIfPresent(vnode.elm);
|
|
4781
4707
|
|
|
4782
4708
|
if (vm) {
|
|
@@ -4787,7 +4713,7 @@ const CustomElementHook = {
|
|
|
4787
4713
|
// will happen, but in native, it does allocate the light dom
|
|
4788
4714
|
|
|
4789
4715
|
|
|
4790
|
-
|
|
4716
|
+
patchChildren(vnode.elm, oldVnode.children, vnode.children);
|
|
4791
4717
|
|
|
4792
4718
|
if (vm) {
|
|
4793
4719
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -6453,7 +6379,6 @@ function patchShadowRoot(vm, newCh) {
|
|
|
6453
6379
|
// patch function mutates vnodes by adding the element reference,
|
|
6454
6380
|
// however, if patching fails it contains partial changes.
|
|
6455
6381
|
if (oldCh !== newCh) {
|
|
6456
|
-
const fn = hasDynamicChildren(newCh) ? updateDynamicChildren : updateStaticChildren;
|
|
6457
6382
|
runWithBoundaryProtection(vm, vm, () => {
|
|
6458
6383
|
// pre
|
|
6459
6384
|
logOperationStart(2
|
|
@@ -6461,8 +6386,8 @@ function patchShadowRoot(vm, newCh) {
|
|
|
6461
6386
|
, vm);
|
|
6462
6387
|
}, () => {
|
|
6463
6388
|
// job
|
|
6464
|
-
const
|
|
6465
|
-
|
|
6389
|
+
const renderRoot = getRenderRoot(vm);
|
|
6390
|
+
patchChildren(renderRoot, oldCh, newCh);
|
|
6466
6391
|
}, () => {
|
|
6467
6392
|
// post
|
|
6468
6393
|
logOperationEnd(2
|
|
@@ -6756,70 +6681,8 @@ function getErrorBoundaryVM(vm) {
|
|
|
6756
6681
|
|
|
6757
6682
|
currentVm = currentVm.owner;
|
|
6758
6683
|
}
|
|
6759
|
-
} // slow path routine
|
|
6760
|
-
// NOTE: we should probably more this routine to the synthetic shadow folder
|
|
6761
|
-
// and get the allocation to be cached by in the elm instead of in the VM
|
|
6762
|
-
|
|
6763
|
-
|
|
6764
|
-
function allocateInSlot(vm, children) {
|
|
6765
|
-
const {
|
|
6766
|
-
cmpSlots: oldSlots
|
|
6767
|
-
} = vm;
|
|
6768
|
-
const cmpSlots = vm.cmpSlots = create(null);
|
|
6769
|
-
|
|
6770
|
-
for (let i = 0, len = children.length; i < len; i += 1) {
|
|
6771
|
-
const vnode = children[i];
|
|
6772
|
-
|
|
6773
|
-
if (isNull(vnode)) {
|
|
6774
|
-
continue;
|
|
6775
|
-
}
|
|
6776
|
-
|
|
6777
|
-
const {
|
|
6778
|
-
data
|
|
6779
|
-
} = vnode;
|
|
6780
|
-
const slotName = data.attrs && data.attrs.slot || '';
|
|
6781
|
-
const vnodes = cmpSlots[slotName] = cmpSlots[slotName] || []; // re-keying the vnodes is necessary to avoid conflicts with default content for the slot
|
|
6782
|
-
// which might have similar keys. Each vnode will always have a key that
|
|
6783
|
-
// starts with a numeric character from compiler. In this case, we add a unique
|
|
6784
|
-
// notation for slotted vnodes keys, e.g.: `@foo:1:1`
|
|
6785
|
-
|
|
6786
|
-
if (!isUndefined$1(vnode.key)) {
|
|
6787
|
-
vnode.key = `@${slotName}:${vnode.key}`;
|
|
6788
|
-
}
|
|
6789
|
-
|
|
6790
|
-
ArrayPush$1.call(vnodes, vnode);
|
|
6791
|
-
}
|
|
6792
|
-
|
|
6793
|
-
if (isFalse(vm.isDirty)) {
|
|
6794
|
-
// We need to determine if the old allocation is really different from the new one
|
|
6795
|
-
// and mark the vm as dirty
|
|
6796
|
-
const oldKeys = keys(oldSlots);
|
|
6797
|
-
|
|
6798
|
-
if (oldKeys.length !== keys(cmpSlots).length) {
|
|
6799
|
-
markComponentAsDirty(vm);
|
|
6800
|
-
return;
|
|
6801
|
-
}
|
|
6802
|
-
|
|
6803
|
-
for (let i = 0, len = oldKeys.length; i < len; i += 1) {
|
|
6804
|
-
const key = oldKeys[i];
|
|
6805
|
-
|
|
6806
|
-
if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
|
|
6807
|
-
markComponentAsDirty(vm);
|
|
6808
|
-
return;
|
|
6809
|
-
}
|
|
6810
|
-
|
|
6811
|
-
const oldVNodes = oldSlots[key];
|
|
6812
|
-
const vnodes = cmpSlots[key];
|
|
6813
|
-
|
|
6814
|
-
for (let j = 0, a = cmpSlots[key].length; j < a; j += 1) {
|
|
6815
|
-
if (oldVNodes[j] !== vnodes[j]) {
|
|
6816
|
-
markComponentAsDirty(vm);
|
|
6817
|
-
return;
|
|
6818
|
-
}
|
|
6819
|
-
}
|
|
6820
|
-
}
|
|
6821
|
-
}
|
|
6822
6684
|
}
|
|
6685
|
+
|
|
6823
6686
|
function runWithBoundaryProtection(vm, owner, pre, job, post) {
|
|
6824
6687
|
let error;
|
|
6825
6688
|
pre();
|
|
@@ -7256,4 +7119,4 @@ function setHooks(hooks) {
|
|
|
7256
7119
|
}
|
|
7257
7120
|
|
|
7258
7121
|
export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, connectRootElement, createContextProvider, createVM, disconnectRootElement, getAssociatedVMIfPresent, getComponentDef, getComponentInternalDef, getUpgradableConstructor, hydrateRootElement, isComponentConstructor, readonly, register, registerComponent, registerDecorators, registerTemplate, sanitizeAttribute, setAddEventListener, setAssertInstanceOfHTMLElement, setAttachShadow, setCreateComment, setCreateElement, setCreateText, setDefineCustomElement, setDispatchEvent, setGetAttribute, setGetBoundingClientRect, setGetChildNodes, setGetChildren, setGetClassList, setGetCustomElement, setGetElementsByClassName, setGetElementsByTagName, setGetFirstChild, setGetFirstElementChild, setGetLastChild, setGetLastElementChild, setGetProperty, setHTMLElement, setHooks, setInsert, setInsertGlobalStylesheet, setInsertStylesheet, setIsConnected, setIsHydrating, setIsNativeShadowDefined, setIsSyntheticShadowDefined, setNextSibling, setQuerySelector, setQuerySelectorAll, setRemove, setRemoveAttribute, setRemoveEventListener, setSetAttribute, setSetCSSStyleProperty, setSetProperty, setSetText, setSsr, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
|
|
7259
|
-
/* version: 2.7.
|
|
7122
|
+
/* version: 2.7.3 */
|