lwc 2.14.1 → 2.14.2
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 +449 -534
- package/dist/engine-dom/iife/es2017/engine-dom.js +449 -533
- package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es2017/engine-dom_debug.js +393 -478
- package/dist/engine-dom/iife/es5/engine-dom.js +561 -700
- package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es5/engine-dom_debug.js +498 -642
- package/dist/engine-dom/umd/es2017/engine-dom.js +449 -533
- package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es2017/engine-dom_debug.js +393 -478
- package/dist/engine-dom/umd/es5/engine-dom.js +561 -700
- package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es5/engine-dom_debug.js +498 -642
- package/dist/engine-server/commonjs/es2017/engine-server.js +332 -437
- package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
- package/dist/engine-server/esm/es2017/engine-server.js +332 -438
- package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +3 -3
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +3 -3
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +3 -3
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +3 -3
- 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 +2 -2
- package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
- 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 +2 -2
- package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
- package/package.json +7 -7
|
@@ -298,9 +298,9 @@ const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
|
|
|
298
298
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
299
299
|
*/
|
|
300
300
|
// Increment whenever the LWC template compiler changes
|
|
301
|
-
const LWC_VERSION = "2.14.
|
|
301
|
+
const LWC_VERSION = "2.14.2";
|
|
302
302
|
const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
|
|
303
|
-
/** version: 2.14.
|
|
303
|
+
/** version: 2.14.2 */
|
|
304
304
|
|
|
305
305
|
/*
|
|
306
306
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -454,7 +454,32 @@ function setFeatureFlagForTest(name, value) {
|
|
|
454
454
|
setFeatureFlag(name, value);
|
|
455
455
|
}
|
|
456
456
|
}
|
|
457
|
-
/** version: 2.14.
|
|
457
|
+
/** version: 2.14.2 */
|
|
458
|
+
|
|
459
|
+
/*
|
|
460
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
461
|
+
* All rights reserved.
|
|
462
|
+
* SPDX-License-Identifier: MIT
|
|
463
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
464
|
+
*/
|
|
465
|
+
// @ts-ignore
|
|
466
|
+
|
|
467
|
+
if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
|
|
468
|
+
window.addEventListener('test-dummy-flag', () => {
|
|
469
|
+
let hasFlag = false;
|
|
470
|
+
|
|
471
|
+
if (runtimeFlags.DUMMY_TEST_FLAG) {
|
|
472
|
+
hasFlag = true;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
window.dispatchEvent(new CustomEvent('has-dummy-flag', {
|
|
476
|
+
detail: {
|
|
477
|
+
package: '@lwc/engine-dom',
|
|
478
|
+
hasFlag
|
|
479
|
+
}
|
|
480
|
+
}));
|
|
481
|
+
});
|
|
482
|
+
}
|
|
458
483
|
|
|
459
484
|
/* proxy-compat-disable */
|
|
460
485
|
|
|
@@ -564,162 +589,6 @@ function flattenStylesheets(stylesheets) {
|
|
|
564
589
|
return list;
|
|
565
590
|
}
|
|
566
591
|
|
|
567
|
-
//
|
|
568
|
-
// Primitives
|
|
569
|
-
//
|
|
570
|
-
let ssr$1;
|
|
571
|
-
function setSsr(ssrImpl) {
|
|
572
|
-
ssr$1 = ssrImpl;
|
|
573
|
-
}
|
|
574
|
-
let isNativeShadowDefined$1;
|
|
575
|
-
function setIsNativeShadowDefined(isNativeShadowDefinedImpl) {
|
|
576
|
-
isNativeShadowDefined$1 = isNativeShadowDefinedImpl;
|
|
577
|
-
}
|
|
578
|
-
let isSyntheticShadowDefined$1;
|
|
579
|
-
function setIsSyntheticShadowDefined(isSyntheticShadowDefinedImpl) {
|
|
580
|
-
isSyntheticShadowDefined$1 = isSyntheticShadowDefinedImpl;
|
|
581
|
-
}
|
|
582
|
-
let HTMLElementExported$1;
|
|
583
|
-
function setHTMLElement(HTMLElementImpl) {
|
|
584
|
-
HTMLElementExported$1 = HTMLElementImpl;
|
|
585
|
-
}
|
|
586
|
-
let insert$1;
|
|
587
|
-
function setInsert(insertImpl) {
|
|
588
|
-
insert$1 = insertImpl;
|
|
589
|
-
}
|
|
590
|
-
let remove$1;
|
|
591
|
-
function setRemove(removeImpl) {
|
|
592
|
-
remove$1 = removeImpl;
|
|
593
|
-
}
|
|
594
|
-
let createElement$2;
|
|
595
|
-
function setCreateElement(createElementImpl) {
|
|
596
|
-
createElement$2 = createElementImpl;
|
|
597
|
-
}
|
|
598
|
-
let createText$1;
|
|
599
|
-
function setCreateText(createTextImpl) {
|
|
600
|
-
createText$1 = createTextImpl;
|
|
601
|
-
}
|
|
602
|
-
let createComment$1;
|
|
603
|
-
function setCreateComment(createCommentImpl) {
|
|
604
|
-
createComment$1 = createCommentImpl;
|
|
605
|
-
}
|
|
606
|
-
let nextSibling$1;
|
|
607
|
-
function setNextSibling(nextSiblingImpl) {
|
|
608
|
-
nextSibling$1 = nextSiblingImpl;
|
|
609
|
-
}
|
|
610
|
-
let attachShadow$1;
|
|
611
|
-
function setAttachShadow(attachShadowImpl) {
|
|
612
|
-
attachShadow$1 = attachShadowImpl;
|
|
613
|
-
}
|
|
614
|
-
let getProperty$1;
|
|
615
|
-
function setGetProperty(getPropertyImpl) {
|
|
616
|
-
getProperty$1 = getPropertyImpl;
|
|
617
|
-
}
|
|
618
|
-
let setProperty$1;
|
|
619
|
-
function setSetProperty(setPropertyImpl) {
|
|
620
|
-
setProperty$1 = setPropertyImpl;
|
|
621
|
-
}
|
|
622
|
-
let setText$1;
|
|
623
|
-
function setSetText(setTextImpl) {
|
|
624
|
-
setText$1 = setTextImpl;
|
|
625
|
-
}
|
|
626
|
-
let getAttribute$1;
|
|
627
|
-
function setGetAttribute(getAttributeImpl) {
|
|
628
|
-
getAttribute$1 = getAttributeImpl;
|
|
629
|
-
}
|
|
630
|
-
let setAttribute$1;
|
|
631
|
-
function setSetAttribute(setAttributeImpl) {
|
|
632
|
-
setAttribute$1 = setAttributeImpl;
|
|
633
|
-
}
|
|
634
|
-
let removeAttribute$1;
|
|
635
|
-
function setRemoveAttribute(removeAttributeImpl) {
|
|
636
|
-
removeAttribute$1 = removeAttributeImpl;
|
|
637
|
-
}
|
|
638
|
-
let addEventListener$1;
|
|
639
|
-
function setAddEventListener(addEventListenerImpl) {
|
|
640
|
-
addEventListener$1 = addEventListenerImpl;
|
|
641
|
-
}
|
|
642
|
-
let removeEventListener$1;
|
|
643
|
-
function setRemoveEventListener(removeEventListenerImpl) {
|
|
644
|
-
removeEventListener$1 = removeEventListenerImpl;
|
|
645
|
-
}
|
|
646
|
-
let dispatchEvent$1;
|
|
647
|
-
function setDispatchEvent(dispatchEventImpl) {
|
|
648
|
-
dispatchEvent$1 = dispatchEventImpl;
|
|
649
|
-
}
|
|
650
|
-
let getClassList$1;
|
|
651
|
-
function setGetClassList(getClassListImpl) {
|
|
652
|
-
getClassList$1 = getClassListImpl;
|
|
653
|
-
}
|
|
654
|
-
let setCSSStyleProperty$1;
|
|
655
|
-
function setSetCSSStyleProperty(setCSSStylePropertyImpl) {
|
|
656
|
-
setCSSStyleProperty$1 = setCSSStylePropertyImpl;
|
|
657
|
-
}
|
|
658
|
-
let getBoundingClientRect$1;
|
|
659
|
-
function setGetBoundingClientRect(getBoundingClientRectImpl) {
|
|
660
|
-
getBoundingClientRect$1 = getBoundingClientRectImpl;
|
|
661
|
-
}
|
|
662
|
-
let querySelector$1;
|
|
663
|
-
function setQuerySelector(querySelectorImpl) {
|
|
664
|
-
querySelector$1 = querySelectorImpl;
|
|
665
|
-
}
|
|
666
|
-
let querySelectorAll$1;
|
|
667
|
-
function setQuerySelectorAll(querySelectorAllImpl) {
|
|
668
|
-
querySelectorAll$1 = querySelectorAllImpl;
|
|
669
|
-
}
|
|
670
|
-
let getElementsByTagName$1;
|
|
671
|
-
function setGetElementsByTagName(getElementsByTagNameImpl) {
|
|
672
|
-
getElementsByTagName$1 = getElementsByTagNameImpl;
|
|
673
|
-
}
|
|
674
|
-
let getElementsByClassName$1;
|
|
675
|
-
function setGetElementsByClassName(getElementsByClassNameImpl) {
|
|
676
|
-
getElementsByClassName$1 = getElementsByClassNameImpl;
|
|
677
|
-
}
|
|
678
|
-
let getChildren$1;
|
|
679
|
-
function setGetChildren(getChildrenImpl) {
|
|
680
|
-
getChildren$1 = getChildrenImpl;
|
|
681
|
-
}
|
|
682
|
-
let getChildNodes$1;
|
|
683
|
-
function setGetChildNodes(getChildNodesImpl) {
|
|
684
|
-
getChildNodes$1 = getChildNodesImpl;
|
|
685
|
-
}
|
|
686
|
-
let getFirstChild$1;
|
|
687
|
-
function setGetFirstChild(getFirstChildImpl) {
|
|
688
|
-
getFirstChild$1 = getFirstChildImpl;
|
|
689
|
-
}
|
|
690
|
-
let getFirstElementChild$1;
|
|
691
|
-
function setGetFirstElementChild(getFirstElementChildImpl) {
|
|
692
|
-
getFirstElementChild$1 = getFirstElementChildImpl;
|
|
693
|
-
}
|
|
694
|
-
let getLastChild$1;
|
|
695
|
-
function setGetLastChild(getLastChildImpl) {
|
|
696
|
-
getLastChild$1 = getLastChildImpl;
|
|
697
|
-
}
|
|
698
|
-
let getLastElementChild$1;
|
|
699
|
-
function setGetLastElementChild(getLastElementChildImpl) {
|
|
700
|
-
getLastElementChild$1 = getLastElementChildImpl;
|
|
701
|
-
}
|
|
702
|
-
let isConnected$1;
|
|
703
|
-
function setIsConnected(isConnectedImpl) {
|
|
704
|
-
isConnected$1 = isConnectedImpl;
|
|
705
|
-
}
|
|
706
|
-
let insertStylesheet$1;
|
|
707
|
-
function setInsertStylesheet(insertStylesheetImpl) {
|
|
708
|
-
insertStylesheet$1 = insertStylesheetImpl;
|
|
709
|
-
}
|
|
710
|
-
let assertInstanceOfHTMLElement$1;
|
|
711
|
-
function setAssertInstanceOfHTMLElement(assertInstanceOfHTMLElementImpl) {
|
|
712
|
-
assertInstanceOfHTMLElement$1 = assertInstanceOfHTMLElementImpl;
|
|
713
|
-
}
|
|
714
|
-
let defineCustomElement$1;
|
|
715
|
-
function setDefineCustomElement(defineCustomElementImpl) {
|
|
716
|
-
defineCustomElement$1 = defineCustomElementImpl;
|
|
717
|
-
}
|
|
718
|
-
let getCustomElement$1;
|
|
719
|
-
function setGetCustomElement(getCustomElementImpl) {
|
|
720
|
-
getCustomElement$1 = getCustomElementImpl;
|
|
721
|
-
}
|
|
722
|
-
|
|
723
592
|
/*
|
|
724
593
|
* Copyright (c) 2019, salesforce.com, inc.
|
|
725
594
|
* All rights reserved.
|
|
@@ -2024,7 +1893,8 @@ const LightningElement = function () {
|
|
|
2024
1893
|
const { def, elm } = vm;
|
|
2025
1894
|
const { bridge } = def;
|
|
2026
1895
|
if (process.env.NODE_ENV !== 'production') {
|
|
2027
|
-
|
|
1896
|
+
const { assertInstanceOfHTMLElement } = vm.renderer;
|
|
1897
|
+
assertInstanceOfHTMLElement(vm.elm, `Component creation requires a DOM element to be associated to ${vm}.`);
|
|
2028
1898
|
}
|
|
2029
1899
|
const component = this;
|
|
2030
1900
|
setPrototypeOf(elm, bridge.prototype);
|
|
@@ -2058,8 +1928,8 @@ const LightningElement = function () {
|
|
|
2058
1928
|
return this;
|
|
2059
1929
|
};
|
|
2060
1930
|
function doAttachShadow(vm) {
|
|
2061
|
-
const { elm, mode, shadowMode, def: { ctor }, } = vm;
|
|
2062
|
-
const shadowRoot = attachShadow
|
|
1931
|
+
const { elm, mode, shadowMode, def: { ctor }, renderer: { attachShadow }, } = vm;
|
|
1932
|
+
const shadowRoot = attachShadow(elm, {
|
|
2063
1933
|
[KEY__SYNTHETIC_MODE]: shadowMode === 1 /* Synthetic */,
|
|
2064
1934
|
delegatesFocus: Boolean(ctor.delegatesFocus),
|
|
2065
1935
|
mode,
|
|
@@ -2080,12 +1950,13 @@ function warnIfInvokedDuringConstruction(vm, methodOrPropName) {
|
|
|
2080
1950
|
LightningElement.prototype = {
|
|
2081
1951
|
constructor: LightningElement,
|
|
2082
1952
|
dispatchEvent(event) {
|
|
2083
|
-
const
|
|
2084
|
-
|
|
1953
|
+
const vm = getAssociatedVM(this);
|
|
1954
|
+
const { elm, renderer: { dispatchEvent }, } = vm;
|
|
1955
|
+
return dispatchEvent(elm, event);
|
|
2085
1956
|
},
|
|
2086
1957
|
addEventListener(type, listener, options) {
|
|
2087
1958
|
const vm = getAssociatedVM(this);
|
|
2088
|
-
const { elm } = vm;
|
|
1959
|
+
const { elm, renderer: { addEventListener }, } = vm;
|
|
2089
1960
|
if (process.env.NODE_ENV !== 'production') {
|
|
2090
1961
|
const vmBeingRendered = getVMBeingRendered();
|
|
2091
1962
|
assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm} by adding an event listener for "${type}".`);
|
|
@@ -2093,83 +1964,91 @@ LightningElement.prototype = {
|
|
|
2093
1964
|
assert.invariant(isFunction$1(listener), `Invalid second argument for this.addEventListener() in ${vm} for event "${type}". Expected an EventListener but received ${listener}.`);
|
|
2094
1965
|
}
|
|
2095
1966
|
const wrappedListener = getWrappedComponentsListener(vm, listener);
|
|
2096
|
-
addEventListener
|
|
1967
|
+
addEventListener(elm, type, wrappedListener, options);
|
|
2097
1968
|
},
|
|
2098
1969
|
removeEventListener(type, listener, options) {
|
|
2099
1970
|
const vm = getAssociatedVM(this);
|
|
2100
|
-
const { elm } = vm;
|
|
1971
|
+
const { elm, renderer: { removeEventListener }, } = vm;
|
|
2101
1972
|
const wrappedListener = getWrappedComponentsListener(vm, listener);
|
|
2102
|
-
removeEventListener
|
|
1973
|
+
removeEventListener(elm, type, wrappedListener, options);
|
|
2103
1974
|
},
|
|
2104
1975
|
hasAttribute(name) {
|
|
2105
|
-
const
|
|
2106
|
-
|
|
1976
|
+
const vm = getAssociatedVM(this);
|
|
1977
|
+
const { elm, renderer: { getAttribute }, } = vm;
|
|
1978
|
+
return !isNull(getAttribute(elm, name));
|
|
2107
1979
|
},
|
|
2108
1980
|
hasAttributeNS(namespace, name) {
|
|
2109
|
-
const
|
|
2110
|
-
|
|
1981
|
+
const vm = getAssociatedVM(this);
|
|
1982
|
+
const { elm, renderer: { getAttribute }, } = vm;
|
|
1983
|
+
return !isNull(getAttribute(elm, name, namespace));
|
|
2111
1984
|
},
|
|
2112
1985
|
removeAttribute(name) {
|
|
2113
|
-
const
|
|
1986
|
+
const vm = getAssociatedVM(this);
|
|
1987
|
+
const { elm, renderer: { removeAttribute }, } = vm;
|
|
2114
1988
|
unlockAttribute(elm, name);
|
|
2115
|
-
removeAttribute
|
|
1989
|
+
removeAttribute(elm, name);
|
|
2116
1990
|
lockAttribute();
|
|
2117
1991
|
},
|
|
2118
1992
|
removeAttributeNS(namespace, name) {
|
|
2119
|
-
const { elm } = getAssociatedVM(this);
|
|
1993
|
+
const { elm, renderer: { removeAttribute }, } = getAssociatedVM(this);
|
|
2120
1994
|
unlockAttribute(elm, name);
|
|
2121
|
-
removeAttribute
|
|
1995
|
+
removeAttribute(elm, name, namespace);
|
|
2122
1996
|
lockAttribute();
|
|
2123
1997
|
},
|
|
2124
1998
|
getAttribute(name) {
|
|
2125
|
-
const
|
|
2126
|
-
|
|
1999
|
+
const vm = getAssociatedVM(this);
|
|
2000
|
+
const { elm } = vm;
|
|
2001
|
+
const { getAttribute } = vm.renderer;
|
|
2002
|
+
return getAttribute(elm, name);
|
|
2127
2003
|
},
|
|
2128
2004
|
getAttributeNS(namespace, name) {
|
|
2129
|
-
const
|
|
2130
|
-
|
|
2005
|
+
const vm = getAssociatedVM(this);
|
|
2006
|
+
const { elm } = vm;
|
|
2007
|
+
const { getAttribute } = vm.renderer;
|
|
2008
|
+
return getAttribute(elm, name, namespace);
|
|
2131
2009
|
},
|
|
2132
2010
|
setAttribute(name, value) {
|
|
2133
2011
|
const vm = getAssociatedVM(this);
|
|
2134
|
-
const { elm } = vm;
|
|
2012
|
+
const { elm, renderer: { setAttribute }, } = vm;
|
|
2135
2013
|
if (process.env.NODE_ENV !== 'production') {
|
|
2136
2014
|
assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
|
|
2137
2015
|
}
|
|
2138
2016
|
unlockAttribute(elm, name);
|
|
2139
|
-
setAttribute
|
|
2017
|
+
setAttribute(elm, name, value);
|
|
2140
2018
|
lockAttribute();
|
|
2141
2019
|
},
|
|
2142
2020
|
setAttributeNS(namespace, name, value) {
|
|
2143
2021
|
const vm = getAssociatedVM(this);
|
|
2144
|
-
const { elm } = vm;
|
|
2022
|
+
const { elm, renderer: { setAttribute }, } = vm;
|
|
2145
2023
|
if (process.env.NODE_ENV !== 'production') {
|
|
2146
2024
|
assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
|
|
2147
2025
|
}
|
|
2148
2026
|
unlockAttribute(elm, name);
|
|
2149
|
-
setAttribute
|
|
2027
|
+
setAttribute(elm, name, value, namespace);
|
|
2150
2028
|
lockAttribute();
|
|
2151
2029
|
},
|
|
2152
2030
|
getBoundingClientRect() {
|
|
2153
2031
|
const vm = getAssociatedVM(this);
|
|
2154
|
-
const { elm } = vm;
|
|
2032
|
+
const { elm, renderer: { getBoundingClientRect }, } = vm;
|
|
2155
2033
|
if (process.env.NODE_ENV !== 'production') {
|
|
2156
2034
|
warnIfInvokedDuringConstruction(vm, 'getBoundingClientRect()');
|
|
2157
2035
|
}
|
|
2158
|
-
return getBoundingClientRect
|
|
2036
|
+
return getBoundingClientRect(elm);
|
|
2159
2037
|
},
|
|
2160
2038
|
get isConnected() {
|
|
2161
|
-
const
|
|
2162
|
-
|
|
2039
|
+
const vm = getAssociatedVM(this);
|
|
2040
|
+
const { elm, renderer: { isConnected }, } = vm;
|
|
2041
|
+
return isConnected(elm);
|
|
2163
2042
|
},
|
|
2164
2043
|
get classList() {
|
|
2165
2044
|
const vm = getAssociatedVM(this);
|
|
2166
|
-
const { elm } = vm;
|
|
2045
|
+
const { elm, renderer: { getClassList }, } = vm;
|
|
2167
2046
|
if (process.env.NODE_ENV !== 'production') {
|
|
2168
2047
|
// TODO [#1290]: this still fails in dev but works in production, eventually, we should
|
|
2169
2048
|
// just throw in all modes
|
|
2170
2049
|
assert.isFalse(isBeingConstructed(vm), `Failed to construct ${vm}: The result must not have attributes. Adding or tampering with classname in constructor is not allowed in a web component, use connectedCallback() instead.`);
|
|
2171
2050
|
}
|
|
2172
|
-
return getClassList
|
|
2051
|
+
return getClassList(elm);
|
|
2173
2052
|
},
|
|
2174
2053
|
get template() {
|
|
2175
2054
|
const vm = getAssociatedVM(this);
|
|
@@ -2185,6 +2064,54 @@ LightningElement.prototype = {
|
|
|
2185
2064
|
// Authors should rely on this.template instead.
|
|
2186
2065
|
return null;
|
|
2187
2066
|
},
|
|
2067
|
+
get children() {
|
|
2068
|
+
const vm = getAssociatedVM(this);
|
|
2069
|
+
const renderer = vm.renderer;
|
|
2070
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2071
|
+
warnIfInvokedDuringConstruction(vm, 'children');
|
|
2072
|
+
}
|
|
2073
|
+
return renderer.getChildren(vm.elm);
|
|
2074
|
+
},
|
|
2075
|
+
get childNodes() {
|
|
2076
|
+
const vm = getAssociatedVM(this);
|
|
2077
|
+
const renderer = vm.renderer;
|
|
2078
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2079
|
+
warnIfInvokedDuringConstruction(vm, 'childNodes');
|
|
2080
|
+
}
|
|
2081
|
+
return renderer.getChildNodes(vm.elm);
|
|
2082
|
+
},
|
|
2083
|
+
get firstChild() {
|
|
2084
|
+
const vm = getAssociatedVM(this);
|
|
2085
|
+
const renderer = vm.renderer;
|
|
2086
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2087
|
+
warnIfInvokedDuringConstruction(vm, 'firstChild');
|
|
2088
|
+
}
|
|
2089
|
+
return renderer.getFirstChild(vm.elm);
|
|
2090
|
+
},
|
|
2091
|
+
get firstElementChild() {
|
|
2092
|
+
const vm = getAssociatedVM(this);
|
|
2093
|
+
const renderer = vm.renderer;
|
|
2094
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2095
|
+
warnIfInvokedDuringConstruction(vm, 'firstElementChild');
|
|
2096
|
+
}
|
|
2097
|
+
return renderer.getFirstElementChild(vm.elm);
|
|
2098
|
+
},
|
|
2099
|
+
get lastChild() {
|
|
2100
|
+
const vm = getAssociatedVM(this);
|
|
2101
|
+
const renderer = vm.renderer;
|
|
2102
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2103
|
+
warnIfInvokedDuringConstruction(vm, 'lastChild');
|
|
2104
|
+
}
|
|
2105
|
+
return renderer.getLastChild(vm.elm);
|
|
2106
|
+
},
|
|
2107
|
+
get lastElementChild() {
|
|
2108
|
+
const vm = getAssociatedVM(this);
|
|
2109
|
+
const renderer = vm.renderer;
|
|
2110
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2111
|
+
warnIfInvokedDuringConstruction(vm, 'lastElementChild');
|
|
2112
|
+
}
|
|
2113
|
+
return renderer.getLastElementChild(vm.elm);
|
|
2114
|
+
},
|
|
2188
2115
|
render() {
|
|
2189
2116
|
const vm = getAssociatedVM(this);
|
|
2190
2117
|
return vm.def.template;
|
|
@@ -2195,76 +2122,22 @@ LightningElement.prototype = {
|
|
|
2195
2122
|
},
|
|
2196
2123
|
};
|
|
2197
2124
|
const queryAndChildGetterDescriptors = create(null);
|
|
2198
|
-
// The reason we don't just call `import * as renderer from '../renderer'` here is that the bundle size
|
|
2199
|
-
// is smaller if we reference each function individually. Otherwise Rollup will create one big frozen
|
|
2200
|
-
// object representing the renderer, with a lot of methods we don't actually need.
|
|
2201
|
-
const childGetters = [
|
|
2202
|
-
'children',
|
|
2203
|
-
'childNodes',
|
|
2204
|
-
'firstChild',
|
|
2205
|
-
'firstElementChild',
|
|
2206
|
-
'lastChild',
|
|
2207
|
-
'lastElementChild',
|
|
2208
|
-
];
|
|
2209
|
-
function getChildGetter(methodName) {
|
|
2210
|
-
switch (methodName) {
|
|
2211
|
-
case 'children':
|
|
2212
|
-
return getChildren$1;
|
|
2213
|
-
case 'childNodes':
|
|
2214
|
-
return getChildNodes$1;
|
|
2215
|
-
case 'firstChild':
|
|
2216
|
-
return getFirstChild$1;
|
|
2217
|
-
case 'firstElementChild':
|
|
2218
|
-
return getFirstElementChild$1;
|
|
2219
|
-
case 'lastChild':
|
|
2220
|
-
return getLastChild$1;
|
|
2221
|
-
case 'lastElementChild':
|
|
2222
|
-
return getLastElementChild$1;
|
|
2223
|
-
}
|
|
2224
|
-
}
|
|
2225
|
-
// Generic passthrough for child getters on HTMLElement to the relevant Renderer APIs
|
|
2226
|
-
for (const childGetter of childGetters) {
|
|
2227
|
-
queryAndChildGetterDescriptors[childGetter] = {
|
|
2228
|
-
get() {
|
|
2229
|
-
const vm = getAssociatedVM(this);
|
|
2230
|
-
const { elm } = vm;
|
|
2231
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2232
|
-
warnIfInvokedDuringConstruction(vm, childGetter);
|
|
2233
|
-
}
|
|
2234
|
-
return getChildGetter(childGetter)(elm);
|
|
2235
|
-
},
|
|
2236
|
-
configurable: true,
|
|
2237
|
-
enumerable: true,
|
|
2238
|
-
};
|
|
2239
|
-
}
|
|
2240
2125
|
const queryMethods = [
|
|
2241
2126
|
'getElementsByClassName',
|
|
2242
2127
|
'getElementsByTagName',
|
|
2243
2128
|
'querySelector',
|
|
2244
2129
|
'querySelectorAll',
|
|
2245
2130
|
];
|
|
2246
|
-
function getQueryMethod(methodName) {
|
|
2247
|
-
switch (methodName) {
|
|
2248
|
-
case 'getElementsByClassName':
|
|
2249
|
-
return getElementsByClassName$1;
|
|
2250
|
-
case 'getElementsByTagName':
|
|
2251
|
-
return getElementsByTagName$1;
|
|
2252
|
-
case 'querySelector':
|
|
2253
|
-
return querySelector$1;
|
|
2254
|
-
case 'querySelectorAll':
|
|
2255
|
-
return querySelectorAll$1;
|
|
2256
|
-
}
|
|
2257
|
-
}
|
|
2258
2131
|
// Generic passthrough for query APIs on HTMLElement to the relevant Renderer APIs
|
|
2259
2132
|
for (const queryMethod of queryMethods) {
|
|
2260
2133
|
queryAndChildGetterDescriptors[queryMethod] = {
|
|
2261
2134
|
value(arg) {
|
|
2262
2135
|
const vm = getAssociatedVM(this);
|
|
2263
|
-
const { elm } = vm;
|
|
2136
|
+
const { elm, renderer } = vm;
|
|
2264
2137
|
if (process.env.NODE_ENV !== 'production') {
|
|
2265
2138
|
warnIfInvokedDuringConstruction(vm, `${queryMethod}()`);
|
|
2266
2139
|
}
|
|
2267
|
-
return
|
|
2140
|
+
return renderer[queryMethod](elm, arg);
|
|
2268
2141
|
},
|
|
2269
2142
|
configurable: true,
|
|
2270
2143
|
enumerable: true,
|
|
@@ -3488,12 +3361,13 @@ function getComponentDef(Ctor) {
|
|
|
3488
3361
|
* SPDX-License-Identifier: MIT
|
|
3489
3362
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3490
3363
|
*/
|
|
3491
|
-
function getUpgradableConstructor(tagName) {
|
|
3364
|
+
function getUpgradableConstructor(tagName, renderer) {
|
|
3365
|
+
const { getCustomElement, HTMLElementExported: RendererHTMLElement, defineCustomElement, } = renderer;
|
|
3492
3366
|
// Should never get a tag with upper case letter at this point, the compiler should
|
|
3493
3367
|
// produce only tags with lowercase letters
|
|
3494
3368
|
// But, for backwards compatibility, we will lower case the tagName
|
|
3495
3369
|
tagName = tagName.toLowerCase();
|
|
3496
|
-
let CE = getCustomElement
|
|
3370
|
+
let CE = getCustomElement(tagName);
|
|
3497
3371
|
if (!isUndefined$1(CE)) {
|
|
3498
3372
|
return CE;
|
|
3499
3373
|
}
|
|
@@ -3501,7 +3375,7 @@ function getUpgradableConstructor(tagName) {
|
|
|
3501
3375
|
* LWC Upgradable Element reference to an element that was created
|
|
3502
3376
|
* via the scoped registry mechanism, and that is ready to be upgraded.
|
|
3503
3377
|
*/
|
|
3504
|
-
CE = class LWCUpgradableElement extends
|
|
3378
|
+
CE = class LWCUpgradableElement extends RendererHTMLElement {
|
|
3505
3379
|
constructor(upgradeCallback) {
|
|
3506
3380
|
super();
|
|
3507
3381
|
if (isFunction$1(upgradeCallback)) {
|
|
@@ -3509,7 +3383,7 @@ function getUpgradableConstructor(tagName) {
|
|
|
3509
3383
|
}
|
|
3510
3384
|
}
|
|
3511
3385
|
};
|
|
3512
|
-
defineCustomElement
|
|
3386
|
+
defineCustomElement(tagName, CE);
|
|
3513
3387
|
return CE;
|
|
3514
3388
|
}
|
|
3515
3389
|
|
|
@@ -3534,7 +3408,7 @@ function isSameVnode(vnode1, vnode2) {
|
|
|
3534
3408
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3535
3409
|
*/
|
|
3536
3410
|
const ColonCharCode = 58;
|
|
3537
|
-
function patchAttributes(oldVnode, vnode) {
|
|
3411
|
+
function patchAttributes(oldVnode, vnode, renderer) {
|
|
3538
3412
|
const { attrs } = vnode.data;
|
|
3539
3413
|
if (isUndefined$1(attrs)) {
|
|
3540
3414
|
return;
|
|
@@ -3544,6 +3418,7 @@ function patchAttributes(oldVnode, vnode) {
|
|
|
3544
3418
|
return;
|
|
3545
3419
|
}
|
|
3546
3420
|
const { elm } = vnode;
|
|
3421
|
+
const { setAttribute, removeAttribute } = renderer;
|
|
3547
3422
|
for (const key in attrs) {
|
|
3548
3423
|
const cur = attrs[key];
|
|
3549
3424
|
const old = oldAttrs[key];
|
|
@@ -3551,17 +3426,17 @@ function patchAttributes(oldVnode, vnode) {
|
|
|
3551
3426
|
unlockAttribute(elm, key);
|
|
3552
3427
|
if (StringCharCodeAt.call(key, 3) === ColonCharCode) {
|
|
3553
3428
|
// Assume xml namespace
|
|
3554
|
-
setAttribute
|
|
3429
|
+
setAttribute(elm, key, cur, XML_NAMESPACE);
|
|
3555
3430
|
}
|
|
3556
3431
|
else if (StringCharCodeAt.call(key, 5) === ColonCharCode) {
|
|
3557
3432
|
// Assume xlink namespace
|
|
3558
|
-
setAttribute
|
|
3433
|
+
setAttribute(elm, key, cur, XLINK_NAMESPACE);
|
|
3559
3434
|
}
|
|
3560
3435
|
else if (isNull(cur) || isUndefined$1(cur)) {
|
|
3561
|
-
removeAttribute
|
|
3436
|
+
removeAttribute(elm, key);
|
|
3562
3437
|
}
|
|
3563
3438
|
else {
|
|
3564
|
-
setAttribute
|
|
3439
|
+
setAttribute(elm, key, cur);
|
|
3565
3440
|
}
|
|
3566
3441
|
lockAttribute();
|
|
3567
3442
|
}
|
|
@@ -3579,7 +3454,7 @@ function isLiveBindingProp(sel, key) {
|
|
|
3579
3454
|
// instead of relying on internally tracked values.
|
|
3580
3455
|
return sel === 'input' && (key === 'value' || key === 'checked');
|
|
3581
3456
|
}
|
|
3582
|
-
function patchProps(oldVnode, vnode) {
|
|
3457
|
+
function patchProps(oldVnode, vnode, renderer) {
|
|
3583
3458
|
const { props } = vnode.data;
|
|
3584
3459
|
if (isUndefined$1(props)) {
|
|
3585
3460
|
return;
|
|
@@ -3590,13 +3465,14 @@ function patchProps(oldVnode, vnode) {
|
|
|
3590
3465
|
}
|
|
3591
3466
|
const isFirstPatch = isNull(oldVnode);
|
|
3592
3467
|
const { elm, sel } = vnode;
|
|
3468
|
+
const { getProperty, setProperty } = renderer;
|
|
3593
3469
|
for (const key in props) {
|
|
3594
3470
|
const cur = props[key];
|
|
3595
3471
|
// Set the property if it's the first time is is patched or if the previous property is
|
|
3596
3472
|
// different than the one previously set.
|
|
3597
3473
|
if (isFirstPatch ||
|
|
3598
|
-
cur !== (isLiveBindingProp(sel, key) ? getProperty
|
|
3599
|
-
setProperty
|
|
3474
|
+
cur !== (isLiveBindingProp(sel, key) ? getProperty(elm, key) : oldProps[key])) {
|
|
3475
|
+
setProperty(elm, key, cur);
|
|
3600
3476
|
}
|
|
3601
3477
|
}
|
|
3602
3478
|
}
|
|
@@ -3641,13 +3517,14 @@ function getMapFromClassName(className) {
|
|
|
3641
3517
|
}
|
|
3642
3518
|
return map;
|
|
3643
3519
|
}
|
|
3644
|
-
function patchClassAttribute(oldVnode, vnode) {
|
|
3520
|
+
function patchClassAttribute(oldVnode, vnode, renderer) {
|
|
3645
3521
|
const { elm, data: { className: newClass }, } = vnode;
|
|
3646
3522
|
const oldClass = isNull(oldVnode) ? undefined : oldVnode.data.className;
|
|
3647
3523
|
if (oldClass === newClass) {
|
|
3648
3524
|
return;
|
|
3649
3525
|
}
|
|
3650
|
-
const
|
|
3526
|
+
const { getClassList } = renderer;
|
|
3527
|
+
const classList = getClassList(elm);
|
|
3651
3528
|
const newClassMap = getMapFromClassName(newClass);
|
|
3652
3529
|
const oldClassMap = getMapFromClassName(oldClass);
|
|
3653
3530
|
let name;
|
|
@@ -3671,17 +3548,18 @@ function patchClassAttribute(oldVnode, vnode) {
|
|
|
3671
3548
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3672
3549
|
*/
|
|
3673
3550
|
// The style property is a string when defined via an expression in the template.
|
|
3674
|
-
function patchStyleAttribute(oldVnode, vnode) {
|
|
3551
|
+
function patchStyleAttribute(oldVnode, vnode, renderer) {
|
|
3675
3552
|
const { elm, data: { style: newStyle }, } = vnode;
|
|
3676
3553
|
const oldStyle = isNull(oldVnode) ? undefined : oldVnode.data.style;
|
|
3677
3554
|
if (oldStyle === newStyle) {
|
|
3678
3555
|
return;
|
|
3679
3556
|
}
|
|
3557
|
+
const { setAttribute, removeAttribute } = renderer;
|
|
3680
3558
|
if (!isString(newStyle) || newStyle === '') {
|
|
3681
|
-
removeAttribute
|
|
3559
|
+
removeAttribute(elm, 'style');
|
|
3682
3560
|
}
|
|
3683
3561
|
else {
|
|
3684
|
-
setAttribute
|
|
3562
|
+
setAttribute(elm, 'style', newStyle);
|
|
3685
3563
|
}
|
|
3686
3564
|
}
|
|
3687
3565
|
|
|
@@ -3691,14 +3569,15 @@ function patchStyleAttribute(oldVnode, vnode) {
|
|
|
3691
3569
|
* SPDX-License-Identifier: MIT
|
|
3692
3570
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3693
3571
|
*/
|
|
3694
|
-
function applyEventListeners(vnode) {
|
|
3572
|
+
function applyEventListeners(vnode, renderer) {
|
|
3695
3573
|
const { elm, data: { on }, } = vnode;
|
|
3696
3574
|
if (isUndefined$1(on)) {
|
|
3697
3575
|
return;
|
|
3698
3576
|
}
|
|
3577
|
+
const { addEventListener } = renderer;
|
|
3699
3578
|
for (const name in on) {
|
|
3700
3579
|
const handler = on[name];
|
|
3701
|
-
addEventListener
|
|
3580
|
+
addEventListener(elm, name, handler);
|
|
3702
3581
|
}
|
|
3703
3582
|
}
|
|
3704
3583
|
|
|
@@ -3711,12 +3590,13 @@ function applyEventListeners(vnode) {
|
|
|
3711
3590
|
// The HTML class property becomes the vnode.data.classMap object when defined as a string in the template.
|
|
3712
3591
|
// The compiler takes care of transforming the inline classnames into an object. It's faster to set the
|
|
3713
3592
|
// different classnames properties individually instead of via a string.
|
|
3714
|
-
function applyStaticClassAttribute(vnode) {
|
|
3593
|
+
function applyStaticClassAttribute(vnode, renderer) {
|
|
3715
3594
|
const { elm, data: { classMap }, } = vnode;
|
|
3716
3595
|
if (isUndefined$1(classMap)) {
|
|
3717
3596
|
return;
|
|
3718
3597
|
}
|
|
3719
|
-
const
|
|
3598
|
+
const { getClassList } = renderer;
|
|
3599
|
+
const classList = getClassList(elm);
|
|
3720
3600
|
for (const name in classMap) {
|
|
3721
3601
|
classList.add(name);
|
|
3722
3602
|
}
|
|
@@ -3731,14 +3611,15 @@ function applyStaticClassAttribute(vnode) {
|
|
|
3731
3611
|
// The HTML style property becomes the vnode.data.styleDecls object when defined as a string in the template.
|
|
3732
3612
|
// The compiler takes care of transforming the inline style into an object. It's faster to set the
|
|
3733
3613
|
// different style properties individually instead of via a string.
|
|
3734
|
-
function applyStaticStyleAttribute(vnode) {
|
|
3614
|
+
function applyStaticStyleAttribute(vnode, renderer) {
|
|
3735
3615
|
const { elm, data: { styleDecls }, } = vnode;
|
|
3736
3616
|
if (isUndefined$1(styleDecls)) {
|
|
3737
3617
|
return;
|
|
3738
3618
|
}
|
|
3619
|
+
const { setCSSStyleProperty } = renderer;
|
|
3739
3620
|
for (let i = 0; i < styleDecls.length; i++) {
|
|
3740
3621
|
const [prop, value, important] = styleDecls[i];
|
|
3741
|
-
setCSSStyleProperty
|
|
3622
|
+
setCSSStyleProperty(elm, prop, value, important);
|
|
3742
3623
|
}
|
|
3743
3624
|
}
|
|
3744
3625
|
|
|
@@ -3748,15 +3629,16 @@ function applyStaticStyleAttribute(vnode) {
|
|
|
3748
3629
|
* SPDX-License-Identifier: MIT
|
|
3749
3630
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3750
3631
|
*/
|
|
3751
|
-
function patchChildren(c1, c2, parent) {
|
|
3632
|
+
function patchChildren(c1, c2, parent, renderer) {
|
|
3752
3633
|
if (hasDynamicChildren(c2)) {
|
|
3753
|
-
updateDynamicChildren(c1, c2, parent);
|
|
3634
|
+
updateDynamicChildren(c1, c2, parent, renderer);
|
|
3754
3635
|
}
|
|
3755
3636
|
else {
|
|
3756
|
-
updateStaticChildren(c1, c2, parent);
|
|
3637
|
+
updateStaticChildren(c1, c2, parent, renderer);
|
|
3757
3638
|
}
|
|
3758
3639
|
}
|
|
3759
|
-
function patch(n1, n2) {
|
|
3640
|
+
function patch(n1, n2, renderer) {
|
|
3641
|
+
var _a, _b;
|
|
3760
3642
|
if (n1 === n2) {
|
|
3761
3643
|
return;
|
|
3762
3644
|
}
|
|
@@ -3770,80 +3652,90 @@ function patch(n1, n2) {
|
|
|
3770
3652
|
}
|
|
3771
3653
|
switch (n2.type) {
|
|
3772
3654
|
case 0 /* Text */:
|
|
3773
|
-
|
|
3655
|
+
// VText has no special capability, fallback to the owner's renderer
|
|
3656
|
+
patchText(n1, n2, renderer);
|
|
3774
3657
|
break;
|
|
3775
3658
|
case 1 /* Comment */:
|
|
3776
|
-
|
|
3659
|
+
// VComment has no special capability, fallback to the owner's renderer
|
|
3660
|
+
patchComment(n1, n2, renderer);
|
|
3777
3661
|
break;
|
|
3778
3662
|
case 2 /* Element */:
|
|
3779
|
-
patchElement(n1, n2);
|
|
3663
|
+
patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
|
|
3780
3664
|
break;
|
|
3781
3665
|
case 3 /* CustomElement */:
|
|
3782
|
-
patchCustomElement(n1, n2);
|
|
3666
|
+
patchCustomElement(n1, n2, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
|
|
3783
3667
|
break;
|
|
3784
3668
|
}
|
|
3785
3669
|
}
|
|
3786
|
-
function mount(node, parent, anchor) {
|
|
3670
|
+
function mount(node, parent, renderer, anchor) {
|
|
3671
|
+
var _a, _b;
|
|
3787
3672
|
switch (node.type) {
|
|
3788
3673
|
case 0 /* Text */:
|
|
3789
|
-
|
|
3674
|
+
// VText has no special capability, fallback to the owner's renderer
|
|
3675
|
+
mountText(node, parent, anchor, renderer);
|
|
3790
3676
|
break;
|
|
3791
3677
|
case 1 /* Comment */:
|
|
3792
|
-
|
|
3678
|
+
// VComment has no special capability, fallback to the owner's renderer
|
|
3679
|
+
mountComment(node, parent, anchor, renderer);
|
|
3793
3680
|
break;
|
|
3794
3681
|
case 2 /* Element */:
|
|
3795
|
-
|
|
3682
|
+
// If the vnode data has a renderer override use it, else fallback to owner's renderer
|
|
3683
|
+
mountElement(node, parent, anchor, (_a = node.data.renderer) !== null && _a !== void 0 ? _a : renderer);
|
|
3796
3684
|
break;
|
|
3797
3685
|
case 3 /* CustomElement */:
|
|
3798
|
-
|
|
3686
|
+
// If the vnode data has a renderer override use it, else fallback to owner's renderer
|
|
3687
|
+
mountCustomElement(node, parent, anchor, (_b = node.data.renderer) !== null && _b !== void 0 ? _b : renderer);
|
|
3799
3688
|
break;
|
|
3800
3689
|
}
|
|
3801
3690
|
}
|
|
3802
|
-
function patchText(n1, n2) {
|
|
3691
|
+
function patchText(n1, n2, renderer) {
|
|
3803
3692
|
n2.elm = n1.elm;
|
|
3804
3693
|
if (n2.text !== n1.text) {
|
|
3805
|
-
updateTextContent(n2);
|
|
3694
|
+
updateTextContent(n2, renderer);
|
|
3806
3695
|
}
|
|
3807
3696
|
}
|
|
3808
|
-
function mountText(
|
|
3809
|
-
const { owner } =
|
|
3810
|
-
const
|
|
3811
|
-
|
|
3812
|
-
|
|
3697
|
+
function mountText(vnode, parent, anchor, renderer) {
|
|
3698
|
+
const { owner } = vnode;
|
|
3699
|
+
const { createText } = renderer;
|
|
3700
|
+
const textNode = (vnode.elm = createText(vnode.text));
|
|
3701
|
+
linkNodeToShadow(textNode, owner, renderer);
|
|
3702
|
+
insertNode(textNode, parent, anchor, renderer);
|
|
3813
3703
|
}
|
|
3814
|
-
function patchComment(n1, n2) {
|
|
3704
|
+
function patchComment(n1, n2, renderer) {
|
|
3815
3705
|
n2.elm = n1.elm;
|
|
3816
3706
|
// FIXME: Comment nodes should be static, we shouldn't need to diff them together. However
|
|
3817
3707
|
// it is the case today.
|
|
3818
3708
|
if (n2.text !== n1.text) {
|
|
3819
|
-
updateTextContent(n2);
|
|
3709
|
+
updateTextContent(n2, renderer);
|
|
3820
3710
|
}
|
|
3821
3711
|
}
|
|
3822
|
-
function mountComment(
|
|
3823
|
-
const { owner } =
|
|
3824
|
-
const
|
|
3825
|
-
|
|
3826
|
-
|
|
3712
|
+
function mountComment(vnode, parent, anchor, renderer) {
|
|
3713
|
+
const { owner } = vnode;
|
|
3714
|
+
const { createComment } = renderer;
|
|
3715
|
+
const commentNode = (vnode.elm = createComment(vnode.text));
|
|
3716
|
+
linkNodeToShadow(commentNode, owner, renderer);
|
|
3717
|
+
insertNode(commentNode, parent, anchor, renderer);
|
|
3827
3718
|
}
|
|
3828
|
-
function mountElement(vnode, parent, anchor) {
|
|
3719
|
+
function mountElement(vnode, parent, anchor, renderer) {
|
|
3829
3720
|
const { sel, owner, data: { svg }, } = vnode;
|
|
3721
|
+
const { createElement } = renderer;
|
|
3830
3722
|
const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
|
|
3831
|
-
const elm = createElement
|
|
3832
|
-
linkNodeToShadow(elm, owner);
|
|
3833
|
-
fallbackElmHook(elm, vnode);
|
|
3723
|
+
const elm = createElement(sel, namespace);
|
|
3724
|
+
linkNodeToShadow(elm, owner, renderer);
|
|
3725
|
+
fallbackElmHook(elm, vnode, renderer);
|
|
3834
3726
|
vnode.elm = elm;
|
|
3835
|
-
patchElementPropsAndAttrs$1(null, vnode);
|
|
3836
|
-
insertNode(elm, parent, anchor);
|
|
3837
|
-
mountVNodes(vnode.children, elm, null);
|
|
3727
|
+
patchElementPropsAndAttrs$1(null, vnode, renderer);
|
|
3728
|
+
insertNode(elm, parent, anchor, renderer);
|
|
3729
|
+
mountVNodes(vnode.children, elm, renderer, null);
|
|
3838
3730
|
}
|
|
3839
|
-
function patchElement(n1, n2) {
|
|
3731
|
+
function patchElement(n1, n2, renderer) {
|
|
3840
3732
|
const elm = (n2.elm = n1.elm);
|
|
3841
|
-
patchElementPropsAndAttrs$1(n1, n2);
|
|
3842
|
-
patchChildren(n1.children, n2.children, elm);
|
|
3733
|
+
patchElementPropsAndAttrs$1(n1, n2, renderer);
|
|
3734
|
+
patchChildren(n1.children, n2.children, elm, renderer);
|
|
3843
3735
|
}
|
|
3844
|
-
function mountCustomElement(vnode, parent, anchor) {
|
|
3736
|
+
function mountCustomElement(vnode, parent, anchor, renderer) {
|
|
3845
3737
|
const { sel, owner } = vnode;
|
|
3846
|
-
const UpgradableConstructor = getUpgradableConstructor(sel);
|
|
3738
|
+
const UpgradableConstructor = getUpgradableConstructor(sel, renderer);
|
|
3847
3739
|
/**
|
|
3848
3740
|
* Note: if the upgradable constructor does not expect, or throw when we new it
|
|
3849
3741
|
* with a callback as the first argument, we could implement a more advanced
|
|
@@ -3853,9 +3745,9 @@ function mountCustomElement(vnode, parent, anchor) {
|
|
|
3853
3745
|
let vm;
|
|
3854
3746
|
const elm = new UpgradableConstructor((elm) => {
|
|
3855
3747
|
// the custom element from the registry is expecting an upgrade callback
|
|
3856
|
-
vm = createViewModelHook(elm, vnode);
|
|
3748
|
+
vm = createViewModelHook(elm, vnode, renderer);
|
|
3857
3749
|
});
|
|
3858
|
-
linkNodeToShadow(elm, owner);
|
|
3750
|
+
linkNodeToShadow(elm, owner, renderer);
|
|
3859
3751
|
vnode.elm = elm;
|
|
3860
3752
|
vnode.vm = vm;
|
|
3861
3753
|
if (vm) {
|
|
@@ -3864,23 +3756,23 @@ function mountCustomElement(vnode, parent, anchor) {
|
|
|
3864
3756
|
else if (vnode.ctor !== UpgradableConstructor) {
|
|
3865
3757
|
throw new TypeError(`Incorrect Component Constructor`);
|
|
3866
3758
|
}
|
|
3867
|
-
patchElementPropsAndAttrs$1(null, vnode);
|
|
3868
|
-
insertNode(elm, parent, anchor);
|
|
3759
|
+
patchElementPropsAndAttrs$1(null, vnode, renderer);
|
|
3760
|
+
insertNode(elm, parent, anchor, renderer);
|
|
3869
3761
|
if (vm) {
|
|
3870
3762
|
if (process.env.NODE_ENV !== 'production') {
|
|
3871
3763
|
assert.isTrue(vm.state === 0 /* created */, `${vm} cannot be recycled.`);
|
|
3872
3764
|
}
|
|
3873
3765
|
runConnectedCallback(vm);
|
|
3874
3766
|
}
|
|
3875
|
-
mountVNodes(vnode.children, elm, null);
|
|
3767
|
+
mountVNodes(vnode.children, elm, renderer, null);
|
|
3876
3768
|
if (vm) {
|
|
3877
3769
|
appendVM(vm);
|
|
3878
3770
|
}
|
|
3879
3771
|
}
|
|
3880
|
-
function patchCustomElement(n1, n2) {
|
|
3772
|
+
function patchCustomElement(n1, n2, renderer) {
|
|
3881
3773
|
const elm = (n2.elm = n1.elm);
|
|
3882
3774
|
const vm = (n2.vm = n1.vm);
|
|
3883
|
-
patchElementPropsAndAttrs$1(n1, n2);
|
|
3775
|
+
patchElementPropsAndAttrs$1(n1, n2, renderer);
|
|
3884
3776
|
if (!isUndefined$1(vm)) {
|
|
3885
3777
|
// in fallback mode, the allocation will always set children to
|
|
3886
3778
|
// empty and delegate the real allocation to the slot elements
|
|
@@ -3888,34 +3780,36 @@ function patchCustomElement(n1, n2) {
|
|
|
3888
3780
|
}
|
|
3889
3781
|
// in fallback mode, the children will be always empty, so, nothing
|
|
3890
3782
|
// will happen, but in native, it does allocate the light dom
|
|
3891
|
-
patchChildren(n1.children, n2.children, elm);
|
|
3783
|
+
patchChildren(n1.children, n2.children, elm, renderer);
|
|
3892
3784
|
if (!isUndefined$1(vm)) {
|
|
3893
3785
|
// this will probably update the shadowRoot, but only if the vm is in a dirty state
|
|
3894
3786
|
// this is important to preserve the top to bottom synchronous rendering phase.
|
|
3895
3787
|
rerenderVM(vm);
|
|
3896
3788
|
}
|
|
3897
3789
|
}
|
|
3898
|
-
function mountVNodes(vnodes, parent, anchor, start = 0, end = vnodes.length) {
|
|
3790
|
+
function mountVNodes(vnodes, parent, renderer, anchor, start = 0, end = vnodes.length) {
|
|
3899
3791
|
for (; start < end; ++start) {
|
|
3900
3792
|
const vnode = vnodes[start];
|
|
3901
3793
|
if (isVNode(vnode)) {
|
|
3902
|
-
mount(vnode, parent, anchor);
|
|
3794
|
+
mount(vnode, parent, renderer, anchor);
|
|
3903
3795
|
}
|
|
3904
3796
|
}
|
|
3905
3797
|
}
|
|
3906
|
-
function unmount(vnode, parent, doRemove = false) {
|
|
3798
|
+
function unmount(vnode, parent, renderer, doRemove = false) {
|
|
3907
3799
|
const { type, elm, sel } = vnode;
|
|
3908
3800
|
// When unmounting a VNode subtree not all the elements have to removed from the DOM. The
|
|
3909
3801
|
// subtree root, is the only element worth unmounting from the subtree.
|
|
3910
3802
|
if (doRemove) {
|
|
3911
|
-
|
|
3803
|
+
// The vnode might or might not have a data.renderer associated to it
|
|
3804
|
+
// but the removal used here is from the owner instead.
|
|
3805
|
+
removeNode(elm, parent, renderer);
|
|
3912
3806
|
}
|
|
3913
3807
|
switch (type) {
|
|
3914
3808
|
case 2 /* Element */: {
|
|
3915
3809
|
// Slot content is removed to trigger slotchange event when removing slot.
|
|
3916
3810
|
// Only required for synthetic shadow.
|
|
3917
|
-
const
|
|
3918
|
-
unmountVNodes(vnode.children, elm,
|
|
3811
|
+
const shouldRemoveChildren = sel === 'slot' && vnode.owner.shadowMode === 1 /* Synthetic */;
|
|
3812
|
+
unmountVNodes(vnode.children, elm, renderer, shouldRemoveChildren);
|
|
3919
3813
|
break;
|
|
3920
3814
|
}
|
|
3921
3815
|
case 3 /* CustomElement */: {
|
|
@@ -3928,11 +3822,11 @@ function unmount(vnode, parent, doRemove = false) {
|
|
|
3928
3822
|
}
|
|
3929
3823
|
}
|
|
3930
3824
|
}
|
|
3931
|
-
function unmountVNodes(vnodes, parent, doRemove = false, start = 0, end = vnodes.length) {
|
|
3825
|
+
function unmountVNodes(vnodes, parent, renderer, doRemove = false, start = 0, end = vnodes.length) {
|
|
3932
3826
|
for (; start < end; ++start) {
|
|
3933
3827
|
const ch = vnodes[start];
|
|
3934
3828
|
if (isVNode(ch)) {
|
|
3935
|
-
unmount(ch, parent, doRemove);
|
|
3829
|
+
unmount(ch, parent, renderer, doRemove);
|
|
3936
3830
|
}
|
|
3937
3831
|
}
|
|
3938
3832
|
}
|
|
@@ -3946,66 +3840,71 @@ function setElementShadowToken(elm, token) {
|
|
|
3946
3840
|
elm.$shadowToken$ = token;
|
|
3947
3841
|
}
|
|
3948
3842
|
// Set the scope token class for *.scoped.css styles
|
|
3949
|
-
function setScopeTokenClassIfNecessary(elm, owner) {
|
|
3843
|
+
function setScopeTokenClassIfNecessary(elm, owner, renderer) {
|
|
3950
3844
|
const { cmpTemplate, context } = owner;
|
|
3845
|
+
const { getClassList } = renderer;
|
|
3951
3846
|
const token = cmpTemplate === null || cmpTemplate === void 0 ? void 0 : cmpTemplate.stylesheetToken;
|
|
3952
3847
|
if (!isUndefined$1(token) && context.hasScopedStyles) {
|
|
3953
|
-
|
|
3848
|
+
// TODO [#2762]: this dot notation with add is probably problematic
|
|
3849
|
+
// probably we should have a renderer api for just the add operation
|
|
3850
|
+
getClassList(elm).add(token);
|
|
3954
3851
|
}
|
|
3955
3852
|
}
|
|
3956
|
-
function linkNodeToShadow(elm, owner) {
|
|
3853
|
+
function linkNodeToShadow(elm, owner, renderer) {
|
|
3957
3854
|
const { renderRoot, renderMode, shadowMode } = owner;
|
|
3855
|
+
const { isSyntheticShadowDefined } = renderer;
|
|
3958
3856
|
// TODO [#1164]: this should eventually be done by the polyfill directly
|
|
3959
|
-
if (isSyntheticShadowDefined
|
|
3857
|
+
if (isSyntheticShadowDefined) {
|
|
3960
3858
|
if (shadowMode === 1 /* Synthetic */ || renderMode === 0 /* Light */) {
|
|
3961
3859
|
elm[KEY__SHADOW_RESOLVER] = renderRoot[KEY__SHADOW_RESOLVER];
|
|
3962
3860
|
}
|
|
3963
3861
|
}
|
|
3964
3862
|
}
|
|
3965
|
-
function updateTextContent(vnode) {
|
|
3863
|
+
function updateTextContent(vnode, renderer) {
|
|
3966
3864
|
const { elm, text } = vnode;
|
|
3865
|
+
const { setText } = renderer;
|
|
3967
3866
|
if (process.env.NODE_ENV !== 'production') {
|
|
3968
3867
|
unlockDomMutation();
|
|
3969
3868
|
}
|
|
3970
|
-
setText
|
|
3869
|
+
setText(elm, text);
|
|
3971
3870
|
if (process.env.NODE_ENV !== 'production') {
|
|
3972
3871
|
lockDomMutation();
|
|
3973
3872
|
}
|
|
3974
3873
|
}
|
|
3975
|
-
function insertNode(node, parent, anchor) {
|
|
3874
|
+
function insertNode(node, parent, anchor, renderer) {
|
|
3976
3875
|
if (process.env.NODE_ENV !== 'production') {
|
|
3977
3876
|
unlockDomMutation();
|
|
3978
3877
|
}
|
|
3979
|
-
insert
|
|
3878
|
+
renderer.insert(node, parent, anchor);
|
|
3980
3879
|
if (process.env.NODE_ENV !== 'production') {
|
|
3981
3880
|
lockDomMutation();
|
|
3982
3881
|
}
|
|
3983
3882
|
}
|
|
3984
|
-
function removeNode(node, parent) {
|
|
3883
|
+
function removeNode(node, parent, renderer) {
|
|
3985
3884
|
if (process.env.NODE_ENV !== 'production') {
|
|
3986
3885
|
unlockDomMutation();
|
|
3987
3886
|
}
|
|
3988
|
-
remove
|
|
3887
|
+
renderer.remove(node, parent);
|
|
3989
3888
|
if (process.env.NODE_ENV !== 'production') {
|
|
3990
3889
|
lockDomMutation();
|
|
3991
3890
|
}
|
|
3992
3891
|
}
|
|
3993
|
-
function patchElementPropsAndAttrs$1(oldVnode, vnode) {
|
|
3892
|
+
function patchElementPropsAndAttrs$1(oldVnode, vnode, renderer) {
|
|
3994
3893
|
if (isNull(oldVnode)) {
|
|
3995
|
-
applyEventListeners(vnode);
|
|
3996
|
-
applyStaticClassAttribute(vnode);
|
|
3997
|
-
applyStaticStyleAttribute(vnode);
|
|
3894
|
+
applyEventListeners(vnode, renderer);
|
|
3895
|
+
applyStaticClassAttribute(vnode, renderer);
|
|
3896
|
+
applyStaticStyleAttribute(vnode, renderer);
|
|
3998
3897
|
}
|
|
3999
3898
|
// Attrs need to be applied to element before props IE11 will wipe out value on radio inputs if
|
|
4000
3899
|
// value is set before type=radio.
|
|
4001
|
-
patchClassAttribute(oldVnode, vnode);
|
|
4002
|
-
patchStyleAttribute(oldVnode, vnode);
|
|
4003
|
-
patchAttributes(oldVnode, vnode);
|
|
4004
|
-
patchProps(oldVnode, vnode);
|
|
3900
|
+
patchClassAttribute(oldVnode, vnode, renderer);
|
|
3901
|
+
patchStyleAttribute(oldVnode, vnode, renderer);
|
|
3902
|
+
patchAttributes(oldVnode, vnode, renderer);
|
|
3903
|
+
patchProps(oldVnode, vnode, renderer);
|
|
4005
3904
|
}
|
|
4006
|
-
function fallbackElmHook(elm, vnode) {
|
|
3905
|
+
function fallbackElmHook(elm, vnode, renderer) {
|
|
4007
3906
|
const { owner } = vnode;
|
|
4008
|
-
setScopeTokenClassIfNecessary(elm, owner);
|
|
3907
|
+
setScopeTokenClassIfNecessary(elm, owner, renderer);
|
|
4009
3908
|
if (owner.shadowMode === 1 /* Synthetic */) {
|
|
4010
3909
|
const { data: { context }, } = vnode;
|
|
4011
3910
|
const { stylesheetToken } = owner.context;
|
|
@@ -4053,7 +3952,7 @@ function allocateChildren(vnode, vm) {
|
|
|
4053
3952
|
vnode.children = EmptyArray;
|
|
4054
3953
|
}
|
|
4055
3954
|
}
|
|
4056
|
-
function createViewModelHook(elm, vnode) {
|
|
3955
|
+
function createViewModelHook(elm, vnode, renderer) {
|
|
4057
3956
|
let vm = getAssociatedVMIfPresent(elm);
|
|
4058
3957
|
// There is a possibility that a custom element is registered under tagName, in which case, the
|
|
4059
3958
|
// initialization is already carry on, and there is nothing else to do here since this hook is
|
|
@@ -4062,7 +3961,7 @@ function createViewModelHook(elm, vnode) {
|
|
|
4062
3961
|
return vm;
|
|
4063
3962
|
}
|
|
4064
3963
|
const { sel, mode, ctor, owner } = vnode;
|
|
4065
|
-
setScopeTokenClassIfNecessary(elm, owner);
|
|
3964
|
+
setScopeTokenClassIfNecessary(elm, owner, renderer);
|
|
4066
3965
|
if (owner.shadowMode === 1 /* Synthetic */) {
|
|
4067
3966
|
const { stylesheetToken } = owner.context;
|
|
4068
3967
|
// when running in synthetic shadow mode, we need to set the shadowToken value
|
|
@@ -4071,7 +3970,7 @@ function createViewModelHook(elm, vnode) {
|
|
|
4071
3970
|
setElementShadowToken(elm, stylesheetToken);
|
|
4072
3971
|
}
|
|
4073
3972
|
}
|
|
4074
|
-
vm = createVM(elm, ctor, {
|
|
3973
|
+
vm = createVM(elm, ctor, renderer, {
|
|
4075
3974
|
mode,
|
|
4076
3975
|
owner,
|
|
4077
3976
|
tagName: sel,
|
|
@@ -4146,7 +4045,7 @@ function createKeyToOldIdx(children, beginIdx, endIdx) {
|
|
|
4146
4045
|
}
|
|
4147
4046
|
return map;
|
|
4148
4047
|
}
|
|
4149
|
-
function updateDynamicChildren(oldCh, newCh, parent) {
|
|
4048
|
+
function updateDynamicChildren(oldCh, newCh, parent, renderer) {
|
|
4150
4049
|
let oldStartIdx = 0;
|
|
4151
4050
|
let newStartIdx = 0;
|
|
4152
4051
|
let oldEndIdx = oldCh.length - 1;
|
|
@@ -4175,26 +4074,26 @@ function updateDynamicChildren(oldCh, newCh, parent) {
|
|
|
4175
4074
|
newEndVnode = newCh[--newEndIdx];
|
|
4176
4075
|
}
|
|
4177
4076
|
else if (isSameVnode(oldStartVnode, newStartVnode)) {
|
|
4178
|
-
patch(oldStartVnode, newStartVnode);
|
|
4077
|
+
patch(oldStartVnode, newStartVnode, renderer);
|
|
4179
4078
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
4180
4079
|
newStartVnode = newCh[++newStartIdx];
|
|
4181
4080
|
}
|
|
4182
4081
|
else if (isSameVnode(oldEndVnode, newEndVnode)) {
|
|
4183
|
-
patch(oldEndVnode, newEndVnode);
|
|
4082
|
+
patch(oldEndVnode, newEndVnode, renderer);
|
|
4184
4083
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
4185
4084
|
newEndVnode = newCh[--newEndIdx];
|
|
4186
4085
|
}
|
|
4187
4086
|
else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
4188
4087
|
// Vnode moved right
|
|
4189
|
-
patch(oldStartVnode, newEndVnode);
|
|
4190
|
-
insertNode(oldStartVnode.elm, parent, nextSibling
|
|
4088
|
+
patch(oldStartVnode, newEndVnode, renderer);
|
|
4089
|
+
insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
|
|
4191
4090
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
4192
4091
|
newEndVnode = newCh[--newEndIdx];
|
|
4193
4092
|
}
|
|
4194
4093
|
else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
4195
4094
|
// Vnode moved left
|
|
4196
|
-
patch(oldEndVnode, newStartVnode);
|
|
4197
|
-
insertNode(newStartVnode.elm, parent, oldStartVnode.elm);
|
|
4095
|
+
patch(oldEndVnode, newStartVnode, renderer);
|
|
4096
|
+
insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
|
|
4198
4097
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
4199
4098
|
newStartVnode = newCh[++newStartIdx];
|
|
4200
4099
|
}
|
|
@@ -4205,7 +4104,7 @@ function updateDynamicChildren(oldCh, newCh, parent) {
|
|
|
4205
4104
|
idxInOld = oldKeyToIdx[newStartVnode.key];
|
|
4206
4105
|
if (isUndefined$1(idxInOld)) {
|
|
4207
4106
|
// New element
|
|
4208
|
-
mount(newStartVnode, parent, oldStartVnode.elm);
|
|
4107
|
+
mount(newStartVnode, parent, renderer, oldStartVnode.elm);
|
|
4209
4108
|
newStartVnode = newCh[++newStartIdx];
|
|
4210
4109
|
}
|
|
4211
4110
|
else {
|
|
@@ -4213,10 +4112,10 @@ function updateDynamicChildren(oldCh, newCh, parent) {
|
|
|
4213
4112
|
if (isVNode(elmToMove)) {
|
|
4214
4113
|
if (elmToMove.sel !== newStartVnode.sel) {
|
|
4215
4114
|
// New element
|
|
4216
|
-
mount(newStartVnode, parent, oldStartVnode.elm);
|
|
4115
|
+
mount(newStartVnode, parent, renderer, oldStartVnode.elm);
|
|
4217
4116
|
}
|
|
4218
4117
|
else {
|
|
4219
|
-
patch(elmToMove, newStartVnode);
|
|
4118
|
+
patch(elmToMove, newStartVnode, renderer);
|
|
4220
4119
|
// Delete the old child, but copy the array since it is read-only.
|
|
4221
4120
|
// The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
|
|
4222
4121
|
// so we only care about the `oldCh` object inside this function.
|
|
@@ -4228,7 +4127,7 @@ function updateDynamicChildren(oldCh, newCh, parent) {
|
|
|
4228
4127
|
}
|
|
4229
4128
|
// We've already cloned at least once, so it's no longer read-only
|
|
4230
4129
|
oldCh[idxInOld] = undefined;
|
|
4231
|
-
insertNode(elmToMove.elm, parent, oldStartVnode.elm);
|
|
4130
|
+
insertNode(elmToMove.elm, parent, oldStartVnode.elm, renderer);
|
|
4232
4131
|
}
|
|
4233
4132
|
}
|
|
4234
4133
|
newStartVnode = newCh[++newStartIdx];
|
|
@@ -4245,25 +4144,25 @@ function updateDynamicChildren(oldCh, newCh, parent) {
|
|
|
4245
4144
|
n = newCh[++i];
|
|
4246
4145
|
} while (!isVNode(n) && i < newChEnd);
|
|
4247
4146
|
before = isVNode(n) ? n.elm : null;
|
|
4248
|
-
mountVNodes(newCh, parent, before, newStartIdx, newEndIdx + 1);
|
|
4147
|
+
mountVNodes(newCh, parent, renderer, before, newStartIdx, newEndIdx + 1);
|
|
4249
4148
|
}
|
|
4250
4149
|
else {
|
|
4251
|
-
unmountVNodes(oldCh, parent, true, oldStartIdx, oldEndIdx + 1);
|
|
4150
|
+
unmountVNodes(oldCh, parent, renderer, true, oldStartIdx, oldEndIdx + 1);
|
|
4252
4151
|
}
|
|
4253
4152
|
}
|
|
4254
4153
|
}
|
|
4255
|
-
function updateStaticChildren(c1, c2, parent) {
|
|
4154
|
+
function updateStaticChildren(c1, c2, parent, renderer) {
|
|
4256
4155
|
const c1Length = c1.length;
|
|
4257
4156
|
const c2Length = c2.length;
|
|
4258
4157
|
if (c1Length === 0) {
|
|
4259
4158
|
// the old list is empty, we can directly insert anything new
|
|
4260
|
-
mountVNodes(c2, parent, null);
|
|
4159
|
+
mountVNodes(c2, parent, renderer, null);
|
|
4261
4160
|
return;
|
|
4262
4161
|
}
|
|
4263
4162
|
if (c2Length === 0) {
|
|
4264
4163
|
// the old list is nonempty and the new list is empty so we can directly remove all old nodes
|
|
4265
4164
|
// this is the case in which the dynamic children of an if-directive should be removed
|
|
4266
|
-
unmountVNodes(c1, parent, true);
|
|
4165
|
+
unmountVNodes(c1, parent, renderer, true);
|
|
4267
4166
|
return;
|
|
4268
4167
|
}
|
|
4269
4168
|
// if the old list is not empty, the new list MUST have the same
|
|
@@ -4276,16 +4175,16 @@ function updateStaticChildren(c1, c2, parent) {
|
|
|
4276
4175
|
if (isVNode(n1)) {
|
|
4277
4176
|
if (isVNode(n2)) {
|
|
4278
4177
|
// both vnodes are equivalent, and we just need to patch them
|
|
4279
|
-
patch(n1, n2);
|
|
4178
|
+
patch(n1, n2, renderer);
|
|
4280
4179
|
anchor = n2.elm;
|
|
4281
4180
|
}
|
|
4282
4181
|
else {
|
|
4283
4182
|
// removing the old vnode since the new one is null
|
|
4284
|
-
unmount(n1, parent, true);
|
|
4183
|
+
unmount(n1, parent, renderer, true);
|
|
4285
4184
|
}
|
|
4286
4185
|
}
|
|
4287
4186
|
else if (isVNode(n2)) {
|
|
4288
|
-
mount(n2, parent, anchor);
|
|
4187
|
+
mount(n2, parent, renderer, anchor);
|
|
4289
4188
|
anchor = n2.elm;
|
|
4290
4189
|
}
|
|
4291
4190
|
}
|
|
@@ -4714,7 +4613,7 @@ function createInlineStyleVNode(content) {
|
|
|
4714
4613
|
}, [api.t(content)]);
|
|
4715
4614
|
}
|
|
4716
4615
|
function updateStylesheetToken(vm, template) {
|
|
4717
|
-
const { elm, context, renderMode, shadowMode } = vm;
|
|
4616
|
+
const { elm, context, renderMode, shadowMode, renderer: { getClassList, removeAttribute, setAttribute }, } = vm;
|
|
4718
4617
|
const { stylesheets: newStylesheets, stylesheetToken: newStylesheetToken } = template;
|
|
4719
4618
|
const isSyntheticShadow = renderMode === 1 /* Shadow */ && shadowMode === 1 /* Synthetic */;
|
|
4720
4619
|
const { hasScopedStyles } = context;
|
|
@@ -4725,10 +4624,10 @@ function updateStylesheetToken(vm, template) {
|
|
|
4725
4624
|
const { stylesheetToken: oldToken, hasTokenInClass: oldHasTokenInClass, hasTokenInAttribute: oldHasTokenInAttribute, } = context;
|
|
4726
4625
|
if (!isUndefined$1(oldToken)) {
|
|
4727
4626
|
if (oldHasTokenInClass) {
|
|
4728
|
-
getClassList
|
|
4627
|
+
getClassList(elm).remove(makeHostToken(oldToken));
|
|
4729
4628
|
}
|
|
4730
4629
|
if (oldHasTokenInAttribute) {
|
|
4731
|
-
removeAttribute
|
|
4630
|
+
removeAttribute(elm, makeHostToken(oldToken));
|
|
4732
4631
|
}
|
|
4733
4632
|
}
|
|
4734
4633
|
// Apply the new template styling token to the host element, if the new template has any
|
|
@@ -4739,11 +4638,11 @@ function updateStylesheetToken(vm, template) {
|
|
|
4739
4638
|
// Set the new styling token on the host element
|
|
4740
4639
|
if (!isUndefined$1(newToken)) {
|
|
4741
4640
|
if (hasScopedStyles) {
|
|
4742
|
-
getClassList
|
|
4641
|
+
getClassList(elm).add(makeHostToken(newToken));
|
|
4743
4642
|
newHasTokenInClass = true;
|
|
4744
4643
|
}
|
|
4745
4644
|
if (isSyntheticShadow) {
|
|
4746
|
-
setAttribute
|
|
4645
|
+
setAttribute(elm, makeHostToken(newToken), '');
|
|
4747
4646
|
newHasTokenInAttribute = true;
|
|
4748
4647
|
}
|
|
4749
4648
|
}
|
|
@@ -4831,13 +4730,13 @@ function getNearestNativeShadowComponent(vm) {
|
|
|
4831
4730
|
return owner;
|
|
4832
4731
|
}
|
|
4833
4732
|
function createStylesheet(vm, stylesheets) {
|
|
4834
|
-
const { renderMode, shadowMode } = vm;
|
|
4733
|
+
const { renderMode, shadowMode, renderer: { ssr, insertStylesheet }, } = vm;
|
|
4835
4734
|
if (renderMode === 1 /* Shadow */ && shadowMode === 1 /* Synthetic */) {
|
|
4836
4735
|
for (let i = 0; i < stylesheets.length; i++) {
|
|
4837
|
-
insertStylesheet
|
|
4736
|
+
insertStylesheet(stylesheets[i]);
|
|
4838
4737
|
}
|
|
4839
4738
|
}
|
|
4840
|
-
else if (ssr
|
|
4739
|
+
else if (ssr || vm.hydrated) {
|
|
4841
4740
|
// Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
|
|
4842
4741
|
// This works in the client, because the stylesheets are created, and cached in the VM
|
|
4843
4742
|
// the first time the VM renders.
|
|
@@ -4851,7 +4750,7 @@ function createStylesheet(vm, stylesheets) {
|
|
|
4851
4750
|
// null root means a global style
|
|
4852
4751
|
const target = isNull(root) ? undefined : root.shadowRoot;
|
|
4853
4752
|
for (let i = 0; i < stylesheets.length; i++) {
|
|
4854
|
-
insertStylesheet
|
|
4753
|
+
insertStylesheet(stylesheets[i], target);
|
|
4855
4754
|
}
|
|
4856
4755
|
}
|
|
4857
4756
|
return null;
|
|
@@ -5406,7 +5305,7 @@ function getNearestShadowAncestor(vm) {
|
|
|
5406
5305
|
return ancestor;
|
|
5407
5306
|
}
|
|
5408
5307
|
|
|
5409
|
-
function createVM(elm, ctor, options) {
|
|
5308
|
+
function createVM(elm, ctor, renderer, options) {
|
|
5410
5309
|
const {
|
|
5411
5310
|
mode,
|
|
5412
5311
|
owner,
|
|
@@ -5455,9 +5354,10 @@ function createVM(elm, ctor, options) {
|
|
|
5455
5354
|
renderRoot: null,
|
|
5456
5355
|
callHook,
|
|
5457
5356
|
setHook,
|
|
5458
|
-
getHook
|
|
5357
|
+
getHook,
|
|
5358
|
+
renderer
|
|
5459
5359
|
};
|
|
5460
|
-
vm.shadowMode = computeShadowMode(vm);
|
|
5360
|
+
vm.shadowMode = computeShadowMode(vm, renderer);
|
|
5461
5361
|
vm.tro = getTemplateReactiveObserver(vm);
|
|
5462
5362
|
|
|
5463
5363
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -5482,13 +5382,17 @@ function createVM(elm, ctor, options) {
|
|
|
5482
5382
|
return vm;
|
|
5483
5383
|
}
|
|
5484
5384
|
|
|
5485
|
-
function computeShadowMode(vm) {
|
|
5385
|
+
function computeShadowMode(vm, renderer) {
|
|
5486
5386
|
const {
|
|
5487
5387
|
def
|
|
5488
5388
|
} = vm;
|
|
5389
|
+
const {
|
|
5390
|
+
isSyntheticShadowDefined,
|
|
5391
|
+
isNativeShadowDefined
|
|
5392
|
+
} = renderer;
|
|
5489
5393
|
let shadowMode;
|
|
5490
5394
|
|
|
5491
|
-
if (isSyntheticShadowDefined
|
|
5395
|
+
if (isSyntheticShadowDefined) {
|
|
5492
5396
|
if (def.renderMode === 0
|
|
5493
5397
|
/* Light */
|
|
5494
5398
|
) {
|
|
@@ -5497,7 +5401,7 @@ function computeShadowMode(vm) {
|
|
|
5497
5401
|
shadowMode = 0
|
|
5498
5402
|
/* Native */
|
|
5499
5403
|
;
|
|
5500
|
-
} else if (isNativeShadowDefined
|
|
5404
|
+
} else if (isNativeShadowDefined) {
|
|
5501
5405
|
// Not combined with above condition because @lwc/features only supports identifiers in
|
|
5502
5406
|
// the if-condition.
|
|
5503
5407
|
if (runtimeFlags.ENABLE_MIXED_SHADOW_MODE) {
|
|
@@ -5587,7 +5491,8 @@ function rehydrate(vm) {
|
|
|
5587
5491
|
function patchShadowRoot(vm, newCh) {
|
|
5588
5492
|
const {
|
|
5589
5493
|
renderRoot,
|
|
5590
|
-
children: oldCh
|
|
5494
|
+
children: oldCh,
|
|
5495
|
+
renderer
|
|
5591
5496
|
} = vm; // caching the new children collection
|
|
5592
5497
|
|
|
5593
5498
|
vm.children = newCh;
|
|
@@ -5603,7 +5508,7 @@ function patchShadowRoot(vm, newCh) {
|
|
|
5603
5508
|
, vm);
|
|
5604
5509
|
}, () => {
|
|
5605
5510
|
// job
|
|
5606
|
-
patchChildren(oldCh, newCh, renderRoot);
|
|
5511
|
+
patchChildren(oldCh, newCh, renderRoot, renderer);
|
|
5607
5512
|
}, () => {
|
|
5608
5513
|
// post
|
|
5609
5514
|
logOperationEnd(2
|
|
@@ -5628,10 +5533,13 @@ function runRenderedCallback(vm) {
|
|
|
5628
5533
|
const {
|
|
5629
5534
|
def: {
|
|
5630
5535
|
renderedCallback
|
|
5536
|
+
},
|
|
5537
|
+
renderer: {
|
|
5538
|
+
ssr
|
|
5631
5539
|
}
|
|
5632
5540
|
} = vm;
|
|
5633
5541
|
|
|
5634
|
-
if (isTrue(ssr
|
|
5542
|
+
if (isTrue(ssr)) {
|
|
5635
5543
|
return;
|
|
5636
5544
|
}
|
|
5637
5545
|
|
|
@@ -5865,14 +5773,17 @@ function recursivelyDisconnectChildren(vnodes) {
|
|
|
5865
5773
|
function resetComponentRoot(vm) {
|
|
5866
5774
|
const {
|
|
5867
5775
|
children,
|
|
5868
|
-
renderRoot
|
|
5776
|
+
renderRoot,
|
|
5777
|
+
renderer: {
|
|
5778
|
+
remove
|
|
5779
|
+
}
|
|
5869
5780
|
} = vm;
|
|
5870
5781
|
|
|
5871
5782
|
for (let i = 0, len = children.length; i < len; i++) {
|
|
5872
5783
|
const child = children[i];
|
|
5873
5784
|
|
|
5874
5785
|
if (!isNull(child) && !isUndefined$1(child.elm)) {
|
|
5875
|
-
remove
|
|
5786
|
+
remove(child.elm, renderRoot);
|
|
5876
5787
|
}
|
|
5877
5788
|
}
|
|
5878
5789
|
|
|
@@ -5881,7 +5792,13 @@ function resetComponentRoot(vm) {
|
|
|
5881
5792
|
vm.velements = EmptyArray;
|
|
5882
5793
|
}
|
|
5883
5794
|
function scheduleRehydration(vm) {
|
|
5884
|
-
|
|
5795
|
+
const {
|
|
5796
|
+
renderer: {
|
|
5797
|
+
ssr
|
|
5798
|
+
}
|
|
5799
|
+
} = vm;
|
|
5800
|
+
|
|
5801
|
+
if (isTrue(ssr) || isTrue(vm.isScheduled)) {
|
|
5885
5802
|
return;
|
|
5886
5803
|
}
|
|
5887
5804
|
|
|
@@ -6057,6 +5974,9 @@ function createContextWatcher(vm, wireDef, callbackWhenContextIsReady) {
|
|
|
6057
5974
|
context: {
|
|
6058
5975
|
wiredConnecting,
|
|
6059
5976
|
wiredDisconnecting
|
|
5977
|
+
},
|
|
5978
|
+
renderer: {
|
|
5979
|
+
dispatchEvent
|
|
6060
5980
|
}
|
|
6061
5981
|
} = vm; // waiting for the component to be connected to formally request the context via the token
|
|
6062
5982
|
|
|
@@ -6080,7 +6000,7 @@ function createContextWatcher(vm, wireDef, callbackWhenContextIsReady) {
|
|
|
6080
6000
|
}
|
|
6081
6001
|
|
|
6082
6002
|
});
|
|
6083
|
-
dispatchEvent
|
|
6003
|
+
dispatchEvent(elm, contextRegistrationEvent);
|
|
6084
6004
|
});
|
|
6085
6005
|
}
|
|
6086
6006
|
|
|
@@ -6328,95 +6248,105 @@ function hydrateRoot(vm) {
|
|
|
6328
6248
|
function hydrateVM(vm) {
|
|
6329
6249
|
const children = renderComponent(vm);
|
|
6330
6250
|
vm.children = children;
|
|
6331
|
-
const parentNode = vm
|
|
6332
|
-
hydrateChildren(getFirstChild
|
|
6251
|
+
const { renderRoot: parentNode, renderer: { getFirstChild }, } = vm;
|
|
6252
|
+
hydrateChildren(getFirstChild(parentNode), children, parentNode, vm);
|
|
6333
6253
|
runRenderedCallback(vm);
|
|
6334
6254
|
}
|
|
6335
|
-
function hydrateNode(node, vnode) {
|
|
6255
|
+
function hydrateNode(node, vnode, renderer) {
|
|
6256
|
+
var _a, _b;
|
|
6336
6257
|
let hydratedNode;
|
|
6337
6258
|
switch (vnode.type) {
|
|
6338
6259
|
case 0 /* Text */:
|
|
6339
|
-
|
|
6260
|
+
// VText has no special capability, fallback to the owner's renderer
|
|
6261
|
+
hydratedNode = hydrateText(node, vnode, renderer);
|
|
6340
6262
|
break;
|
|
6341
6263
|
case 1 /* Comment */:
|
|
6342
|
-
|
|
6264
|
+
// VComment has no special capability, fallback to the owner's renderer
|
|
6265
|
+
hydratedNode = hydrateComment(node, vnode, renderer);
|
|
6343
6266
|
break;
|
|
6344
6267
|
case 2 /* Element */:
|
|
6345
|
-
hydratedNode = hydrateElement(node, vnode);
|
|
6268
|
+
hydratedNode = hydrateElement(node, vnode, (_a = vnode.data.renderer) !== null && _a !== void 0 ? _a : renderer);
|
|
6346
6269
|
break;
|
|
6347
6270
|
case 3 /* CustomElement */:
|
|
6348
|
-
hydratedNode = hydrateCustomElement(node, vnode);
|
|
6271
|
+
hydratedNode = hydrateCustomElement(node, vnode, (_b = vnode.data.renderer) !== null && _b !== void 0 ? _b : renderer);
|
|
6349
6272
|
break;
|
|
6350
6273
|
}
|
|
6351
|
-
return nextSibling
|
|
6274
|
+
return renderer.nextSibling(hydratedNode);
|
|
6352
6275
|
}
|
|
6353
|
-
function hydrateText(node, vnode) {
|
|
6276
|
+
function hydrateText(node, vnode, renderer) {
|
|
6354
6277
|
var _a;
|
|
6355
|
-
if (!hasCorrectNodeType(vnode, node, 3 /* TEXT
|
|
6356
|
-
return handleMismatch(node, vnode);
|
|
6278
|
+
if (!hasCorrectNodeType(vnode, node, 3 /* TEXT */, renderer)) {
|
|
6279
|
+
return handleMismatch(node, vnode, renderer);
|
|
6357
6280
|
}
|
|
6358
6281
|
if (process.env.NODE_ENV !== 'production') {
|
|
6359
|
-
const
|
|
6282
|
+
const { getProperty } = renderer;
|
|
6283
|
+
const nodeValue = getProperty(node, 'nodeValue');
|
|
6360
6284
|
if (nodeValue !== vnode.text && !(nodeValue === '\u200D' && vnode.text === '')) {
|
|
6361
6285
|
logWarn('Hydration mismatch: text values do not match, will recover from the difference', vnode.owner);
|
|
6362
6286
|
}
|
|
6363
6287
|
}
|
|
6364
|
-
setText
|
|
6288
|
+
const { setText } = renderer;
|
|
6289
|
+
setText(node, (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
|
|
6365
6290
|
vnode.elm = node;
|
|
6366
6291
|
return node;
|
|
6367
6292
|
}
|
|
6368
|
-
function hydrateComment(node, vnode) {
|
|
6293
|
+
function hydrateComment(node, vnode, renderer) {
|
|
6369
6294
|
var _a;
|
|
6370
|
-
if (!hasCorrectNodeType(vnode, node, 8 /* COMMENT
|
|
6371
|
-
return handleMismatch(node, vnode);
|
|
6295
|
+
if (!hasCorrectNodeType(vnode, node, 8 /* COMMENT */, renderer)) {
|
|
6296
|
+
return handleMismatch(node, vnode, renderer);
|
|
6372
6297
|
}
|
|
6373
6298
|
if (process.env.NODE_ENV !== 'production') {
|
|
6374
|
-
const
|
|
6299
|
+
const { getProperty } = renderer;
|
|
6300
|
+
const nodeValue = getProperty(node, 'nodeValue');
|
|
6375
6301
|
if (nodeValue !== vnode.text) {
|
|
6376
6302
|
logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vnode.owner);
|
|
6377
6303
|
}
|
|
6378
6304
|
}
|
|
6379
|
-
setProperty
|
|
6305
|
+
const { setProperty } = renderer;
|
|
6306
|
+
setProperty(node, 'nodeValue', (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
|
|
6380
6307
|
vnode.elm = node;
|
|
6381
6308
|
return node;
|
|
6382
6309
|
}
|
|
6383
|
-
function hydrateElement(elm, vnode) {
|
|
6384
|
-
if (!hasCorrectNodeType(vnode, elm, 1 /* ELEMENT
|
|
6385
|
-
!isMatchingElement(vnode, elm)) {
|
|
6386
|
-
return handleMismatch(elm, vnode);
|
|
6310
|
+
function hydrateElement(elm, vnode, renderer) {
|
|
6311
|
+
if (!hasCorrectNodeType(vnode, elm, 1 /* ELEMENT */, renderer) ||
|
|
6312
|
+
!isMatchingElement(vnode, elm, renderer)) {
|
|
6313
|
+
return handleMismatch(elm, vnode, renderer);
|
|
6387
6314
|
}
|
|
6388
6315
|
vnode.elm = elm;
|
|
6316
|
+
const { owner } = vnode;
|
|
6389
6317
|
const { context } = vnode.data;
|
|
6390
6318
|
const isDomManual = Boolean(!isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === "manual" /* Manual */);
|
|
6391
6319
|
if (isDomManual) {
|
|
6392
6320
|
// it may be that this element has lwc:inner-html, we need to diff and in case are the same,
|
|
6393
6321
|
// remove the innerHTML from props so it reuses the existing dom elements.
|
|
6394
|
-
const { props } = vnode
|
|
6322
|
+
const { data: { props }, } = vnode;
|
|
6323
|
+
const { getProperty } = renderer;
|
|
6395
6324
|
if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
|
|
6396
|
-
if (getProperty
|
|
6325
|
+
if (getProperty(elm, 'innerHTML') === props.innerHTML) {
|
|
6397
6326
|
// Do a shallow clone since VNodeData may be shared across VNodes due to hoist optimization
|
|
6398
6327
|
vnode.data = Object.assign(Object.assign({}, vnode.data), { props: cloneAndOmitKey(props, 'innerHTML') });
|
|
6399
6328
|
}
|
|
6400
6329
|
else {
|
|
6401
6330
|
if (process.env.NODE_ENV !== 'production') {
|
|
6402
|
-
logWarn(`Mismatch hydrating element <${getProperty
|
|
6331
|
+
logWarn(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: innerHTML values do not match for element, will recover from the difference`, owner);
|
|
6403
6332
|
}
|
|
6404
6333
|
}
|
|
6405
6334
|
}
|
|
6406
6335
|
}
|
|
6407
|
-
patchElementPropsAndAttrs(vnode);
|
|
6336
|
+
patchElementPropsAndAttrs(vnode, renderer);
|
|
6408
6337
|
if (!isDomManual) {
|
|
6409
|
-
|
|
6338
|
+
const { getFirstChild } = renderer;
|
|
6339
|
+
hydrateChildren(getFirstChild(elm), vnode.children, elm, owner);
|
|
6410
6340
|
}
|
|
6411
6341
|
return elm;
|
|
6412
6342
|
}
|
|
6413
|
-
function hydrateCustomElement(elm, vnode) {
|
|
6414
|
-
if (!hasCorrectNodeType(vnode, elm, 1 /* ELEMENT
|
|
6415
|
-
!isMatchingElement(vnode, elm)) {
|
|
6416
|
-
return handleMismatch(elm, vnode);
|
|
6343
|
+
function hydrateCustomElement(elm, vnode, renderer) {
|
|
6344
|
+
if (!hasCorrectNodeType(vnode, elm, 1 /* ELEMENT */, renderer) ||
|
|
6345
|
+
!isMatchingElement(vnode, elm, renderer)) {
|
|
6346
|
+
return handleMismatch(elm, vnode, renderer);
|
|
6417
6347
|
}
|
|
6418
6348
|
const { sel, mode, ctor, owner } = vnode;
|
|
6419
|
-
const vm = createVM(elm, ctor, {
|
|
6349
|
+
const vm = createVM(elm, ctor, renderer, {
|
|
6420
6350
|
mode,
|
|
6421
6351
|
owner,
|
|
6422
6352
|
tagName: sel,
|
|
@@ -6425,16 +6355,17 @@ function hydrateCustomElement(elm, vnode) {
|
|
|
6425
6355
|
vnode.elm = elm;
|
|
6426
6356
|
vnode.vm = vm;
|
|
6427
6357
|
allocateChildren(vnode, vm);
|
|
6428
|
-
patchElementPropsAndAttrs(vnode);
|
|
6358
|
+
patchElementPropsAndAttrs(vnode, renderer);
|
|
6429
6359
|
// Insert hook section:
|
|
6430
6360
|
if (process.env.NODE_ENV !== 'production') {
|
|
6431
6361
|
assert.isTrue(vm.state === 0 /* created */, `${vm} cannot be recycled.`);
|
|
6432
6362
|
}
|
|
6433
6363
|
runConnectedCallback(vm);
|
|
6434
6364
|
if (vm.renderMode !== 0 /* Light */) {
|
|
6365
|
+
const { getFirstChild } = renderer;
|
|
6435
6366
|
// VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
|
|
6436
6367
|
// Note: for Light DOM, this is handled while hydrating the VM
|
|
6437
|
-
hydrateChildren(getFirstChild
|
|
6368
|
+
hydrateChildren(getFirstChild(elm), vnode.children, elm, vm);
|
|
6438
6369
|
}
|
|
6439
6370
|
hydrateVM(vm);
|
|
6440
6371
|
return elm;
|
|
@@ -6443,11 +6374,12 @@ function hydrateChildren(node, children, parentNode, owner) {
|
|
|
6443
6374
|
let hasWarned = false;
|
|
6444
6375
|
let nextNode = node;
|
|
6445
6376
|
let anchor = null;
|
|
6377
|
+
const { renderer } = owner;
|
|
6446
6378
|
for (let i = 0; i < children.length; i++) {
|
|
6447
6379
|
const childVnode = children[i];
|
|
6448
6380
|
if (!isNull(childVnode)) {
|
|
6449
6381
|
if (nextNode) {
|
|
6450
|
-
nextNode = hydrateNode(nextNode, childVnode);
|
|
6382
|
+
nextNode = hydrateNode(nextNode, childVnode, renderer);
|
|
6451
6383
|
anchor = childVnode.elm;
|
|
6452
6384
|
}
|
|
6453
6385
|
else {
|
|
@@ -6458,7 +6390,7 @@ function hydrateChildren(node, children, parentNode, owner) {
|
|
|
6458
6390
|
logError(`Hydration mismatch: incorrect number of rendered nodes. Client produced more nodes than the server.`, owner);
|
|
6459
6391
|
}
|
|
6460
6392
|
}
|
|
6461
|
-
mount(childVnode, parentNode, anchor);
|
|
6393
|
+
mount(childVnode, parentNode, renderer, anchor);
|
|
6462
6394
|
anchor = childVnode.elm;
|
|
6463
6395
|
}
|
|
6464
6396
|
}
|
|
@@ -6470,31 +6402,33 @@ function hydrateChildren(node, children, parentNode, owner) {
|
|
|
6470
6402
|
logError(`Hydration mismatch: incorrect number of rendered nodes. Server rendered more nodes than the client.`, owner);
|
|
6471
6403
|
}
|
|
6472
6404
|
}
|
|
6405
|
+
// nextSibling is mostly harmless, and since we don't have
|
|
6406
|
+
// a good reference to what element to act upon, we instead
|
|
6407
|
+
// rely on the vm's associated renderer for navigating to the
|
|
6408
|
+
// next node in the list to be hydrated.
|
|
6409
|
+
const { nextSibling } = renderer;
|
|
6473
6410
|
do {
|
|
6474
6411
|
const current = nextNode;
|
|
6475
|
-
nextNode = nextSibling
|
|
6476
|
-
removeNode(current, parentNode);
|
|
6412
|
+
nextNode = nextSibling(nextNode);
|
|
6413
|
+
removeNode(current, parentNode, renderer);
|
|
6477
6414
|
} while (nextNode);
|
|
6478
6415
|
}
|
|
6479
6416
|
}
|
|
6480
|
-
function handleMismatch(node, vnode,
|
|
6417
|
+
function handleMismatch(node, vnode, renderer) {
|
|
6481
6418
|
hasMismatch = true;
|
|
6482
|
-
|
|
6483
|
-
|
|
6484
|
-
|
|
6485
|
-
|
|
6486
|
-
}
|
|
6487
|
-
const parentNode = getProperty$1(node, 'parentNode');
|
|
6488
|
-
mount(vnode, parentNode, node);
|
|
6489
|
-
removeNode(node, parentNode);
|
|
6419
|
+
const { getProperty } = renderer;
|
|
6420
|
+
const parentNode = getProperty(node, 'parentNode');
|
|
6421
|
+
mount(vnode, parentNode, renderer, node);
|
|
6422
|
+
removeNode(node, parentNode, renderer);
|
|
6490
6423
|
return vnode.elm;
|
|
6491
6424
|
}
|
|
6492
|
-
function patchElementPropsAndAttrs(vnode) {
|
|
6493
|
-
applyEventListeners(vnode);
|
|
6494
|
-
patchProps(null, vnode);
|
|
6425
|
+
function patchElementPropsAndAttrs(vnode, renderer) {
|
|
6426
|
+
applyEventListeners(vnode, renderer);
|
|
6427
|
+
patchProps(null, vnode, renderer);
|
|
6495
6428
|
}
|
|
6496
|
-
function hasCorrectNodeType(vnode, node, nodeType) {
|
|
6497
|
-
|
|
6429
|
+
function hasCorrectNodeType(vnode, node, nodeType, renderer) {
|
|
6430
|
+
const { getProperty } = renderer;
|
|
6431
|
+
if (getProperty(node, 'nodeType') !== nodeType) {
|
|
6498
6432
|
if (process.env.NODE_ENV !== 'production') {
|
|
6499
6433
|
logError('Hydration mismatch: incorrect node type received', vnode.owner);
|
|
6500
6434
|
}
|
|
@@ -6502,46 +6436,51 @@ function hasCorrectNodeType(vnode, node, nodeType) {
|
|
|
6502
6436
|
}
|
|
6503
6437
|
return true;
|
|
6504
6438
|
}
|
|
6505
|
-
function isMatchingElement(vnode, elm) {
|
|
6506
|
-
|
|
6439
|
+
function isMatchingElement(vnode, elm, renderer) {
|
|
6440
|
+
const { getProperty } = renderer;
|
|
6441
|
+
if (vnode.sel.toLowerCase() !== getProperty(elm, 'tagName').toLowerCase()) {
|
|
6507
6442
|
if (process.env.NODE_ENV !== 'production') {
|
|
6508
|
-
logError(`Hydration mismatch: expecting element with tag "${vnode.sel.toLowerCase()}" but found "${getProperty
|
|
6443
|
+
logError(`Hydration mismatch: expecting element with tag "${vnode.sel.toLowerCase()}" but found "${getProperty(elm, 'tagName').toLowerCase()}".`, vnode.owner);
|
|
6509
6444
|
}
|
|
6510
6445
|
return false;
|
|
6511
6446
|
}
|
|
6512
|
-
const hasIncompatibleAttrs = validateAttrs(vnode, elm);
|
|
6513
|
-
const hasIncompatibleClass = validateClassAttr(vnode, elm);
|
|
6514
|
-
const hasIncompatibleStyle = validateStyleAttr(vnode, elm);
|
|
6447
|
+
const hasIncompatibleAttrs = validateAttrs(vnode, elm, renderer);
|
|
6448
|
+
const hasIncompatibleClass = validateClassAttr(vnode, elm, renderer);
|
|
6449
|
+
const hasIncompatibleStyle = validateStyleAttr(vnode, elm, renderer);
|
|
6515
6450
|
return hasIncompatibleAttrs && hasIncompatibleClass && hasIncompatibleStyle;
|
|
6516
6451
|
}
|
|
6517
|
-
function validateAttrs(vnode, elm) {
|
|
6452
|
+
function validateAttrs(vnode, elm, renderer) {
|
|
6518
6453
|
const { data: { attrs = {} }, } = vnode;
|
|
6519
6454
|
let nodesAreCompatible = true;
|
|
6520
6455
|
// Validate attributes, though we could always recovery from those by running the update mods.
|
|
6521
6456
|
// Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
|
|
6522
6457
|
for (const [attrName, attrValue] of Object.entries(attrs)) {
|
|
6523
|
-
const
|
|
6458
|
+
const { owner } = vnode;
|
|
6459
|
+
const { getAttribute } = renderer;
|
|
6460
|
+
const elmAttrValue = getAttribute(elm, attrName);
|
|
6524
6461
|
if (String(attrValue) !== elmAttrValue) {
|
|
6525
6462
|
if (process.env.NODE_ENV !== 'production') {
|
|
6526
|
-
|
|
6463
|
+
const { getProperty } = renderer;
|
|
6464
|
+
logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "${attrName}" has different values, expected "${attrValue}" but found "${elmAttrValue}"`, owner);
|
|
6527
6465
|
}
|
|
6528
6466
|
nodesAreCompatible = false;
|
|
6529
6467
|
}
|
|
6530
6468
|
}
|
|
6531
6469
|
return nodesAreCompatible;
|
|
6532
6470
|
}
|
|
6533
|
-
function validateClassAttr(vnode, elm) {
|
|
6471
|
+
function validateClassAttr(vnode, elm, renderer) {
|
|
6534
6472
|
const { data: { className, classMap }, } = vnode;
|
|
6473
|
+
const { getProperty, getClassList } = renderer;
|
|
6535
6474
|
let nodesAreCompatible = true;
|
|
6536
6475
|
let vnodeClassName;
|
|
6537
|
-
if (!isUndefined$1(className) && String(className) !== getProperty
|
|
6476
|
+
if (!isUndefined$1(className) && String(className) !== getProperty(elm, 'className')) {
|
|
6538
6477
|
// className is used when class is bound to an expr.
|
|
6539
6478
|
nodesAreCompatible = false;
|
|
6540
6479
|
vnodeClassName = className;
|
|
6541
6480
|
}
|
|
6542
6481
|
else if (!isUndefined$1(classMap)) {
|
|
6543
6482
|
// classMap is used when class is set to static value.
|
|
6544
|
-
const classList = getClassList
|
|
6483
|
+
const classList = getClassList(elm);
|
|
6545
6484
|
let computedClassName = '';
|
|
6546
6485
|
// all classes from the vnode should be in the element.classList
|
|
6547
6486
|
for (const name in classMap) {
|
|
@@ -6557,14 +6496,15 @@ function validateClassAttr(vnode, elm) {
|
|
|
6557
6496
|
}
|
|
6558
6497
|
if (!nodesAreCompatible) {
|
|
6559
6498
|
if (process.env.NODE_ENV !== 'production') {
|
|
6560
|
-
logError(`Mismatch hydrating element <${getProperty
|
|
6499
|
+
logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "class" has different values, expected "${vnodeClassName}" but found "${getProperty(elm, 'className')}"`, vnode.owner);
|
|
6561
6500
|
}
|
|
6562
6501
|
}
|
|
6563
6502
|
return nodesAreCompatible;
|
|
6564
6503
|
}
|
|
6565
|
-
function validateStyleAttr(vnode, elm) {
|
|
6504
|
+
function validateStyleAttr(vnode, elm, renderer) {
|
|
6566
6505
|
const { data: { style, styleDecls }, } = vnode;
|
|
6567
|
-
const
|
|
6506
|
+
const { getAttribute } = renderer;
|
|
6507
|
+
const elmStyle = getAttribute(elm, 'style') || '';
|
|
6568
6508
|
let vnodeStyle;
|
|
6569
6509
|
let nodesAreCompatible = true;
|
|
6570
6510
|
if (!isUndefined$1(style) && style !== elmStyle) {
|
|
@@ -6596,7 +6536,8 @@ function validateStyleAttr(vnode, elm) {
|
|
|
6596
6536
|
}
|
|
6597
6537
|
if (!nodesAreCompatible) {
|
|
6598
6538
|
if (process.env.NODE_ENV !== 'production') {
|
|
6599
|
-
|
|
6539
|
+
const { getProperty } = renderer;
|
|
6540
|
+
logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "style" has different values, expected "${vnodeStyle}" but found "${elmStyle}".`, vnode.owner);
|
|
6600
6541
|
}
|
|
6601
6542
|
}
|
|
6602
6543
|
return nodesAreCompatible;
|
|
@@ -6736,7 +6677,7 @@ function getComponentConstructor(elm) {
|
|
|
6736
6677
|
}
|
|
6737
6678
|
return ctor;
|
|
6738
6679
|
}
|
|
6739
|
-
/* version: 2.14.
|
|
6680
|
+
/* version: 2.14.2 */
|
|
6740
6681
|
|
|
6741
6682
|
/*
|
|
6742
6683
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -6895,7 +6836,7 @@ function isCustomElementRegistryAvailable() {
|
|
|
6895
6836
|
try {
|
|
6896
6837
|
// dereference HTMLElement global because babel wraps globals in compat mode with a
|
|
6897
6838
|
// _wrapNativeSuper()
|
|
6898
|
-
// This is a problem because LWCUpgradableElement extends renderer.
|
|
6839
|
+
// This is a problem because LWCUpgradableElement extends renderer.HTMLElementExported which does not
|
|
6899
6840
|
// get wrapped by babel.
|
|
6900
6841
|
const HTMLElementAlias = HTMLElement;
|
|
6901
6842
|
// In case we use compat mode with a modern browser, the compat mode transformation
|
|
@@ -6949,6 +6890,9 @@ function setIsHydrating(value) {
|
|
|
6949
6890
|
hydrating = value;
|
|
6950
6891
|
}
|
|
6951
6892
|
const ssr = false;
|
|
6893
|
+
function isHydrating() {
|
|
6894
|
+
return hydrating;
|
|
6895
|
+
}
|
|
6952
6896
|
const isNativeShadowDefined = _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED];
|
|
6953
6897
|
const isSyntheticShadowDefined = hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN);
|
|
6954
6898
|
function createElement$1(tagName, namespace) {
|
|
@@ -7067,76 +7011,47 @@ function assertInstanceOfHTMLElement(elm, msg) {
|
|
|
7067
7011
|
assert.invariant(elm instanceof HTMLElement, msg);
|
|
7068
7012
|
}
|
|
7069
7013
|
const HTMLElementExported = HTMLElementConstructor;
|
|
7070
|
-
|
|
7071
|
-
|
|
7072
|
-
|
|
7073
|
-
|
|
7074
|
-
|
|
7075
|
-
|
|
7076
|
-
|
|
7077
|
-
|
|
7078
|
-
|
|
7079
|
-
|
|
7080
|
-
|
|
7081
|
-
|
|
7082
|
-
|
|
7083
|
-
|
|
7084
|
-
|
|
7085
|
-
|
|
7086
|
-
|
|
7087
|
-
|
|
7088
|
-
|
|
7089
|
-
|
|
7090
|
-
|
|
7091
|
-
|
|
7092
|
-
|
|
7093
|
-
|
|
7094
|
-
|
|
7095
|
-
|
|
7096
|
-
|
|
7097
|
-
|
|
7098
|
-
|
|
7099
|
-
|
|
7100
|
-
|
|
7101
|
-
|
|
7102
|
-
|
|
7103
|
-
|
|
7104
|
-
|
|
7105
|
-
|
|
7106
|
-
|
|
7107
|
-
|
|
7108
|
-
|
|
7109
|
-
|
|
7110
|
-
|
|
7111
|
-
setSetText(setText);
|
|
7112
|
-
setSsr(ssr);
|
|
7113
|
-
setAddEventListener(addEventListener);
|
|
7114
|
-
setInsertStylesheet(insertStylesheet);
|
|
7115
|
-
|
|
7116
|
-
/*
|
|
7117
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
7118
|
-
* All rights reserved.
|
|
7119
|
-
* SPDX-License-Identifier: MIT
|
|
7120
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
7121
|
-
*/
|
|
7122
|
-
// @ts-ignore
|
|
7123
|
-
|
|
7124
|
-
if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
|
|
7125
|
-
window.addEventListener('test-dummy-flag', () => {
|
|
7126
|
-
let hasFlag = false;
|
|
7127
|
-
|
|
7128
|
-
if (runtimeFlags.DUMMY_TEST_FLAG) {
|
|
7129
|
-
hasFlag = true;
|
|
7130
|
-
}
|
|
7131
|
-
|
|
7132
|
-
window.dispatchEvent(new CustomEvent('has-dummy-flag', {
|
|
7133
|
-
detail: {
|
|
7134
|
-
package: '@lwc/engine-dom',
|
|
7135
|
-
hasFlag
|
|
7136
|
-
}
|
|
7137
|
-
}));
|
|
7138
|
-
});
|
|
7139
|
-
}
|
|
7014
|
+
const renderer = {
|
|
7015
|
+
ssr,
|
|
7016
|
+
isNativeShadowDefined,
|
|
7017
|
+
isSyntheticShadowDefined,
|
|
7018
|
+
HTMLElementExported,
|
|
7019
|
+
isHydrating,
|
|
7020
|
+
insert,
|
|
7021
|
+
remove,
|
|
7022
|
+
createElement: createElement$1,
|
|
7023
|
+
createText,
|
|
7024
|
+
createComment,
|
|
7025
|
+
nextSibling,
|
|
7026
|
+
attachShadow,
|
|
7027
|
+
getProperty,
|
|
7028
|
+
setProperty,
|
|
7029
|
+
setText,
|
|
7030
|
+
getAttribute,
|
|
7031
|
+
setAttribute,
|
|
7032
|
+
removeAttribute,
|
|
7033
|
+
addEventListener,
|
|
7034
|
+
removeEventListener,
|
|
7035
|
+
dispatchEvent,
|
|
7036
|
+
getClassList,
|
|
7037
|
+
setCSSStyleProperty,
|
|
7038
|
+
getBoundingClientRect,
|
|
7039
|
+
querySelector,
|
|
7040
|
+
querySelectorAll,
|
|
7041
|
+
getElementsByTagName,
|
|
7042
|
+
getElementsByClassName,
|
|
7043
|
+
getChildren,
|
|
7044
|
+
getChildNodes,
|
|
7045
|
+
getFirstChild,
|
|
7046
|
+
getFirstElementChild,
|
|
7047
|
+
getLastChild,
|
|
7048
|
+
getLastElementChild,
|
|
7049
|
+
isConnected,
|
|
7050
|
+
insertStylesheet,
|
|
7051
|
+
assertInstanceOfHTMLElement,
|
|
7052
|
+
defineCustomElement,
|
|
7053
|
+
getCustomElement,
|
|
7054
|
+
};
|
|
7140
7055
|
|
|
7141
7056
|
/*
|
|
7142
7057
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -7158,7 +7073,7 @@ function resetShadowRootAndLightDom(element, Ctor) {
|
|
|
7158
7073
|
}
|
|
7159
7074
|
}
|
|
7160
7075
|
function createVMWithProps(element, Ctor, props) {
|
|
7161
|
-
const vm = createVM(element, Ctor, {
|
|
7076
|
+
const vm = createVM(element, Ctor, renderer, {
|
|
7162
7077
|
mode: 'open',
|
|
7163
7078
|
owner: null,
|
|
7164
7079
|
tagName: element.tagName.toLowerCase(),
|
|
@@ -7254,7 +7169,7 @@ function buildCustomElementConstructor(Ctor) {
|
|
|
7254
7169
|
hydratedCustomElements.add(this);
|
|
7255
7170
|
}
|
|
7256
7171
|
else {
|
|
7257
|
-
createVM(this, Ctor, {
|
|
7172
|
+
createVM(this, Ctor, renderer, {
|
|
7258
7173
|
mode: 'open',
|
|
7259
7174
|
owner: null,
|
|
7260
7175
|
tagName: this.tagName,
|
|
@@ -7339,7 +7254,7 @@ function createElement(sel, options) {
|
|
|
7339
7254
|
if (!isFunction$1(Ctor)) {
|
|
7340
7255
|
throw new TypeError(`"createElement" function expects an "is" option with a valid component constructor.`);
|
|
7341
7256
|
}
|
|
7342
|
-
const UpgradableConstructor = getUpgradableConstructor(sel);
|
|
7257
|
+
const UpgradableConstructor = getUpgradableConstructor(sel, renderer);
|
|
7343
7258
|
let wasComponentUpgraded = false;
|
|
7344
7259
|
// the custom element from the registry is expecting an upgrade callback
|
|
7345
7260
|
/**
|
|
@@ -7349,7 +7264,7 @@ function createElement(sel, options) {
|
|
|
7349
7264
|
* an upgradable custom element.
|
|
7350
7265
|
*/
|
|
7351
7266
|
const element = new UpgradableConstructor((elm) => {
|
|
7352
|
-
createVM(elm, Ctor, {
|
|
7267
|
+
createVM(elm, Ctor, renderer, {
|
|
7353
7268
|
tagName: sel,
|
|
7354
7269
|
mode: options.mode !== 'closed' ? 'open' : 'closed',
|
|
7355
7270
|
owner: null,
|
|
@@ -7433,6 +7348,6 @@ defineProperty(LightningElement, 'CustomElementConstructor', {
|
|
|
7433
7348
|
});
|
|
7434
7349
|
freeze(LightningElement);
|
|
7435
7350
|
seal(LightningElement.prototype);
|
|
7436
|
-
/* version: 2.14.
|
|
7351
|
+
/* version: 2.14.2 */
|
|
7437
7352
|
|
|
7438
|
-
export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, deprecatedBuildCustomElementConstructor as buildCustomElementConstructor, createContextProvider, createElement, freezeTemplate, getComponentConstructor, getComponentDef, hydrateComponent, isComponentConstructor, isNodeShadowed as isNodeFromTemplate, readonly, register, registerComponent, registerDecorators, registerTemplate, sanitizeAttribute, setFeatureFlag, setFeatureFlagForTest, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
|
|
7353
|
+
export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, deprecatedBuildCustomElementConstructor as buildCustomElementConstructor, createContextProvider, createElement, freezeTemplate, getComponentConstructor, getComponentDef, hydrateComponent, isComponentConstructor, isNodeShadowed as isNodeFromTemplate, readonly, register, registerComponent, registerDecorators, registerTemplate, renderer, sanitizeAttribute, setFeatureFlag, setFeatureFlagForTest, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
|