lwc 2.37.0 → 2.37.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/engine-dom/esm/es2017/engine-dom.js +2226 -2517
- package/dist/engine-dom/iife/es2017/engine-dom.js +8217 -8508
- package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es2017/engine-dom_debug.js +6603 -6857
- package/dist/engine-dom/iife/es5/engine-dom.js +8142 -8179
- package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es5/engine-dom_debug.js +6730 -6721
- package/dist/engine-dom/umd/es2017/engine-dom.js +8218 -8509
- package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es2017/engine-dom_debug.js +6604 -6858
- package/dist/engine-dom/umd/es5/engine-dom.js +8143 -8180
- package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es5/engine-dom_debug.js +6731 -6722
- package/dist/engine-server/commonjs/es2017/engine-server.js +1966 -2235
- package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
- package/dist/engine-server/esm/es2017/engine-server.js +1966 -2235
- package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +211 -233
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +4598 -4620
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.min.js +9 -9
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +4422 -4423
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +4328 -4352
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow.min.js +9 -9
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +4170 -4172
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +4599 -4621
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.min.js +9 -9
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +4423 -4424
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +4329 -4353
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow.min.js +9 -9
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +4171 -4173
- 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
|
@@ -442,41 +442,9 @@ function htmlEscape(str, attrMode = false) {
|
|
|
442
442
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
443
443
|
*/
|
|
444
444
|
// Increment whenever the LWC template compiler changes
|
|
445
|
-
const LWC_VERSION = "2.37.
|
|
445
|
+
const LWC_VERSION = "2.37.1";
|
|
446
446
|
const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
|
|
447
|
-
/** version: 2.37.
|
|
448
|
-
|
|
449
|
-
/*
|
|
450
|
-
* Copyright (c) 2020, salesforce.com, inc.
|
|
451
|
-
* All rights reserved.
|
|
452
|
-
* SPDX-License-Identifier: MIT
|
|
453
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
454
|
-
*/
|
|
455
|
-
/**
|
|
456
|
-
* The following constructor might be used in either the constructor or the connectedCallback. In
|
|
457
|
-
* order to ensure that the component evaluates, we attach those mock constructors to the global
|
|
458
|
-
* object.
|
|
459
|
-
* Also note that Event is defined in Node 16+, but CustomEvent is not, so they have to be
|
|
460
|
-
* polyfilled separately.
|
|
461
|
-
*/
|
|
462
|
-
if (typeof Event !== 'function') {
|
|
463
|
-
class Event {
|
|
464
|
-
}
|
|
465
|
-
defineProperty(_globalThis, 'Event', {
|
|
466
|
-
value: Event,
|
|
467
|
-
configurable: true,
|
|
468
|
-
writable: true,
|
|
469
|
-
});
|
|
470
|
-
}
|
|
471
|
-
if (typeof CustomEvent !== 'function') {
|
|
472
|
-
class CustomEvent extends Event {
|
|
473
|
-
}
|
|
474
|
-
defineProperty(_globalThis, 'CustomEvent', {
|
|
475
|
-
value: CustomEvent,
|
|
476
|
-
configurable: true,
|
|
477
|
-
writable: true,
|
|
478
|
-
});
|
|
479
|
-
}
|
|
447
|
+
/** version: 2.37.1 */
|
|
480
448
|
|
|
481
449
|
/**
|
|
482
450
|
* Copyright (C) 2018 salesforce.com, inc.
|
|
@@ -499,10 +467,12 @@ const features = {
|
|
|
499
467
|
ENABLE_FROZEN_TEMPLATE: null,
|
|
500
468
|
DISABLE_ARIA_REFLECTION_POLYFILL: null,
|
|
501
469
|
};
|
|
470
|
+
// eslint-disable-next-line no-restricted-properties
|
|
502
471
|
if (!_globalThis.lwcRuntimeFlags) {
|
|
503
472
|
Object.defineProperty(_globalThis, 'lwcRuntimeFlags', { value: create(null) });
|
|
504
473
|
}
|
|
505
|
-
|
|
474
|
+
// eslint-disable-next-line no-restricted-properties
|
|
475
|
+
const flags = _globalThis.lwcRuntimeFlags;
|
|
506
476
|
/**
|
|
507
477
|
* Set the value at runtime of a given feature flag. This method only be invoked once per feature
|
|
508
478
|
* flag. It is meant to be used during the app initialization.
|
|
@@ -530,17 +500,17 @@ function setFeatureFlag(name, value) {
|
|
|
530
500
|
// This may seem redundant, but `process.env.NODE_ENV === 'test-karma-lwc'` is replaced by Karma tests
|
|
531
501
|
if (process.env.NODE_ENV === 'test-karma-lwc' || process.env.NODE_ENV !== 'production') {
|
|
532
502
|
// Allow the same flag to be set more than once outside of production to enable testing
|
|
533
|
-
|
|
503
|
+
flags[name] = value;
|
|
534
504
|
}
|
|
535
505
|
else {
|
|
536
506
|
// Disallow the same flag to be set more than once in production
|
|
537
|
-
const runtimeValue =
|
|
507
|
+
const runtimeValue = flags[name];
|
|
538
508
|
if (!isUndefined$1(runtimeValue)) {
|
|
539
509
|
// eslint-disable-next-line no-console
|
|
540
510
|
console.error(`Failed to set the value "${value}" for the runtime feature flag "${name}". "${name}" has already been set with the value "${runtimeValue}".`);
|
|
541
511
|
return;
|
|
542
512
|
}
|
|
543
|
-
defineProperty(
|
|
513
|
+
defineProperty(flags, name, { value });
|
|
544
514
|
}
|
|
545
515
|
}
|
|
546
516
|
/**
|
|
@@ -553,7 +523,39 @@ function setFeatureFlagForTest(name, value) {
|
|
|
553
523
|
setFeatureFlag(name, value);
|
|
554
524
|
}
|
|
555
525
|
}
|
|
556
|
-
/** version: 2.37.
|
|
526
|
+
/** version: 2.37.1 */
|
|
527
|
+
|
|
528
|
+
/*
|
|
529
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
530
|
+
* All rights reserved.
|
|
531
|
+
* SPDX-License-Identifier: MIT
|
|
532
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
533
|
+
*/
|
|
534
|
+
/**
|
|
535
|
+
* The following constructor might be used in either the constructor or the connectedCallback. In
|
|
536
|
+
* order to ensure that the component evaluates, we attach those mock constructors to the global
|
|
537
|
+
* object.
|
|
538
|
+
* Also note that Event is defined in Node 16+, but CustomEvent is not, so they have to be
|
|
539
|
+
* polyfilled separately.
|
|
540
|
+
*/
|
|
541
|
+
if (typeof Event !== 'function') {
|
|
542
|
+
class Event {
|
|
543
|
+
}
|
|
544
|
+
defineProperty(_globalThis, 'Event', {
|
|
545
|
+
value: Event,
|
|
546
|
+
configurable: true,
|
|
547
|
+
writable: true,
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
if (typeof CustomEvent !== 'function') {
|
|
551
|
+
class CustomEvent extends Event {
|
|
552
|
+
}
|
|
553
|
+
defineProperty(_globalThis, 'CustomEvent', {
|
|
554
|
+
value: CustomEvent,
|
|
555
|
+
configurable: true,
|
|
556
|
+
writable: true,
|
|
557
|
+
});
|
|
558
|
+
}
|
|
557
559
|
|
|
558
560
|
/**
|
|
559
561
|
* Copyright (C) 2018 salesforce.com, inc.
|
|
@@ -617,32 +619,10 @@ function applyAriaReflection(prototype = Element.prototype) {
|
|
|
617
619
|
}
|
|
618
620
|
}
|
|
619
621
|
}
|
|
620
|
-
/** version: 2.37.
|
|
622
|
+
/** version: 2.37.1 */
|
|
621
623
|
|
|
622
624
|
/* proxy-compat-disable */
|
|
623
625
|
|
|
624
|
-
/*
|
|
625
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
626
|
-
* All rights reserved.
|
|
627
|
-
* SPDX-License-Identifier: MIT
|
|
628
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
629
|
-
*/
|
|
630
|
-
// Only used in LWC's Karma tests
|
|
631
|
-
if (process.env.NODE_ENV === 'test-karma-lwc') {
|
|
632
|
-
window.addEventListener('test-dummy-flag', () => {
|
|
633
|
-
let hasFlag = false;
|
|
634
|
-
if (lwcRuntimeFlags.DUMMY_TEST_FLAG) {
|
|
635
|
-
hasFlag = true;
|
|
636
|
-
}
|
|
637
|
-
window.dispatchEvent(new CustomEvent('has-dummy-flag', {
|
|
638
|
-
detail: {
|
|
639
|
-
package: '@lwc/engine-core',
|
|
640
|
-
hasFlag
|
|
641
|
-
}
|
|
642
|
-
}));
|
|
643
|
-
});
|
|
644
|
-
}
|
|
645
|
-
|
|
646
626
|
/*
|
|
647
627
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
648
628
|
* All rights reserved.
|
|
@@ -1881,50 +1861,45 @@ function getReactiveProxy(value) {
|
|
|
1881
1861
|
* for the Base Lightning Element, it also include the reactivity bit, so the standard property is reactive.
|
|
1882
1862
|
*/
|
|
1883
1863
|
function createBridgeToElementDescriptor(propName, descriptor) {
|
|
1884
|
-
|
|
1885
|
-
get
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
if (!isFunction$1(get)) {
|
|
1891
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1892
|
-
assert.fail(`Detected invalid public property descriptor for HTMLElement.prototype.${propName} definition. Missing the standard getter.`);
|
|
1893
|
-
}
|
|
1894
|
-
throw new TypeError();
|
|
1895
|
-
}
|
|
1896
|
-
if (!isFunction$1(set)) {
|
|
1897
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1898
|
-
assert.fail(`Detected invalid public property descriptor for HTMLElement.prototype.${propName} definition. Missing the standard setter.`);
|
|
1864
|
+
const { get, set, enumerable, configurable } = descriptor;
|
|
1865
|
+
if (!isFunction$1(get)) {
|
|
1866
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1867
|
+
assert.fail(`Detected invalid public property descriptor for HTMLElement.prototype.${propName} definition. Missing the standard getter.`);
|
|
1868
|
+
}
|
|
1869
|
+
throw new TypeError();
|
|
1899
1870
|
}
|
|
1900
|
-
|
|
1901
|
-
}
|
|
1902
|
-
return {
|
|
1903
|
-
enumerable,
|
|
1904
|
-
configurable,
|
|
1905
|
-
get() {
|
|
1906
|
-
const vm = getAssociatedVM(this);
|
|
1907
|
-
if (isBeingConstructed(vm)) {
|
|
1871
|
+
if (!isFunction$1(set)) {
|
|
1908
1872
|
if (process.env.NODE_ENV !== 'production') {
|
|
1909
|
-
|
|
1873
|
+
assert.fail(`Detected invalid public property descriptor for HTMLElement.prototype.${propName} definition. Missing the standard setter.`);
|
|
1910
1874
|
}
|
|
1911
|
-
|
|
1912
|
-
}
|
|
1913
|
-
return get.call(vm.elm);
|
|
1914
|
-
},
|
|
1915
|
-
set(newValue) {
|
|
1916
|
-
const vm = getAssociatedVM(this);
|
|
1917
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1918
|
-
const vmBeingRendered = getVMBeingRendered();
|
|
1919
|
-
assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${propName}`);
|
|
1920
|
-
assert.invariant(!isUpdatingTemplate, `When updating the template of ${vmBeingRendered}, one of the accessors used by the template has side effects on the state of ${vm}.${propName}`);
|
|
1921
|
-
assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
|
|
1922
|
-
assert.invariant(!isObject(newValue) || isNull(newValue), `Invalid value "${newValue}" for "${propName}" of ${vm}. Value cannot be an object, must be a primitive value.`);
|
|
1923
|
-
}
|
|
1924
|
-
updateComponentValue(vm, propName, newValue);
|
|
1925
|
-
return set.call(vm.elm, newValue);
|
|
1875
|
+
throw new TypeError();
|
|
1926
1876
|
}
|
|
1927
|
-
|
|
1877
|
+
return {
|
|
1878
|
+
enumerable,
|
|
1879
|
+
configurable,
|
|
1880
|
+
get() {
|
|
1881
|
+
const vm = getAssociatedVM(this);
|
|
1882
|
+
if (isBeingConstructed(vm)) {
|
|
1883
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1884
|
+
logError(`The value of property \`${propName}\` can't be read from the constructor because the owner component hasn't set the value yet. Instead, use the constructor to set a default value for the property.`, vm);
|
|
1885
|
+
}
|
|
1886
|
+
return;
|
|
1887
|
+
}
|
|
1888
|
+
return get.call(vm.elm);
|
|
1889
|
+
},
|
|
1890
|
+
set(newValue) {
|
|
1891
|
+
const vm = getAssociatedVM(this);
|
|
1892
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1893
|
+
const vmBeingRendered = getVMBeingRendered();
|
|
1894
|
+
assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${propName}`);
|
|
1895
|
+
assert.invariant(!isUpdatingTemplate, `When updating the template of ${vmBeingRendered}, one of the accessors used by the template has side effects on the state of ${vm}.${propName}`);
|
|
1896
|
+
assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
|
|
1897
|
+
assert.invariant(!isObject(newValue) || isNull(newValue), `Invalid value "${newValue}" for "${propName}" of ${vm}. Value cannot be an object, must be a primitive value.`);
|
|
1898
|
+
}
|
|
1899
|
+
updateComponentValue(vm, propName, newValue);
|
|
1900
|
+
return set.call(vm.elm, newValue);
|
|
1901
|
+
},
|
|
1902
|
+
};
|
|
1928
1903
|
}
|
|
1929
1904
|
const refsCache = new WeakMap();
|
|
1930
1905
|
/**
|
|
@@ -1933,436 +1908,347 @@ const refsCache = new WeakMap();
|
|
|
1933
1908
|
**/
|
|
1934
1909
|
// @ts-ignore
|
|
1935
1910
|
const LightningElement = function () {
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
def
|
|
1945
|
-
elm
|
|
1946
|
-
} = vm;
|
|
1947
|
-
const {
|
|
1948
|
-
bridge
|
|
1949
|
-
} = def;
|
|
1950
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1951
|
-
const {
|
|
1952
|
-
assertInstanceOfHTMLElement
|
|
1953
|
-
} = vm.renderer;
|
|
1954
|
-
assertInstanceOfHTMLElement(vm.elm, `Component creation requires a DOM element to be associated to ${vm}.`);
|
|
1955
|
-
}
|
|
1956
|
-
const component = this;
|
|
1957
|
-
setPrototypeOf(elm, bridge.prototype);
|
|
1958
|
-
vm.component = this;
|
|
1959
|
-
// Locker hooks assignment. When the LWC engine run with Locker, Locker intercepts all the new
|
|
1960
|
-
// component creation and passes hooks to instrument all the component interactions with the
|
|
1961
|
-
// engine. We are intentionally hiding this argument from the formal API of LightningElement
|
|
1962
|
-
// because we don't want folks to know about it just yet.
|
|
1963
|
-
if (arguments.length === 1) {
|
|
1964
|
-
const {
|
|
1965
|
-
callHook,
|
|
1966
|
-
setHook,
|
|
1967
|
-
getHook
|
|
1968
|
-
} = arguments[0];
|
|
1969
|
-
vm.callHook = callHook;
|
|
1970
|
-
vm.setHook = setHook;
|
|
1971
|
-
vm.getHook = getHook;
|
|
1972
|
-
}
|
|
1973
|
-
// Linking elm, shadow root and component with the VM.
|
|
1974
|
-
associateVM(component, vm);
|
|
1975
|
-
associateVM(elm, vm);
|
|
1976
|
-
if (vm.renderMode === 1 /* RenderMode.Shadow */) {
|
|
1977
|
-
vm.renderRoot = doAttachShadow(vm);
|
|
1978
|
-
} else {
|
|
1979
|
-
vm.renderRoot = elm;
|
|
1980
|
-
}
|
|
1981
|
-
// Adding extra guard rails in DEV mode.
|
|
1982
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1983
|
-
patchCustomElementWithRestrictions(elm);
|
|
1984
|
-
patchComponentWithRestrictions(component);
|
|
1985
|
-
}
|
|
1986
|
-
return this;
|
|
1987
|
-
};
|
|
1988
|
-
function doAttachShadow(vm) {
|
|
1989
|
-
const {
|
|
1990
|
-
elm,
|
|
1991
|
-
mode,
|
|
1992
|
-
shadowMode,
|
|
1993
|
-
def: {
|
|
1994
|
-
ctor
|
|
1995
|
-
},
|
|
1996
|
-
renderer: {
|
|
1997
|
-
attachShadow
|
|
1998
|
-
}
|
|
1999
|
-
} = vm;
|
|
2000
|
-
const shadowRoot = attachShadow(elm, {
|
|
2001
|
-
[KEY__SYNTHETIC_MODE]: shadowMode === 1 /* ShadowMode.Synthetic */,
|
|
2002
|
-
delegatesFocus: Boolean(ctor.delegatesFocus),
|
|
2003
|
-
mode
|
|
2004
|
-
});
|
|
2005
|
-
vm.shadowRoot = shadowRoot;
|
|
2006
|
-
associateVM(shadowRoot, vm);
|
|
2007
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2008
|
-
patchShadowRootWithRestrictions(shadowRoot);
|
|
2009
|
-
}
|
|
2010
|
-
return shadowRoot;
|
|
2011
|
-
}
|
|
2012
|
-
function warnIfInvokedDuringConstruction(vm, methodOrPropName) {
|
|
2013
|
-
if (isBeingConstructed(vm)) {
|
|
2014
|
-
logError(`this.${methodOrPropName} should not be called during the construction of the custom element for ${getComponentTag(vm)} because the element is not yet in the DOM or has no children yet.`);
|
|
2015
|
-
}
|
|
2016
|
-
}
|
|
2017
|
-
// @ts-ignore
|
|
2018
|
-
LightningElement.prototype = {
|
|
2019
|
-
constructor: LightningElement,
|
|
2020
|
-
dispatchEvent(event) {
|
|
2021
|
-
const vm = getAssociatedVM(this);
|
|
2022
|
-
const {
|
|
2023
|
-
elm,
|
|
2024
|
-
renderer: {
|
|
2025
|
-
dispatchEvent
|
|
2026
|
-
}
|
|
2027
|
-
} = vm;
|
|
2028
|
-
return dispatchEvent(elm, event);
|
|
2029
|
-
},
|
|
2030
|
-
addEventListener(type, listener, options) {
|
|
2031
|
-
const vm = getAssociatedVM(this);
|
|
2032
|
-
const {
|
|
2033
|
-
elm,
|
|
2034
|
-
renderer: {
|
|
2035
|
-
addEventListener
|
|
2036
|
-
}
|
|
2037
|
-
} = vm;
|
|
2038
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2039
|
-
const vmBeingRendered = getVMBeingRendered();
|
|
2040
|
-
assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm} by adding an event listener for "${type}".`);
|
|
2041
|
-
assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm} by adding an event listener for "${type}".`);
|
|
2042
|
-
assert.invariant(isFunction$1(listener), `Invalid second argument for this.addEventListener() in ${vm} for event "${type}". Expected an EventListener but received ${listener}.`);
|
|
2043
|
-
}
|
|
2044
|
-
const wrappedListener = getWrappedComponentsListener(vm, listener);
|
|
2045
|
-
addEventListener(elm, type, wrappedListener, options);
|
|
2046
|
-
},
|
|
2047
|
-
removeEventListener(type, listener, options) {
|
|
2048
|
-
const vm = getAssociatedVM(this);
|
|
2049
|
-
const {
|
|
2050
|
-
elm,
|
|
2051
|
-
renderer: {
|
|
2052
|
-
removeEventListener
|
|
2053
|
-
}
|
|
2054
|
-
} = vm;
|
|
2055
|
-
const wrappedListener = getWrappedComponentsListener(vm, listener);
|
|
2056
|
-
removeEventListener(elm, type, wrappedListener, options);
|
|
2057
|
-
},
|
|
2058
|
-
hasAttribute(name) {
|
|
2059
|
-
const vm = getAssociatedVM(this);
|
|
2060
|
-
const {
|
|
2061
|
-
elm,
|
|
2062
|
-
renderer: {
|
|
2063
|
-
getAttribute
|
|
2064
|
-
}
|
|
2065
|
-
} = vm;
|
|
2066
|
-
return !isNull(getAttribute(elm, name));
|
|
2067
|
-
},
|
|
2068
|
-
hasAttributeNS(namespace, name) {
|
|
2069
|
-
const vm = getAssociatedVM(this);
|
|
2070
|
-
const {
|
|
2071
|
-
elm,
|
|
2072
|
-
renderer: {
|
|
2073
|
-
getAttribute
|
|
2074
|
-
}
|
|
2075
|
-
} = vm;
|
|
2076
|
-
return !isNull(getAttribute(elm, name, namespace));
|
|
2077
|
-
},
|
|
2078
|
-
removeAttribute(name) {
|
|
2079
|
-
const vm = getAssociatedVM(this);
|
|
2080
|
-
const {
|
|
2081
|
-
elm,
|
|
2082
|
-
renderer: {
|
|
2083
|
-
removeAttribute
|
|
2084
|
-
}
|
|
2085
|
-
} = vm;
|
|
2086
|
-
unlockAttribute(elm, name);
|
|
2087
|
-
removeAttribute(elm, name);
|
|
2088
|
-
lockAttribute();
|
|
2089
|
-
},
|
|
2090
|
-
removeAttributeNS(namespace, name) {
|
|
2091
|
-
const {
|
|
2092
|
-
elm,
|
|
2093
|
-
renderer: {
|
|
2094
|
-
removeAttribute
|
|
2095
|
-
}
|
|
2096
|
-
} = getAssociatedVM(this);
|
|
2097
|
-
unlockAttribute(elm, name);
|
|
2098
|
-
removeAttribute(elm, name, namespace);
|
|
2099
|
-
lockAttribute();
|
|
2100
|
-
},
|
|
2101
|
-
getAttribute(name) {
|
|
2102
|
-
const vm = getAssociatedVM(this);
|
|
2103
|
-
const {
|
|
2104
|
-
elm
|
|
2105
|
-
} = vm;
|
|
2106
|
-
const {
|
|
2107
|
-
getAttribute
|
|
2108
|
-
} = vm.renderer;
|
|
2109
|
-
return getAttribute(elm, name);
|
|
2110
|
-
},
|
|
2111
|
-
getAttributeNS(namespace, name) {
|
|
2112
|
-
const vm = getAssociatedVM(this);
|
|
2113
|
-
const {
|
|
2114
|
-
elm
|
|
2115
|
-
} = vm;
|
|
2116
|
-
const {
|
|
2117
|
-
getAttribute
|
|
2118
|
-
} = vm.renderer;
|
|
2119
|
-
return getAttribute(elm, name, namespace);
|
|
2120
|
-
},
|
|
2121
|
-
setAttribute(name, value) {
|
|
2122
|
-
const vm = getAssociatedVM(this);
|
|
2123
|
-
const {
|
|
2124
|
-
elm,
|
|
2125
|
-
renderer: {
|
|
2126
|
-
setAttribute
|
|
2127
|
-
}
|
|
2128
|
-
} = vm;
|
|
1911
|
+
// This should be as performant as possible, while any initialization should be done lazily
|
|
1912
|
+
if (isNull(vmBeingConstructed)) {
|
|
1913
|
+
// Thrown when doing something like `new LightningElement()` or
|
|
1914
|
+
// `class Foo extends LightningElement {}; new Foo()`
|
|
1915
|
+
throw new TypeError('Illegal constructor');
|
|
1916
|
+
}
|
|
1917
|
+
const vm = vmBeingConstructed;
|
|
1918
|
+
const { def, elm } = vm;
|
|
1919
|
+
const { bridge } = def;
|
|
2129
1920
|
if (process.env.NODE_ENV !== 'production') {
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
|
|
2146
|
-
}
|
|
2147
|
-
unlockAttribute(elm, name);
|
|
2148
|
-
setAttribute(elm, name, value, namespace);
|
|
2149
|
-
lockAttribute();
|
|
2150
|
-
},
|
|
2151
|
-
getBoundingClientRect() {
|
|
2152
|
-
const vm = getAssociatedVM(this);
|
|
2153
|
-
const {
|
|
2154
|
-
elm,
|
|
2155
|
-
renderer: {
|
|
2156
|
-
getBoundingClientRect
|
|
2157
|
-
}
|
|
2158
|
-
} = vm;
|
|
2159
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2160
|
-
warnIfInvokedDuringConstruction(vm, 'getBoundingClientRect()');
|
|
2161
|
-
}
|
|
2162
|
-
return getBoundingClientRect(elm);
|
|
2163
|
-
},
|
|
2164
|
-
get isConnected() {
|
|
2165
|
-
const vm = getAssociatedVM(this);
|
|
2166
|
-
const {
|
|
2167
|
-
elm,
|
|
2168
|
-
renderer: {
|
|
2169
|
-
isConnected
|
|
2170
|
-
}
|
|
2171
|
-
} = vm;
|
|
2172
|
-
return isConnected(elm);
|
|
2173
|
-
},
|
|
2174
|
-
get classList() {
|
|
2175
|
-
const vm = getAssociatedVM(this);
|
|
2176
|
-
const {
|
|
2177
|
-
elm,
|
|
2178
|
-
renderer: {
|
|
2179
|
-
getClassList
|
|
2180
|
-
}
|
|
2181
|
-
} = vm;
|
|
2182
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2183
|
-
// TODO [#1290]: this still fails in dev but works in production, eventually, we should
|
|
2184
|
-
// just throw in all modes
|
|
2185
|
-
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.`);
|
|
2186
|
-
}
|
|
2187
|
-
return getClassList(elm);
|
|
2188
|
-
},
|
|
2189
|
-
get template() {
|
|
2190
|
-
const vm = getAssociatedVM(this);
|
|
2191
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2192
|
-
if (vm.renderMode === 0 /* RenderMode.Light */) {
|
|
2193
|
-
logError('`this.template` returns null for light DOM components. Since there is no shadow, the rendered content can be accessed via `this` itself. e.g. instead of `this.template.querySelector`, use `this.querySelector`.');
|
|
2194
|
-
}
|
|
2195
|
-
}
|
|
2196
|
-
return vm.shadowRoot;
|
|
2197
|
-
},
|
|
2198
|
-
get refs() {
|
|
2199
|
-
const vm = getAssociatedVM(this);
|
|
2200
|
-
if (isUpdatingTemplate) {
|
|
2201
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2202
|
-
logError(`this.refs should not be called while ${getComponentTag(vm)} is rendering. Use this.refs only when the DOM is stable, e.g. in renderedCallback().`);
|
|
2203
|
-
}
|
|
2204
|
-
// If the template is in the process of being updated, then we don't want to go through the normal
|
|
2205
|
-
// process of returning the refs and caching them, because the state of the refs is unstable.
|
|
2206
|
-
// This can happen if e.g. a template contains `<div class={foo}></div>` and `foo` is computed
|
|
2207
|
-
// based on `this.refs.bar`.
|
|
2208
|
-
return;
|
|
1921
|
+
const { assertInstanceOfHTMLElement } = vm.renderer;
|
|
1922
|
+
assertInstanceOfHTMLElement(vm.elm, `Component creation requires a DOM element to be associated to ${vm}.`);
|
|
1923
|
+
}
|
|
1924
|
+
const component = this;
|
|
1925
|
+
setPrototypeOf(elm, bridge.prototype);
|
|
1926
|
+
vm.component = this;
|
|
1927
|
+
// Locker hooks assignment. When the LWC engine run with Locker, Locker intercepts all the new
|
|
1928
|
+
// component creation and passes hooks to instrument all the component interactions with the
|
|
1929
|
+
// engine. We are intentionally hiding this argument from the formal API of LightningElement
|
|
1930
|
+
// because we don't want folks to know about it just yet.
|
|
1931
|
+
if (arguments.length === 1) {
|
|
1932
|
+
const { callHook, setHook, getHook } = arguments[0];
|
|
1933
|
+
vm.callHook = callHook;
|
|
1934
|
+
vm.setHook = setHook;
|
|
1935
|
+
vm.getHook = getHook;
|
|
2209
1936
|
}
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
cmpTemplate
|
|
2216
|
-
} = vm;
|
|
2217
|
-
// If the `cmpTemplate` is null, that means that the template has not been rendered yet. Most likely this occurs
|
|
2218
|
-
// if `this.refs` is called during the `connectedCallback` phase. The DOM elements have not been rendered yet,
|
|
2219
|
-
// so log a warning. Note we also check `isBeingConstructed()` to avoid a double warning (due to
|
|
2220
|
-
// `warnIfInvokedDuringConstruction` above).
|
|
2221
|
-
if (process.env.NODE_ENV !== 'production' && isNull(cmpTemplate) && !isBeingConstructed(vm)) {
|
|
2222
|
-
logError(`this.refs is undefined for ${getComponentTag(vm)}. This is either because the attached template has no "lwc:ref" directive, or this.refs was ` + `invoked before renderedCallback(). Use this.refs only when the referenced HTML elements have ` + `been rendered to the DOM, such as within renderedCallback() or disconnectedCallback().`);
|
|
2223
|
-
}
|
|
2224
|
-
// For backwards compatibility with component written before template refs
|
|
2225
|
-
// were introduced, we return undefined if the template has no refs defined
|
|
2226
|
-
// anywhere. This fixes components that may want to add an expando called `refs`
|
|
2227
|
-
// and are checking if it exists with `if (this.refs)` before adding it.
|
|
2228
|
-
// Note we use a null refVNodes to indicate that the template has no refs defined.
|
|
2229
|
-
if (isNull(refVNodes)) {
|
|
2230
|
-
return;
|
|
2231
|
-
}
|
|
2232
|
-
// The refNodes can be cached based on the refVNodes, since the refVNodes
|
|
2233
|
-
// are recreated from scratch every time the template is rendered.
|
|
2234
|
-
// This happens with `vm.refVNodes = null` in `template.ts` in `@lwc/engine-core`.
|
|
2235
|
-
let refs = refsCache.get(refVNodes);
|
|
2236
|
-
if (isUndefined$1(refs)) {
|
|
2237
|
-
refs = create(null);
|
|
2238
|
-
for (const key of keys(refVNodes)) {
|
|
2239
|
-
refs[key] = refVNodes[key].elm;
|
|
2240
|
-
}
|
|
2241
|
-
freeze(refs);
|
|
2242
|
-
refsCache.set(refVNodes, refs);
|
|
2243
|
-
}
|
|
2244
|
-
return refs;
|
|
2245
|
-
},
|
|
2246
|
-
// For backwards compat, we allow component authors to set `refs` as an expando
|
|
2247
|
-
set refs(value) {
|
|
2248
|
-
defineProperty(this, 'refs', {
|
|
2249
|
-
configurable: true,
|
|
2250
|
-
enumerable: true,
|
|
2251
|
-
writable: true,
|
|
2252
|
-
value
|
|
2253
|
-
});
|
|
2254
|
-
},
|
|
2255
|
-
get shadowRoot() {
|
|
2256
|
-
// From within the component instance, the shadowRoot is always reported as "closed".
|
|
2257
|
-
// Authors should rely on this.template instead.
|
|
2258
|
-
return null;
|
|
2259
|
-
},
|
|
2260
|
-
get children() {
|
|
2261
|
-
const vm = getAssociatedVM(this);
|
|
2262
|
-
const renderer = vm.renderer;
|
|
2263
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2264
|
-
warnIfInvokedDuringConstruction(vm, 'children');
|
|
1937
|
+
// Linking elm, shadow root and component with the VM.
|
|
1938
|
+
associateVM(component, vm);
|
|
1939
|
+
associateVM(elm, vm);
|
|
1940
|
+
if (vm.renderMode === 1 /* RenderMode.Shadow */) {
|
|
1941
|
+
vm.renderRoot = doAttachShadow(vm);
|
|
2265
1942
|
}
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
get childNodes() {
|
|
2269
|
-
const vm = getAssociatedVM(this);
|
|
2270
|
-
const renderer = vm.renderer;
|
|
2271
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2272
|
-
warnIfInvokedDuringConstruction(vm, 'childNodes');
|
|
1943
|
+
else {
|
|
1944
|
+
vm.renderRoot = elm;
|
|
2273
1945
|
}
|
|
2274
|
-
|
|
2275
|
-
},
|
|
2276
|
-
get firstChild() {
|
|
2277
|
-
const vm = getAssociatedVM(this);
|
|
2278
|
-
const renderer = vm.renderer;
|
|
1946
|
+
// Adding extra guard rails in DEV mode.
|
|
2279
1947
|
if (process.env.NODE_ENV !== 'production') {
|
|
2280
|
-
|
|
1948
|
+
patchCustomElementWithRestrictions(elm);
|
|
1949
|
+
patchComponentWithRestrictions(component);
|
|
2281
1950
|
}
|
|
2282
|
-
return
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
const
|
|
2286
|
-
const
|
|
1951
|
+
return this;
|
|
1952
|
+
};
|
|
1953
|
+
function doAttachShadow(vm) {
|
|
1954
|
+
const { elm, mode, shadowMode, def: { ctor }, renderer: { attachShadow }, } = vm;
|
|
1955
|
+
const shadowRoot = attachShadow(elm, {
|
|
1956
|
+
[KEY__SYNTHETIC_MODE]: shadowMode === 1 /* ShadowMode.Synthetic */,
|
|
1957
|
+
delegatesFocus: Boolean(ctor.delegatesFocus),
|
|
1958
|
+
mode,
|
|
1959
|
+
});
|
|
1960
|
+
vm.shadowRoot = shadowRoot;
|
|
1961
|
+
associateVM(shadowRoot, vm);
|
|
2287
1962
|
if (process.env.NODE_ENV !== 'production') {
|
|
2288
|
-
|
|
1963
|
+
patchShadowRootWithRestrictions(shadowRoot);
|
|
2289
1964
|
}
|
|
2290
|
-
return
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2296
|
-
warnIfInvokedDuringConstruction(vm, 'lastChild');
|
|
1965
|
+
return shadowRoot;
|
|
1966
|
+
}
|
|
1967
|
+
function warnIfInvokedDuringConstruction(vm, methodOrPropName) {
|
|
1968
|
+
if (isBeingConstructed(vm)) {
|
|
1969
|
+
logError(`this.${methodOrPropName} should not be called during the construction of the custom element for ${getComponentTag(vm)} because the element is not yet in the DOM or has no children yet.`);
|
|
2297
1970
|
}
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
1971
|
+
}
|
|
1972
|
+
// @ts-ignore
|
|
1973
|
+
LightningElement.prototype = {
|
|
1974
|
+
constructor: LightningElement,
|
|
1975
|
+
dispatchEvent(event) {
|
|
1976
|
+
const vm = getAssociatedVM(this);
|
|
1977
|
+
const { elm, renderer: { dispatchEvent }, } = vm;
|
|
1978
|
+
return dispatchEvent(elm, event);
|
|
1979
|
+
},
|
|
1980
|
+
addEventListener(type, listener, options) {
|
|
1981
|
+
const vm = getAssociatedVM(this);
|
|
1982
|
+
const { elm, renderer: { addEventListener }, } = vm;
|
|
1983
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1984
|
+
const vmBeingRendered = getVMBeingRendered();
|
|
1985
|
+
assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm} by adding an event listener for "${type}".`);
|
|
1986
|
+
assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm} by adding an event listener for "${type}".`);
|
|
1987
|
+
assert.invariant(isFunction$1(listener), `Invalid second argument for this.addEventListener() in ${vm} for event "${type}". Expected an EventListener but received ${listener}.`);
|
|
1988
|
+
}
|
|
1989
|
+
const wrappedListener = getWrappedComponentsListener(vm, listener);
|
|
1990
|
+
addEventListener(elm, type, wrappedListener, options);
|
|
1991
|
+
},
|
|
1992
|
+
removeEventListener(type, listener, options) {
|
|
1993
|
+
const vm = getAssociatedVM(this);
|
|
1994
|
+
const { elm, renderer: { removeEventListener }, } = vm;
|
|
1995
|
+
const wrappedListener = getWrappedComponentsListener(vm, listener);
|
|
1996
|
+
removeEventListener(elm, type, wrappedListener, options);
|
|
1997
|
+
},
|
|
1998
|
+
hasAttribute(name) {
|
|
1999
|
+
const vm = getAssociatedVM(this);
|
|
2000
|
+
const { elm, renderer: { getAttribute }, } = vm;
|
|
2001
|
+
return !isNull(getAttribute(elm, name));
|
|
2002
|
+
},
|
|
2003
|
+
hasAttributeNS(namespace, name) {
|
|
2004
|
+
const vm = getAssociatedVM(this);
|
|
2005
|
+
const { elm, renderer: { getAttribute }, } = vm;
|
|
2006
|
+
return !isNull(getAttribute(elm, name, namespace));
|
|
2007
|
+
},
|
|
2008
|
+
removeAttribute(name) {
|
|
2009
|
+
const vm = getAssociatedVM(this);
|
|
2010
|
+
const { elm, renderer: { removeAttribute }, } = vm;
|
|
2011
|
+
unlockAttribute(elm, name);
|
|
2012
|
+
removeAttribute(elm, name);
|
|
2013
|
+
lockAttribute();
|
|
2014
|
+
},
|
|
2015
|
+
removeAttributeNS(namespace, name) {
|
|
2016
|
+
const { elm, renderer: { removeAttribute }, } = getAssociatedVM(this);
|
|
2017
|
+
unlockAttribute(elm, name);
|
|
2018
|
+
removeAttribute(elm, name, namespace);
|
|
2019
|
+
lockAttribute();
|
|
2020
|
+
},
|
|
2021
|
+
getAttribute(name) {
|
|
2022
|
+
const vm = getAssociatedVM(this);
|
|
2023
|
+
const { elm } = vm;
|
|
2024
|
+
const { getAttribute } = vm.renderer;
|
|
2025
|
+
return getAttribute(elm, name);
|
|
2026
|
+
},
|
|
2027
|
+
getAttributeNS(namespace, name) {
|
|
2028
|
+
const vm = getAssociatedVM(this);
|
|
2029
|
+
const { elm } = vm;
|
|
2030
|
+
const { getAttribute } = vm.renderer;
|
|
2031
|
+
return getAttribute(elm, name, namespace);
|
|
2032
|
+
},
|
|
2033
|
+
setAttribute(name, value) {
|
|
2034
|
+
const vm = getAssociatedVM(this);
|
|
2035
|
+
const { elm, renderer: { setAttribute }, } = vm;
|
|
2036
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2037
|
+
assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
|
|
2038
|
+
}
|
|
2039
|
+
unlockAttribute(elm, name);
|
|
2040
|
+
setAttribute(elm, name, value);
|
|
2041
|
+
lockAttribute();
|
|
2042
|
+
},
|
|
2043
|
+
setAttributeNS(namespace, name, value) {
|
|
2044
|
+
const vm = getAssociatedVM(this);
|
|
2045
|
+
const { elm, renderer: { setAttribute }, } = vm;
|
|
2046
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2047
|
+
assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
|
|
2048
|
+
}
|
|
2049
|
+
unlockAttribute(elm, name);
|
|
2050
|
+
setAttribute(elm, name, value, namespace);
|
|
2051
|
+
lockAttribute();
|
|
2052
|
+
},
|
|
2053
|
+
getBoundingClientRect() {
|
|
2054
|
+
const vm = getAssociatedVM(this);
|
|
2055
|
+
const { elm, renderer: { getBoundingClientRect }, } = vm;
|
|
2056
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2057
|
+
warnIfInvokedDuringConstruction(vm, 'getBoundingClientRect()');
|
|
2058
|
+
}
|
|
2059
|
+
return getBoundingClientRect(elm);
|
|
2060
|
+
},
|
|
2061
|
+
get isConnected() {
|
|
2062
|
+
const vm = getAssociatedVM(this);
|
|
2063
|
+
const { elm, renderer: { isConnected }, } = vm;
|
|
2064
|
+
return isConnected(elm);
|
|
2065
|
+
},
|
|
2066
|
+
get classList() {
|
|
2067
|
+
const vm = getAssociatedVM(this);
|
|
2068
|
+
const { elm, renderer: { getClassList }, } = vm;
|
|
2069
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2070
|
+
// TODO [#1290]: this still fails in dev but works in production, eventually, we should
|
|
2071
|
+
// just throw in all modes
|
|
2072
|
+
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.`);
|
|
2073
|
+
}
|
|
2074
|
+
return getClassList(elm);
|
|
2075
|
+
},
|
|
2076
|
+
get template() {
|
|
2077
|
+
const vm = getAssociatedVM(this);
|
|
2078
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2079
|
+
if (vm.renderMode === 0 /* RenderMode.Light */) {
|
|
2080
|
+
logError('`this.template` returns null for light DOM components. Since there is no shadow, the rendered content can be accessed via `this` itself. e.g. instead of `this.template.querySelector`, use `this.querySelector`.');
|
|
2081
|
+
}
|
|
2082
|
+
}
|
|
2083
|
+
return vm.shadowRoot;
|
|
2084
|
+
},
|
|
2085
|
+
get refs() {
|
|
2086
|
+
const vm = getAssociatedVM(this);
|
|
2087
|
+
if (isUpdatingTemplate) {
|
|
2088
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2089
|
+
logError(`this.refs should not be called while ${getComponentTag(vm)} is rendering. Use this.refs only when the DOM is stable, e.g. in renderedCallback().`);
|
|
2090
|
+
}
|
|
2091
|
+
// If the template is in the process of being updated, then we don't want to go through the normal
|
|
2092
|
+
// process of returning the refs and caching them, because the state of the refs is unstable.
|
|
2093
|
+
// This can happen if e.g. a template contains `<div class={foo}></div>` and `foo` is computed
|
|
2094
|
+
// based on `this.refs.bar`.
|
|
2095
|
+
return;
|
|
2096
|
+
}
|
|
2097
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2098
|
+
warnIfInvokedDuringConstruction(vm, 'refs');
|
|
2099
|
+
}
|
|
2100
|
+
const { refVNodes, cmpTemplate } = vm;
|
|
2101
|
+
// If the `cmpTemplate` is null, that means that the template has not been rendered yet. Most likely this occurs
|
|
2102
|
+
// if `this.refs` is called during the `connectedCallback` phase. The DOM elements have not been rendered yet,
|
|
2103
|
+
// so log a warning. Note we also check `isBeingConstructed()` to avoid a double warning (due to
|
|
2104
|
+
// `warnIfInvokedDuringConstruction` above).
|
|
2105
|
+
if (process.env.NODE_ENV !== 'production' &&
|
|
2106
|
+
isNull(cmpTemplate) &&
|
|
2107
|
+
!isBeingConstructed(vm)) {
|
|
2108
|
+
logError(`this.refs is undefined for ${getComponentTag(vm)}. This is either because the attached template has no "lwc:ref" directive, or this.refs was ` +
|
|
2109
|
+
`invoked before renderedCallback(). Use this.refs only when the referenced HTML elements have ` +
|
|
2110
|
+
`been rendered to the DOM, such as within renderedCallback() or disconnectedCallback().`);
|
|
2111
|
+
}
|
|
2112
|
+
// For backwards compatibility with component written before template refs
|
|
2113
|
+
// were introduced, we return undefined if the template has no refs defined
|
|
2114
|
+
// anywhere. This fixes components that may want to add an expando called `refs`
|
|
2115
|
+
// and are checking if it exists with `if (this.refs)` before adding it.
|
|
2116
|
+
// Note we use a null refVNodes to indicate that the template has no refs defined.
|
|
2117
|
+
if (isNull(refVNodes)) {
|
|
2118
|
+
return;
|
|
2119
|
+
}
|
|
2120
|
+
// The refNodes can be cached based on the refVNodes, since the refVNodes
|
|
2121
|
+
// are recreated from scratch every time the template is rendered.
|
|
2122
|
+
// This happens with `vm.refVNodes = null` in `template.ts` in `@lwc/engine-core`.
|
|
2123
|
+
let refs = refsCache.get(refVNodes);
|
|
2124
|
+
if (isUndefined$1(refs)) {
|
|
2125
|
+
refs = create(null);
|
|
2126
|
+
for (const key of keys(refVNodes)) {
|
|
2127
|
+
refs[key] = refVNodes[key].elm;
|
|
2128
|
+
}
|
|
2129
|
+
freeze(refs);
|
|
2130
|
+
refsCache.set(refVNodes, refs);
|
|
2131
|
+
}
|
|
2132
|
+
return refs;
|
|
2133
|
+
},
|
|
2134
|
+
// For backwards compat, we allow component authors to set `refs` as an expando
|
|
2135
|
+
set refs(value) {
|
|
2136
|
+
defineProperty(this, 'refs', {
|
|
2137
|
+
configurable: true,
|
|
2138
|
+
enumerable: true,
|
|
2139
|
+
writable: true,
|
|
2140
|
+
value,
|
|
2141
|
+
});
|
|
2142
|
+
},
|
|
2143
|
+
get shadowRoot() {
|
|
2144
|
+
// From within the component instance, the shadowRoot is always reported as "closed".
|
|
2145
|
+
// Authors should rely on this.template instead.
|
|
2146
|
+
return null;
|
|
2147
|
+
},
|
|
2148
|
+
get children() {
|
|
2149
|
+
const vm = getAssociatedVM(this);
|
|
2150
|
+
const renderer = vm.renderer;
|
|
2151
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2152
|
+
warnIfInvokedDuringConstruction(vm, 'children');
|
|
2153
|
+
}
|
|
2154
|
+
return renderer.getChildren(vm.elm);
|
|
2155
|
+
},
|
|
2156
|
+
get childNodes() {
|
|
2157
|
+
const vm = getAssociatedVM(this);
|
|
2158
|
+
const renderer = vm.renderer;
|
|
2159
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2160
|
+
warnIfInvokedDuringConstruction(vm, 'childNodes');
|
|
2161
|
+
}
|
|
2162
|
+
return renderer.getChildNodes(vm.elm);
|
|
2163
|
+
},
|
|
2164
|
+
get firstChild() {
|
|
2165
|
+
const vm = getAssociatedVM(this);
|
|
2166
|
+
const renderer = vm.renderer;
|
|
2167
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2168
|
+
warnIfInvokedDuringConstruction(vm, 'firstChild');
|
|
2169
|
+
}
|
|
2170
|
+
return renderer.getFirstChild(vm.elm);
|
|
2171
|
+
},
|
|
2172
|
+
get firstElementChild() {
|
|
2173
|
+
const vm = getAssociatedVM(this);
|
|
2174
|
+
const renderer = vm.renderer;
|
|
2175
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2176
|
+
warnIfInvokedDuringConstruction(vm, 'firstElementChild');
|
|
2177
|
+
}
|
|
2178
|
+
return renderer.getFirstElementChild(vm.elm);
|
|
2179
|
+
},
|
|
2180
|
+
get lastChild() {
|
|
2181
|
+
const vm = getAssociatedVM(this);
|
|
2182
|
+
const renderer = vm.renderer;
|
|
2183
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2184
|
+
warnIfInvokedDuringConstruction(vm, 'lastChild');
|
|
2185
|
+
}
|
|
2186
|
+
return renderer.getLastChild(vm.elm);
|
|
2187
|
+
},
|
|
2188
|
+
get lastElementChild() {
|
|
2189
|
+
const vm = getAssociatedVM(this);
|
|
2190
|
+
const renderer = vm.renderer;
|
|
2191
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2192
|
+
warnIfInvokedDuringConstruction(vm, 'lastElementChild');
|
|
2193
|
+
}
|
|
2194
|
+
return renderer.getLastElementChild(vm.elm);
|
|
2195
|
+
},
|
|
2196
|
+
render() {
|
|
2197
|
+
const vm = getAssociatedVM(this);
|
|
2198
|
+
return vm.def.template;
|
|
2199
|
+
},
|
|
2200
|
+
toString() {
|
|
2201
|
+
const vm = getAssociatedVM(this);
|
|
2202
|
+
return `[object ${vm.def.name}]`;
|
|
2203
|
+
},
|
|
2316
2204
|
};
|
|
2317
2205
|
const queryAndChildGetterDescriptors = create(null);
|
|
2318
|
-
const queryMethods = [
|
|
2206
|
+
const queryMethods = [
|
|
2207
|
+
'getElementsByClassName',
|
|
2208
|
+
'getElementsByTagName',
|
|
2209
|
+
'querySelector',
|
|
2210
|
+
'querySelectorAll',
|
|
2211
|
+
];
|
|
2319
2212
|
// Generic passthrough for query APIs on HTMLElement to the relevant Renderer APIs
|
|
2320
2213
|
for (const queryMethod of queryMethods) {
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
enumerable: true,
|
|
2335
|
-
writable: true
|
|
2336
|
-
};
|
|
2214
|
+
queryAndChildGetterDescriptors[queryMethod] = {
|
|
2215
|
+
value(arg) {
|
|
2216
|
+
const vm = getAssociatedVM(this);
|
|
2217
|
+
const { elm, renderer } = vm;
|
|
2218
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2219
|
+
warnIfInvokedDuringConstruction(vm, `${queryMethod}()`);
|
|
2220
|
+
}
|
|
2221
|
+
return renderer[queryMethod](elm, arg);
|
|
2222
|
+
},
|
|
2223
|
+
configurable: true,
|
|
2224
|
+
enumerable: true,
|
|
2225
|
+
writable: true,
|
|
2226
|
+
};
|
|
2337
2227
|
}
|
|
2338
2228
|
defineProperties(LightningElement.prototype, queryAndChildGetterDescriptors);
|
|
2339
2229
|
const lightningBasedDescriptors = create(null);
|
|
2340
2230
|
for (const propName in HTMLElementOriginalDescriptors) {
|
|
2341
|
-
|
|
2231
|
+
lightningBasedDescriptors[propName] = createBridgeToElementDescriptor(propName, HTMLElementOriginalDescriptors[propName]);
|
|
2342
2232
|
}
|
|
2343
2233
|
defineProperties(LightningElement.prototype, lightningBasedDescriptors);
|
|
2344
2234
|
function applyAriaReflectionToLightningElement() {
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
}
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
if (lwcRuntimeFlags.DISABLE_ARIA_REFLECTION_POLYFILL) {
|
|
2353
|
-
applyAriaReflectionToLightningElement();
|
|
2354
|
-
} else {
|
|
2355
|
-
applyAriaReflectionToLightningElement();
|
|
2235
|
+
// If ARIA reflection is not applied globally to Element.prototype, or if we are running server-side,
|
|
2236
|
+
// apply it to LightningElement.prototype.
|
|
2237
|
+
// This allows `this.aria*` property accessors to work from inside a component, and to reflect `aria-*` attrs.
|
|
2238
|
+
applyAriaReflection(LightningElement.prototype);
|
|
2239
|
+
}
|
|
2240
|
+
{
|
|
2241
|
+
applyAriaReflectionToLightningElement();
|
|
2356
2242
|
}
|
|
2357
2243
|
defineProperty(LightningElement, 'CustomElementConstructor', {
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2244
|
+
get() {
|
|
2245
|
+
// If required, a runtime-specific implementation must be defined.
|
|
2246
|
+
throw new ReferenceError('The current runtime does not support CustomElementConstructor.');
|
|
2247
|
+
},
|
|
2248
|
+
configurable: true,
|
|
2363
2249
|
});
|
|
2364
2250
|
if (process.env.NODE_ENV !== 'production') {
|
|
2365
|
-
|
|
2251
|
+
patchLightningElementPrototypeWithRestrictions(LightningElement.prototype);
|
|
2366
2252
|
}
|
|
2367
2253
|
|
|
2368
2254
|
function createObservedFieldPropertyDescriptor(key) {
|
|
@@ -2391,268 +2277,234 @@ const DeprecatedWiredParamsMeta = '$$DeprecatedWiredParamsMetaKey$$';
|
|
|
2391
2277
|
const WIRE_DEBUG_ENTRY = '@wire';
|
|
2392
2278
|
const WireMetaMap = new Map();
|
|
2393
2279
|
class WireContextRegistrationEvent extends CustomEvent {
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
}
|
|
2409
|
-
});
|
|
2410
|
-
}
|
|
2280
|
+
constructor(adapterToken, { setNewContext, setDisconnectedCallback }) {
|
|
2281
|
+
super(adapterToken, {
|
|
2282
|
+
bubbles: true,
|
|
2283
|
+
composed: true,
|
|
2284
|
+
});
|
|
2285
|
+
defineProperties(this, {
|
|
2286
|
+
setNewContext: {
|
|
2287
|
+
value: setNewContext,
|
|
2288
|
+
},
|
|
2289
|
+
setDisconnectedCallback: {
|
|
2290
|
+
value: setDisconnectedCallback,
|
|
2291
|
+
},
|
|
2292
|
+
});
|
|
2293
|
+
}
|
|
2411
2294
|
}
|
|
2412
2295
|
function createFieldDataCallback(vm, name) {
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2296
|
+
return (value) => {
|
|
2297
|
+
updateComponentValue(vm, name, value);
|
|
2298
|
+
};
|
|
2416
2299
|
}
|
|
2417
2300
|
function createMethodDataCallback(vm, method) {
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2301
|
+
return (value) => {
|
|
2302
|
+
// dispatching new value into the wired method
|
|
2303
|
+
runWithBoundaryProtection(vm, vm.owner, noop, () => {
|
|
2304
|
+
// job
|
|
2305
|
+
method.call(vm.component, value);
|
|
2306
|
+
}, noop);
|
|
2307
|
+
};
|
|
2425
2308
|
}
|
|
2426
2309
|
function createConfigWatcher(component, configCallback, callbackWhenConfigIsReady) {
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2310
|
+
// creating the reactive observer for reactive params when needed
|
|
2311
|
+
const ro = createReactiveObserver();
|
|
2312
|
+
const computeConfigAndUpdate = () => {
|
|
2313
|
+
let config;
|
|
2314
|
+
ro.observe(() => (config = configCallback(component)));
|
|
2315
|
+
// eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo
|
|
2316
|
+
// TODO: dev-mode validation of config based on the adapter.configSchema
|
|
2317
|
+
// @ts-ignore it is assigned in the observe() callback
|
|
2318
|
+
callbackWhenConfigIsReady(config);
|
|
2319
|
+
};
|
|
2320
|
+
return {
|
|
2321
|
+
computeConfigAndUpdate,
|
|
2322
|
+
ro,
|
|
2323
|
+
};
|
|
2441
2324
|
}
|
|
2442
2325
|
function createContextWatcher(vm, wireDef, callbackWhenContextIsReady) {
|
|
2443
|
-
|
|
2444
|
-
adapter
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
setNewContext(newContext) {
|
|
2470
|
-
// eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo
|
|
2471
|
-
// TODO: dev-mode validation of config based on the adapter.contextSchema
|
|
2472
|
-
callbackWhenContextIsReady(newContext);
|
|
2473
|
-
},
|
|
2474
|
-
setDisconnectedCallback(disconnectCallback) {
|
|
2475
|
-
// adds this callback into the disconnect bucket so it gets disconnected from parent
|
|
2476
|
-
// the the element hosting the wire is disconnected
|
|
2477
|
-
ArrayPush$1.call(wiredDisconnecting, disconnectCallback);
|
|
2478
|
-
}
|
|
2326
|
+
const { adapter } = wireDef;
|
|
2327
|
+
const adapterContextToken = getAdapterToken(adapter);
|
|
2328
|
+
if (isUndefined$1(adapterContextToken)) {
|
|
2329
|
+
return; // no provider found, nothing to be done
|
|
2330
|
+
}
|
|
2331
|
+
const { elm, context: { wiredConnecting, wiredDisconnecting }, renderer: { dispatchEvent }, } = vm;
|
|
2332
|
+
// waiting for the component to be connected to formally request the context via the token
|
|
2333
|
+
ArrayPush$1.call(wiredConnecting, () => {
|
|
2334
|
+
// This event is responsible for connecting the host element with another
|
|
2335
|
+
// element in the composed path that is providing contextual data. The provider
|
|
2336
|
+
// must be listening for a special dom event with the name corresponding to the value of
|
|
2337
|
+
// `adapterContextToken`, which will remain secret and internal to this file only to
|
|
2338
|
+
// guarantee that the linkage can be forged.
|
|
2339
|
+
const contextRegistrationEvent = new WireContextRegistrationEvent(adapterContextToken, {
|
|
2340
|
+
setNewContext(newContext) {
|
|
2341
|
+
// eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo
|
|
2342
|
+
// TODO: dev-mode validation of config based on the adapter.contextSchema
|
|
2343
|
+
callbackWhenContextIsReady(newContext);
|
|
2344
|
+
},
|
|
2345
|
+
setDisconnectedCallback(disconnectCallback) {
|
|
2346
|
+
// adds this callback into the disconnect bucket so it gets disconnected from parent
|
|
2347
|
+
// the the element hosting the wire is disconnected
|
|
2348
|
+
ArrayPush$1.call(wiredDisconnecting, disconnectCallback);
|
|
2349
|
+
},
|
|
2350
|
+
});
|
|
2351
|
+
dispatchEvent(elm, contextRegistrationEvent);
|
|
2479
2352
|
});
|
|
2480
|
-
dispatchEvent(elm, contextRegistrationEvent);
|
|
2481
|
-
});
|
|
2482
2353
|
}
|
|
2483
2354
|
function createConnector(vm, name, wireDef) {
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
adapter,
|
|
2487
|
-
configCallback,
|
|
2488
|
-
dynamic
|
|
2489
|
-
} = wireDef;
|
|
2490
|
-
let debugInfo;
|
|
2491
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2492
|
-
const wiredPropOrMethod = isUndefined$1(method) ? name : method.name;
|
|
2493
|
-
debugInfo = create(null);
|
|
2494
|
-
debugInfo.wasDataProvisionedForConfig = false;
|
|
2495
|
-
vm.debugInfo[WIRE_DEBUG_ENTRY][wiredPropOrMethod] = debugInfo;
|
|
2496
|
-
}
|
|
2497
|
-
const fieldOrMethodCallback = isUndefined$1(method) ? createFieldDataCallback(vm, name) : createMethodDataCallback(vm, method);
|
|
2498
|
-
const dataCallback = value => {
|
|
2355
|
+
const { method, adapter, configCallback, dynamic } = wireDef;
|
|
2356
|
+
let debugInfo;
|
|
2499
2357
|
if (process.env.NODE_ENV !== 'production') {
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
// some conditions in which it does not, ex:
|
|
2503
|
-
// race conditions in a poor network while the adapter does not cancel a previous request.
|
|
2504
|
-
debugInfo.wasDataProvisionedForConfig = true;
|
|
2505
|
-
}
|
|
2506
|
-
fieldOrMethodCallback(value);
|
|
2507
|
-
};
|
|
2508
|
-
let context;
|
|
2509
|
-
let connector;
|
|
2510
|
-
// Workaround to pass the component element associated to this wire adapter instance.
|
|
2511
|
-
defineProperty(dataCallback, DeprecatedWiredElementHost, {
|
|
2512
|
-
value: vm.elm
|
|
2513
|
-
});
|
|
2514
|
-
defineProperty(dataCallback, DeprecatedWiredParamsMeta, {
|
|
2515
|
-
value: dynamic
|
|
2516
|
-
});
|
|
2517
|
-
runWithBoundaryProtection(vm, vm, noop, () => {
|
|
2518
|
-
// job
|
|
2519
|
-
connector = new adapter(dataCallback);
|
|
2520
|
-
}, noop);
|
|
2521
|
-
const updateConnectorConfig = config => {
|
|
2522
|
-
// every time the config is recomputed due to tracking,
|
|
2523
|
-
// this callback will be invoked with the new computed config
|
|
2524
|
-
runWithBoundaryProtection(vm, vm, noop, () => {
|
|
2525
|
-
// job
|
|
2526
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2527
|
-
debugInfo.config = config;
|
|
2528
|
-
debugInfo.context = context;
|
|
2358
|
+
const wiredPropOrMethod = isUndefined$1(method) ? name : method.name;
|
|
2359
|
+
debugInfo = create(null);
|
|
2529
2360
|
debugInfo.wasDataProvisionedForConfig = false;
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
}
|
|
2361
|
+
vm.debugInfo[WIRE_DEBUG_ENTRY][wiredPropOrMethod] = debugInfo;
|
|
2362
|
+
}
|
|
2363
|
+
const fieldOrMethodCallback = isUndefined$1(method)
|
|
2364
|
+
? createFieldDataCallback(vm, name)
|
|
2365
|
+
: createMethodDataCallback(vm, method);
|
|
2366
|
+
const dataCallback = (value) => {
|
|
2367
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2368
|
+
debugInfo.data = value;
|
|
2369
|
+
// Note: most of the time, the data provided is for the current config, but there may be
|
|
2370
|
+
// some conditions in which it does not, ex:
|
|
2371
|
+
// race conditions in a poor network while the adapter does not cancel a previous request.
|
|
2372
|
+
debugInfo.wasDataProvisionedForConfig = true;
|
|
2373
|
+
}
|
|
2374
|
+
fieldOrMethodCallback(value);
|
|
2375
|
+
};
|
|
2376
|
+
let context;
|
|
2377
|
+
let connector;
|
|
2378
|
+
// Workaround to pass the component element associated to this wire adapter instance.
|
|
2379
|
+
defineProperty(dataCallback, DeprecatedWiredElementHost, {
|
|
2380
|
+
value: vm.elm,
|
|
2381
|
+
});
|
|
2382
|
+
defineProperty(dataCallback, DeprecatedWiredParamsMeta, {
|
|
2383
|
+
value: dynamic,
|
|
2554
2384
|
});
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2385
|
+
runWithBoundaryProtection(vm, vm, noop, () => {
|
|
2386
|
+
// job
|
|
2387
|
+
connector = new adapter(dataCallback);
|
|
2388
|
+
}, noop);
|
|
2389
|
+
const updateConnectorConfig = (config) => {
|
|
2390
|
+
// every time the config is recomputed due to tracking,
|
|
2391
|
+
// this callback will be invoked with the new computed config
|
|
2392
|
+
runWithBoundaryProtection(vm, vm, noop, () => {
|
|
2393
|
+
// job
|
|
2394
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2395
|
+
debugInfo.config = config;
|
|
2396
|
+
debugInfo.context = context;
|
|
2397
|
+
debugInfo.wasDataProvisionedForConfig = false;
|
|
2398
|
+
}
|
|
2399
|
+
connector.update(config, context);
|
|
2400
|
+
}, noop);
|
|
2401
|
+
};
|
|
2402
|
+
// Computes the current wire config and calls the update method on the wire adapter.
|
|
2403
|
+
// If it has params, we will need to observe changes in the next tick.
|
|
2404
|
+
const { computeConfigAndUpdate, ro } = createConfigWatcher(vm.component, configCallback, updateConnectorConfig);
|
|
2405
|
+
// if the adapter needs contextualization, we need to watch for new context and push it alongside the config
|
|
2406
|
+
if (!isUndefined$1(adapter.contextSchema)) {
|
|
2407
|
+
createContextWatcher(vm, wireDef, (newContext) => {
|
|
2408
|
+
// every time the context is pushed into this component,
|
|
2409
|
+
// this callback will be invoked with the new computed context
|
|
2410
|
+
if (context !== newContext) {
|
|
2411
|
+
context = newContext;
|
|
2412
|
+
// Note: when new context arrives, the config will be recomputed and pushed along side the new
|
|
2413
|
+
// context, this is to preserve the identity characteristics, config should not have identity
|
|
2414
|
+
// (ever), while context can have identity
|
|
2415
|
+
if (vm.state === 1 /* VMState.connected */) {
|
|
2416
|
+
computeConfigAndUpdate();
|
|
2417
|
+
}
|
|
2418
|
+
}
|
|
2419
|
+
});
|
|
2420
|
+
}
|
|
2421
|
+
return {
|
|
2422
|
+
// @ts-ignore the boundary protection executes sync, connector is always defined
|
|
2423
|
+
connector,
|
|
2424
|
+
computeConfigAndUpdate,
|
|
2425
|
+
resetConfigWatcher: () => ro.reset(),
|
|
2426
|
+
};
|
|
2562
2427
|
}
|
|
2563
2428
|
const AdapterToTokenMap = new Map();
|
|
2564
2429
|
function getAdapterToken(adapter) {
|
|
2565
|
-
|
|
2430
|
+
return AdapterToTokenMap.get(adapter);
|
|
2566
2431
|
}
|
|
2567
2432
|
function setAdapterToken(adapter, token) {
|
|
2568
|
-
|
|
2433
|
+
AdapterToTokenMap.set(adapter, token);
|
|
2569
2434
|
}
|
|
2570
2435
|
function storeWiredMethodMeta(descriptor, adapter, configCallback, dynamic) {
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2436
|
+
// support for callable adapters
|
|
2437
|
+
if (adapter.adapter) {
|
|
2438
|
+
adapter = adapter.adapter;
|
|
2439
|
+
}
|
|
2440
|
+
const method = descriptor.value;
|
|
2441
|
+
const def = {
|
|
2442
|
+
adapter,
|
|
2443
|
+
method,
|
|
2444
|
+
configCallback,
|
|
2445
|
+
dynamic,
|
|
2446
|
+
};
|
|
2447
|
+
WireMetaMap.set(descriptor, def);
|
|
2583
2448
|
}
|
|
2584
2449
|
function storeWiredFieldMeta(descriptor, adapter, configCallback, dynamic) {
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2450
|
+
// support for callable adapters
|
|
2451
|
+
if (adapter.adapter) {
|
|
2452
|
+
adapter = adapter.adapter;
|
|
2453
|
+
}
|
|
2454
|
+
const def = {
|
|
2455
|
+
adapter,
|
|
2456
|
+
configCallback,
|
|
2457
|
+
dynamic,
|
|
2458
|
+
};
|
|
2459
|
+
WireMetaMap.set(descriptor, def);
|
|
2595
2460
|
}
|
|
2596
2461
|
function installWireAdapters(vm) {
|
|
2597
|
-
|
|
2598
|
-
context,
|
|
2599
|
-
def: {
|
|
2600
|
-
wire
|
|
2601
|
-
}
|
|
2602
|
-
} = vm;
|
|
2603
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2604
|
-
vm.debugInfo[WIRE_DEBUG_ENTRY] = create(null);
|
|
2605
|
-
}
|
|
2606
|
-
const wiredConnecting = context.wiredConnecting = [];
|
|
2607
|
-
const wiredDisconnecting = context.wiredDisconnecting = [];
|
|
2608
|
-
for (const fieldNameOrMethod in wire) {
|
|
2609
|
-
const descriptor = wire[fieldNameOrMethod];
|
|
2610
|
-
const wireDef = WireMetaMap.get(descriptor);
|
|
2462
|
+
const { context, def: { wire }, } = vm;
|
|
2611
2463
|
if (process.env.NODE_ENV !== 'production') {
|
|
2612
|
-
|
|
2464
|
+
vm.debugInfo[WIRE_DEBUG_ENTRY] = create(null);
|
|
2613
2465
|
}
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2466
|
+
const wiredConnecting = (context.wiredConnecting = []);
|
|
2467
|
+
const wiredDisconnecting = (context.wiredDisconnecting = []);
|
|
2468
|
+
for (const fieldNameOrMethod in wire) {
|
|
2469
|
+
const descriptor = wire[fieldNameOrMethod];
|
|
2470
|
+
const wireDef = WireMetaMap.get(descriptor);
|
|
2471
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2472
|
+
assert.invariant(wireDef, `Internal Error: invalid wire definition found.`);
|
|
2473
|
+
}
|
|
2474
|
+
if (!isUndefined$1(wireDef)) {
|
|
2475
|
+
const { connector, computeConfigAndUpdate, resetConfigWatcher } = createConnector(vm, fieldNameOrMethod, wireDef);
|
|
2476
|
+
const hasDynamicParams = wireDef.dynamic.length > 0;
|
|
2477
|
+
ArrayPush$1.call(wiredConnecting, () => {
|
|
2478
|
+
connector.connect();
|
|
2479
|
+
if (!lwcRuntimeFlags.ENABLE_WIRE_SYNC_EMIT) {
|
|
2480
|
+
if (hasDynamicParams) {
|
|
2481
|
+
Promise.resolve().then(computeConfigAndUpdate);
|
|
2482
|
+
return;
|
|
2483
|
+
}
|
|
2484
|
+
}
|
|
2485
|
+
computeConfigAndUpdate();
|
|
2486
|
+
});
|
|
2487
|
+
ArrayPush$1.call(wiredDisconnecting, () => {
|
|
2488
|
+
connector.disconnect();
|
|
2489
|
+
resetConfigWatcher();
|
|
2490
|
+
});
|
|
2628
2491
|
}
|
|
2629
|
-
computeConfigAndUpdate();
|
|
2630
|
-
});
|
|
2631
|
-
ArrayPush$1.call(wiredDisconnecting, () => {
|
|
2632
|
-
connector.disconnect();
|
|
2633
|
-
resetConfigWatcher();
|
|
2634
|
-
});
|
|
2635
2492
|
}
|
|
2636
|
-
}
|
|
2637
2493
|
}
|
|
2638
2494
|
function connectWireAdapters(vm) {
|
|
2639
|
-
|
|
2640
|
-
wiredConnecting
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
wiredConnecting[i]();
|
|
2644
|
-
}
|
|
2495
|
+
const { wiredConnecting } = vm.context;
|
|
2496
|
+
for (let i = 0, len = wiredConnecting.length; i < len; i += 1) {
|
|
2497
|
+
wiredConnecting[i]();
|
|
2498
|
+
}
|
|
2645
2499
|
}
|
|
2646
2500
|
function disconnectWireAdapters(vm) {
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
}
|
|
2655
|
-
}, noop);
|
|
2501
|
+
const { wiredDisconnecting } = vm.context;
|
|
2502
|
+
runWithBoundaryProtection(vm, vm, noop, () => {
|
|
2503
|
+
// job
|
|
2504
|
+
for (let i = 0, len = wiredDisconnecting.length; i < len; i += 1) {
|
|
2505
|
+
wiredDisconnecting[i]();
|
|
2506
|
+
}
|
|
2507
|
+
}, noop);
|
|
2656
2508
|
}
|
|
2657
2509
|
|
|
2658
2510
|
/*
|
|
@@ -3092,145 +2944,136 @@ function sanitizeAttribute(tagName, namespaceUri, attrName, attrValue) {
|
|
|
3092
2944
|
const cachedGetterByKey = create(null);
|
|
3093
2945
|
const cachedSetterByKey = create(null);
|
|
3094
2946
|
function createGetter(key) {
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
}
|
|
3105
|
-
return fn;
|
|
2947
|
+
let fn = cachedGetterByKey[key];
|
|
2948
|
+
if (isUndefined$1(fn)) {
|
|
2949
|
+
fn = cachedGetterByKey[key] = function () {
|
|
2950
|
+
const vm = getAssociatedVM(this);
|
|
2951
|
+
const { getHook } = vm;
|
|
2952
|
+
return getHook(vm.component, key);
|
|
2953
|
+
};
|
|
2954
|
+
}
|
|
2955
|
+
return fn;
|
|
3106
2956
|
}
|
|
3107
2957
|
function createSetter(key) {
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
}
|
|
3119
|
-
return fn;
|
|
2958
|
+
let fn = cachedSetterByKey[key];
|
|
2959
|
+
if (isUndefined$1(fn)) {
|
|
2960
|
+
fn = cachedSetterByKey[key] = function (newValue) {
|
|
2961
|
+
const vm = getAssociatedVM(this);
|
|
2962
|
+
const { setHook } = vm;
|
|
2963
|
+
newValue = getReadOnlyProxy(newValue);
|
|
2964
|
+
setHook(vm.component, key, newValue);
|
|
2965
|
+
};
|
|
2966
|
+
}
|
|
2967
|
+
return fn;
|
|
3120
2968
|
}
|
|
3121
2969
|
function createMethodCaller(methodName) {
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
}
|
|
3128
|
-
const fn = component[methodName];
|
|
3129
|
-
return callHook(vm.component, fn, ArraySlice.call(arguments));
|
|
3130
|
-
};
|
|
2970
|
+
return function () {
|
|
2971
|
+
const vm = getAssociatedVM(this);
|
|
2972
|
+
const { callHook, component } = vm;
|
|
2973
|
+
const fn = component[methodName];
|
|
2974
|
+
return callHook(vm.component, fn, ArraySlice.call(arguments));
|
|
2975
|
+
};
|
|
3131
2976
|
}
|
|
3132
2977
|
function createAttributeChangedCallback(attributeToPropMap, superAttributeChangedCallback) {
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
2978
|
+
return function attributeChangedCallback(attrName, oldValue, newValue) {
|
|
2979
|
+
if (oldValue === newValue) {
|
|
2980
|
+
// Ignore same values.
|
|
2981
|
+
return;
|
|
2982
|
+
}
|
|
2983
|
+
const propName = attributeToPropMap[attrName];
|
|
2984
|
+
if (isUndefined$1(propName)) {
|
|
2985
|
+
if (!isUndefined$1(superAttributeChangedCallback)) {
|
|
2986
|
+
// delegate unknown attributes to the super.
|
|
2987
|
+
// Typescript does not like it when you treat the `arguments` object as an array
|
|
2988
|
+
// @ts-ignore type-mismatch
|
|
2989
|
+
superAttributeChangedCallback.apply(this, arguments);
|
|
2990
|
+
}
|
|
2991
|
+
return;
|
|
2992
|
+
}
|
|
2993
|
+
if (!isAttributeLocked(this, attrName)) {
|
|
2994
|
+
// Ignore changes triggered by the engine itself during:
|
|
2995
|
+
// * diffing when public props are attempting to reflect to the DOM
|
|
2996
|
+
// * component via `this.setAttribute()`, should never update the prop
|
|
2997
|
+
// Both cases, the setAttribute call is always wrapped by the unlocking of the
|
|
2998
|
+
// attribute to be changed
|
|
2999
|
+
return;
|
|
3000
|
+
}
|
|
3001
|
+
// Reflect attribute change to the corresponding property when changed from outside.
|
|
3002
|
+
this[propName] = newValue;
|
|
3003
|
+
};
|
|
3159
3004
|
}
|
|
3160
3005
|
function HTMLBridgeElementFactory(SuperClass, props, methods) {
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3006
|
+
let HTMLBridgeElement;
|
|
3007
|
+
/**
|
|
3008
|
+
* Modern browsers will have all Native Constructors as regular Classes
|
|
3009
|
+
* and must be instantiated with the new keyword. In older browsers,
|
|
3010
|
+
* specifically IE11, those are objects with a prototype property defined,
|
|
3011
|
+
* since they are not supposed to be extended or instantiated with the
|
|
3012
|
+
* new keyword. This forking logic supports both cases, specifically because
|
|
3013
|
+
* wc.ts relies on the construction path of the bridges to create new
|
|
3014
|
+
* fully qualifying web components.
|
|
3015
|
+
*/
|
|
3016
|
+
if (isFunction$1(SuperClass)) {
|
|
3017
|
+
HTMLBridgeElement = class extends SuperClass {
|
|
3018
|
+
};
|
|
3019
|
+
}
|
|
3020
|
+
else {
|
|
3021
|
+
HTMLBridgeElement = function () {
|
|
3022
|
+
// Bridge classes are not supposed to be instantiated directly in
|
|
3023
|
+
// browsers that do not support web components.
|
|
3024
|
+
throw new TypeError('Illegal constructor');
|
|
3025
|
+
};
|
|
3026
|
+
// prototype inheritance dance
|
|
3027
|
+
setPrototypeOf(HTMLBridgeElement, SuperClass);
|
|
3028
|
+
setPrototypeOf(HTMLBridgeElement.prototype, SuperClass.prototype);
|
|
3029
|
+
defineProperty(HTMLBridgeElement.prototype, 'constructor', {
|
|
3030
|
+
writable: true,
|
|
3031
|
+
configurable: true,
|
|
3032
|
+
value: HTMLBridgeElement,
|
|
3033
|
+
});
|
|
3034
|
+
}
|
|
3035
|
+
// generating the hash table for attributes to avoid duplicate fields and facilitate validation
|
|
3036
|
+
// and false positives in case of inheritance.
|
|
3037
|
+
const attributeToPropMap = create(null);
|
|
3038
|
+
const { attributeChangedCallback: superAttributeChangedCallback } = SuperClass.prototype;
|
|
3039
|
+
const { observedAttributes: superObservedAttributes = [] } = SuperClass;
|
|
3040
|
+
const descriptors = create(null);
|
|
3041
|
+
// expose getters and setters for each public props on the new Element Bridge
|
|
3042
|
+
for (let i = 0, len = props.length; i < len; i += 1) {
|
|
3043
|
+
const propName = props[i];
|
|
3044
|
+
attributeToPropMap[htmlPropertyToAttribute(propName)] = propName;
|
|
3045
|
+
descriptors[propName] = {
|
|
3046
|
+
get: createGetter(propName),
|
|
3047
|
+
set: createSetter(propName),
|
|
3048
|
+
enumerable: true,
|
|
3049
|
+
configurable: true,
|
|
3050
|
+
};
|
|
3051
|
+
}
|
|
3052
|
+
// expose public methods as props on the new Element Bridge
|
|
3053
|
+
for (let i = 0, len = methods.length; i < len; i += 1) {
|
|
3054
|
+
const methodName = methods[i];
|
|
3055
|
+
descriptors[methodName] = {
|
|
3056
|
+
value: createMethodCaller(methodName),
|
|
3057
|
+
writable: true,
|
|
3058
|
+
configurable: true,
|
|
3059
|
+
};
|
|
3060
|
+
}
|
|
3061
|
+
// creating a new attributeChangedCallback per bridge because they are bound to the corresponding
|
|
3062
|
+
// map of attributes to props. We do this after all other props and methods to avoid the possibility
|
|
3063
|
+
// of getting overrule by a class declaration in user-land, and we make it non-writable, non-configurable
|
|
3064
|
+
// to preserve this definition.
|
|
3065
|
+
descriptors.attributeChangedCallback = {
|
|
3066
|
+
value: createAttributeChangedCallback(attributeToPropMap, superAttributeChangedCallback),
|
|
3178
3067
|
};
|
|
3179
|
-
//
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
value: HTMLBridgeElement
|
|
3068
|
+
// Specify attributes for which we want to reflect changes back to their corresponding
|
|
3069
|
+
// properties via attributeChangedCallback.
|
|
3070
|
+
defineProperty(HTMLBridgeElement, 'observedAttributes', {
|
|
3071
|
+
get() {
|
|
3072
|
+
return [...superObservedAttributes, ...keys(attributeToPropMap)];
|
|
3073
|
+
},
|
|
3186
3074
|
});
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
// and false positives in case of inheritance.
|
|
3190
|
-
const attributeToPropMap = create(null);
|
|
3191
|
-
const {
|
|
3192
|
-
attributeChangedCallback: superAttributeChangedCallback
|
|
3193
|
-
} = SuperClass.prototype;
|
|
3194
|
-
const {
|
|
3195
|
-
observedAttributes: superObservedAttributes = []
|
|
3196
|
-
} = SuperClass;
|
|
3197
|
-
const descriptors = create(null);
|
|
3198
|
-
// expose getters and setters for each public props on the new Element Bridge
|
|
3199
|
-
for (let i = 0, len = props.length; i < len; i += 1) {
|
|
3200
|
-
const propName = props[i];
|
|
3201
|
-
attributeToPropMap[htmlPropertyToAttribute(propName)] = propName;
|
|
3202
|
-
descriptors[propName] = {
|
|
3203
|
-
get: createGetter(propName),
|
|
3204
|
-
set: createSetter(propName),
|
|
3205
|
-
enumerable: true,
|
|
3206
|
-
configurable: true
|
|
3207
|
-
};
|
|
3208
|
-
}
|
|
3209
|
-
// expose public methods as props on the new Element Bridge
|
|
3210
|
-
for (let i = 0, len = methods.length; i < len; i += 1) {
|
|
3211
|
-
const methodName = methods[i];
|
|
3212
|
-
descriptors[methodName] = {
|
|
3213
|
-
value: createMethodCaller(methodName),
|
|
3214
|
-
writable: true,
|
|
3215
|
-
configurable: true
|
|
3216
|
-
};
|
|
3217
|
-
}
|
|
3218
|
-
// creating a new attributeChangedCallback per bridge because they are bound to the corresponding
|
|
3219
|
-
// map of attributes to props. We do this after all other props and methods to avoid the possibility
|
|
3220
|
-
// of getting overrule by a class declaration in user-land, and we make it non-writable, non-configurable
|
|
3221
|
-
// to preserve this definition.
|
|
3222
|
-
descriptors.attributeChangedCallback = {
|
|
3223
|
-
value: createAttributeChangedCallback(attributeToPropMap, superAttributeChangedCallback)
|
|
3224
|
-
};
|
|
3225
|
-
// Specify attributes for which we want to reflect changes back to their corresponding
|
|
3226
|
-
// properties via attributeChangedCallback.
|
|
3227
|
-
defineProperty(HTMLBridgeElement, 'observedAttributes', {
|
|
3228
|
-
get() {
|
|
3229
|
-
return [...superObservedAttributes, ...keys(attributeToPropMap)];
|
|
3230
|
-
}
|
|
3231
|
-
});
|
|
3232
|
-
defineProperties(HTMLBridgeElement.prototype, descriptors);
|
|
3233
|
-
return HTMLBridgeElement;
|
|
3075
|
+
defineProperties(HTMLBridgeElement.prototype, descriptors);
|
|
3076
|
+
return HTMLBridgeElement;
|
|
3234
3077
|
}
|
|
3235
3078
|
const BaseBridgeElement = HTMLBridgeElementFactory(HTMLElementConstructor, getOwnPropertyNames$1(HTMLElementOriginalDescriptors), []);
|
|
3236
3079
|
freeze(BaseBridgeElement);
|
|
@@ -3550,157 +3393,137 @@ function getComponentDef(Ctor) {
|
|
|
3550
3393
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3551
3394
|
*/
|
|
3552
3395
|
function makeHostToken(token) {
|
|
3553
|
-
|
|
3396
|
+
return `${token}-host`;
|
|
3554
3397
|
}
|
|
3555
3398
|
function createInlineStyleVNode(content) {
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3399
|
+
return api.h('style', {
|
|
3400
|
+
key: 'style',
|
|
3401
|
+
attrs: {
|
|
3402
|
+
type: 'text/css',
|
|
3403
|
+
},
|
|
3404
|
+
}, [api.t(content)]);
|
|
3562
3405
|
}
|
|
3563
3406
|
function updateStylesheetToken(vm, template) {
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
renderMode
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
}
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
// associated stylesheets. In the case of light DOM, also ensure there is at least one scoped stylesheet.
|
|
3605
|
-
const hasNewStylesheets = hasStyles(newStylesheets);
|
|
3606
|
-
const hasNewVmStylesheets = hasStyles(newVmStylesheets);
|
|
3607
|
-
if (hasNewStylesheets || hasNewVmStylesheets) {
|
|
3608
|
-
newToken = newStylesheetToken;
|
|
3609
|
-
}
|
|
3610
|
-
// Set the new styling token on the host element
|
|
3611
|
-
if (!isUndefined$1(newToken)) {
|
|
3612
|
-
if (hasScopedStyles) {
|
|
3613
|
-
getClassList(elm).add(makeHostToken(newToken));
|
|
3614
|
-
newHasTokenInClass = true;
|
|
3615
|
-
}
|
|
3616
|
-
if (isSyntheticShadow) {
|
|
3617
|
-
setAttribute(elm, makeHostToken(newToken), '');
|
|
3618
|
-
newHasTokenInAttribute = true;
|
|
3619
|
-
}
|
|
3620
|
-
}
|
|
3621
|
-
// Update the styling tokens present on the context object.
|
|
3622
|
-
context.stylesheetToken = newToken;
|
|
3623
|
-
context.hasTokenInClass = newHasTokenInClass;
|
|
3624
|
-
context.hasTokenInAttribute = newHasTokenInAttribute;
|
|
3407
|
+
const { elm, context, renderMode, shadowMode, renderer: { getClassList, removeAttribute, setAttribute }, } = vm;
|
|
3408
|
+
const { stylesheets: newStylesheets, stylesheetToken: newStylesheetToken } = template;
|
|
3409
|
+
const { stylesheets: newVmStylesheets } = vm;
|
|
3410
|
+
const isSyntheticShadow = renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */;
|
|
3411
|
+
const { hasScopedStyles } = context;
|
|
3412
|
+
let newToken;
|
|
3413
|
+
let newHasTokenInClass;
|
|
3414
|
+
let newHasTokenInAttribute;
|
|
3415
|
+
// Reset the styling token applied to the host element.
|
|
3416
|
+
const { stylesheetToken: oldToken, hasTokenInClass: oldHasTokenInClass, hasTokenInAttribute: oldHasTokenInAttribute, } = context;
|
|
3417
|
+
if (!isUndefined$1(oldToken)) {
|
|
3418
|
+
if (oldHasTokenInClass) {
|
|
3419
|
+
getClassList(elm).remove(makeHostToken(oldToken));
|
|
3420
|
+
}
|
|
3421
|
+
if (oldHasTokenInAttribute) {
|
|
3422
|
+
removeAttribute(elm, makeHostToken(oldToken));
|
|
3423
|
+
}
|
|
3424
|
+
}
|
|
3425
|
+
// Apply the new template styling token to the host element, if the new template has any
|
|
3426
|
+
// associated stylesheets. In the case of light DOM, also ensure there is at least one scoped stylesheet.
|
|
3427
|
+
const hasNewStylesheets = hasStyles(newStylesheets);
|
|
3428
|
+
const hasNewVmStylesheets = hasStyles(newVmStylesheets);
|
|
3429
|
+
if (hasNewStylesheets || hasNewVmStylesheets) {
|
|
3430
|
+
newToken = newStylesheetToken;
|
|
3431
|
+
}
|
|
3432
|
+
// Set the new styling token on the host element
|
|
3433
|
+
if (!isUndefined$1(newToken)) {
|
|
3434
|
+
if (hasScopedStyles) {
|
|
3435
|
+
getClassList(elm).add(makeHostToken(newToken));
|
|
3436
|
+
newHasTokenInClass = true;
|
|
3437
|
+
}
|
|
3438
|
+
if (isSyntheticShadow) {
|
|
3439
|
+
setAttribute(elm, makeHostToken(newToken), '');
|
|
3440
|
+
newHasTokenInAttribute = true;
|
|
3441
|
+
}
|
|
3442
|
+
}
|
|
3443
|
+
// Update the styling tokens present on the context object.
|
|
3444
|
+
context.stylesheetToken = newToken;
|
|
3445
|
+
context.hasTokenInClass = newHasTokenInClass;
|
|
3446
|
+
context.hasTokenInAttribute = newHasTokenInAttribute;
|
|
3625
3447
|
}
|
|
3626
3448
|
function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3449
|
+
const content = [];
|
|
3450
|
+
let root;
|
|
3451
|
+
for (let i = 0; i < stylesheets.length; i++) {
|
|
3452
|
+
let stylesheet = stylesheets[i];
|
|
3453
|
+
if (isArray$1(stylesheet)) {
|
|
3454
|
+
ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, stylesheetToken, vm));
|
|
3455
|
+
}
|
|
3456
|
+
else {
|
|
3457
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3458
|
+
// Check for compiler version mismatch in dev mode only
|
|
3459
|
+
checkVersionMismatch(stylesheet, 'stylesheet');
|
|
3460
|
+
// in dev-mode, we support hot swapping of stylesheet, which means that
|
|
3461
|
+
// the component instance might be attempting to use an old version of
|
|
3462
|
+
// the stylesheet, while internally, we have a replacement for it.
|
|
3463
|
+
stylesheet = getStyleOrSwappedStyle(stylesheet);
|
|
3464
|
+
}
|
|
3465
|
+
const isScopedCss = stylesheet[KEY__SCOPED_CSS];
|
|
3466
|
+
if (lwcRuntimeFlags.DISABLE_LIGHT_DOM_UNSCOPED_CSS &&
|
|
3467
|
+
!isScopedCss &&
|
|
3468
|
+
vm.renderMode === 0 /* RenderMode.Light */) {
|
|
3469
|
+
logError('Unscoped CSS is not supported in Light DOM. Please use scoped CSS (*.scoped.css) instead of unscoped CSS (*.css).');
|
|
3470
|
+
continue;
|
|
3471
|
+
}
|
|
3472
|
+
// Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
|
|
3473
|
+
const scopeToken = isScopedCss ||
|
|
3474
|
+
(vm.shadowMode === 1 /* ShadowMode.Synthetic */ && vm.renderMode === 1 /* RenderMode.Shadow */)
|
|
3475
|
+
? stylesheetToken
|
|
3476
|
+
: undefined;
|
|
3477
|
+
// Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
|
|
3478
|
+
// native shadow DOM. Synthetic shadow DOM never uses `:host`.
|
|
3479
|
+
const useActualHostSelector = vm.renderMode === 0 /* RenderMode.Light */
|
|
3480
|
+
? !isScopedCss
|
|
3481
|
+
: vm.shadowMode === 0 /* ShadowMode.Native */;
|
|
3482
|
+
// Use the native :dir() pseudoclass only in native shadow DOM. Otherwise, in synthetic shadow,
|
|
3483
|
+
// we use an attribute selector on the host to simulate :dir().
|
|
3484
|
+
let useNativeDirPseudoclass;
|
|
3485
|
+
if (vm.renderMode === 1 /* RenderMode.Shadow */) {
|
|
3486
|
+
useNativeDirPseudoclass = vm.shadowMode === 0 /* ShadowMode.Native */;
|
|
3487
|
+
}
|
|
3488
|
+
else {
|
|
3489
|
+
// Light DOM components should only render `[dir]` if they're inside of a synthetic shadow root.
|
|
3490
|
+
// At the top level (root is null) or inside of a native shadow root, they should use `:dir()`.
|
|
3491
|
+
if (isUndefined$1(root)) {
|
|
3492
|
+
// Only calculate the root once as necessary
|
|
3493
|
+
root = getNearestShadowComponent(vm);
|
|
3494
|
+
}
|
|
3495
|
+
useNativeDirPseudoclass = isNull(root) || root.shadowMode === 0 /* ShadowMode.Native */;
|
|
3496
|
+
}
|
|
3497
|
+
ArrayPush$1.call(content, stylesheet(scopeToken, useActualHostSelector, useNativeDirPseudoclass));
|
|
3498
|
+
}
|
|
3670
3499
|
}
|
|
3671
|
-
|
|
3672
|
-
return content;
|
|
3500
|
+
return content;
|
|
3673
3501
|
}
|
|
3674
3502
|
function getStylesheetsContent(vm, template) {
|
|
3675
|
-
|
|
3676
|
-
stylesheets
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
// VM (component) stylesheets apply after template stylesheets
|
|
3687
|
-
if (hasStyles(vmStylesheets)) {
|
|
3688
|
-
ArrayPush$1.apply(content, evaluateStylesheetsContent(vmStylesheets, stylesheetToken, vm));
|
|
3689
|
-
}
|
|
3690
|
-
return content;
|
|
3503
|
+
const { stylesheets, stylesheetToken } = template;
|
|
3504
|
+
const { stylesheets: vmStylesheets } = vm;
|
|
3505
|
+
let content = [];
|
|
3506
|
+
if (hasStyles(stylesheets)) {
|
|
3507
|
+
content = evaluateStylesheetsContent(stylesheets, stylesheetToken, vm);
|
|
3508
|
+
}
|
|
3509
|
+
// VM (component) stylesheets apply after template stylesheets
|
|
3510
|
+
if (hasStyles(vmStylesheets)) {
|
|
3511
|
+
ArrayPush$1.apply(content, evaluateStylesheetsContent(vmStylesheets, stylesheetToken, vm));
|
|
3512
|
+
}
|
|
3513
|
+
return content;
|
|
3691
3514
|
}
|
|
3692
3515
|
// It might be worth caching this to avoid doing the lookup repeatedly, but
|
|
3693
3516
|
// perf testing has not shown it to be a huge improvement yet:
|
|
3694
3517
|
// https://github.com/salesforce/lwc/pull/2460#discussion_r691208892
|
|
3695
3518
|
function getNearestShadowComponent(vm) {
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3519
|
+
let owner = vm;
|
|
3520
|
+
while (!isNull(owner)) {
|
|
3521
|
+
if (owner.renderMode === 1 /* RenderMode.Shadow */) {
|
|
3522
|
+
return owner;
|
|
3523
|
+
}
|
|
3524
|
+
owner = owner.owner;
|
|
3700
3525
|
}
|
|
3701
|
-
|
|
3702
|
-
}
|
|
3703
|
-
return owner;
|
|
3526
|
+
return owner;
|
|
3704
3527
|
}
|
|
3705
3528
|
/**
|
|
3706
3529
|
* If the component that is currently being rendered uses scoped styles,
|
|
@@ -3708,32 +3531,24 @@ function getNearestShadowComponent(vm) {
|
|
|
3708
3531
|
* it returns null.
|
|
3709
3532
|
*/
|
|
3710
3533
|
function getScopeTokenClass(owner) {
|
|
3711
|
-
|
|
3712
|
-
cmpTemplate
|
|
3713
|
-
context
|
|
3714
|
-
} = owner;
|
|
3715
|
-
return context.hasScopedStyles && (cmpTemplate === null || cmpTemplate === void 0 ? void 0 : cmpTemplate.stylesheetToken) || null;
|
|
3534
|
+
const { cmpTemplate, context } = owner;
|
|
3535
|
+
return (context.hasScopedStyles && (cmpTemplate === null || cmpTemplate === void 0 ? void 0 : cmpTemplate.stylesheetToken)) || null;
|
|
3716
3536
|
}
|
|
3717
3537
|
function createStylesheet(vm, stylesheets) {
|
|
3718
|
-
|
|
3719
|
-
renderMode
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
}
|
|
3724
|
-
} = vm;
|
|
3725
|
-
if (renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */) {
|
|
3726
|
-
for (let i = 0; i < stylesheets.length; i++) {
|
|
3727
|
-
insertStylesheet(stylesheets[i]);
|
|
3538
|
+
const { renderMode, shadowMode, renderer: { insertStylesheet }, } = vm;
|
|
3539
|
+
if (renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */) {
|
|
3540
|
+
for (let i = 0; i < stylesheets.length; i++) {
|
|
3541
|
+
insertStylesheet(stylesheets[i]);
|
|
3542
|
+
}
|
|
3728
3543
|
}
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3544
|
+
else {
|
|
3545
|
+
// Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
|
|
3546
|
+
// This works in the client, because the stylesheets are created, and cached in the VM
|
|
3547
|
+
// the first time the VM renders.
|
|
3548
|
+
// native shadow or light DOM, SSR
|
|
3549
|
+
return ArrayMap.call(stylesheets, createInlineStyleVNode);
|
|
3550
|
+
}
|
|
3551
|
+
return null;
|
|
3737
3552
|
}
|
|
3738
3553
|
|
|
3739
3554
|
/*
|
|
@@ -4041,496 +3856,433 @@ function applyStaticStyleAttribute(vnode, renderer) {
|
|
|
4041
3856
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
4042
3857
|
*/
|
|
4043
3858
|
function patchChildren(c1, c2, parent, renderer) {
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
3859
|
+
if (hasDynamicChildren(c2)) {
|
|
3860
|
+
updateDynamicChildren(c1, c2, parent, renderer);
|
|
3861
|
+
}
|
|
3862
|
+
else {
|
|
3863
|
+
updateStaticChildren(c1, c2, parent, renderer);
|
|
3864
|
+
}
|
|
4049
3865
|
}
|
|
4050
3866
|
function patch(n1, n2, parent, renderer) {
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
patchCustomElement(n1, n2, parent, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
|
|
4086
|
-
break;
|
|
4087
|
-
}
|
|
3867
|
+
var _a, _b;
|
|
3868
|
+
if (n1 === n2) {
|
|
3869
|
+
return;
|
|
3870
|
+
}
|
|
3871
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3872
|
+
if (!isSameVnode(n1, n2)) {
|
|
3873
|
+
throw new Error('Expected these VNodes to be the same: ' +
|
|
3874
|
+
JSON.stringify({ sel: n1.sel, key: n1.key }) +
|
|
3875
|
+
', ' +
|
|
3876
|
+
JSON.stringify({ sel: n2.sel, key: n2.key }));
|
|
3877
|
+
}
|
|
3878
|
+
}
|
|
3879
|
+
switch (n2.type) {
|
|
3880
|
+
case 0 /* VNodeType.Text */:
|
|
3881
|
+
// VText has no special capability, fallback to the owner's renderer
|
|
3882
|
+
patchText(n1, n2, renderer);
|
|
3883
|
+
break;
|
|
3884
|
+
case 1 /* VNodeType.Comment */:
|
|
3885
|
+
// VComment has no special capability, fallback to the owner's renderer
|
|
3886
|
+
patchComment(n1, n2, renderer);
|
|
3887
|
+
break;
|
|
3888
|
+
case 4 /* VNodeType.Static */:
|
|
3889
|
+
n2.elm = n1.elm;
|
|
3890
|
+
break;
|
|
3891
|
+
case 5 /* VNodeType.Fragment */:
|
|
3892
|
+
patchFragment(n1, n2, parent, renderer);
|
|
3893
|
+
break;
|
|
3894
|
+
case 2 /* VNodeType.Element */:
|
|
3895
|
+
patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
|
|
3896
|
+
break;
|
|
3897
|
+
case 3 /* VNodeType.CustomElement */:
|
|
3898
|
+
patchCustomElement(n1, n2, parent, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
|
|
3899
|
+
break;
|
|
3900
|
+
}
|
|
4088
3901
|
}
|
|
4089
3902
|
function mount(node, parent, renderer, anchor) {
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
3903
|
+
var _a, _b;
|
|
3904
|
+
switch (node.type) {
|
|
3905
|
+
case 0 /* VNodeType.Text */:
|
|
3906
|
+
// VText has no special capability, fallback to the owner's renderer
|
|
3907
|
+
mountText(node, parent, anchor, renderer);
|
|
3908
|
+
break;
|
|
3909
|
+
case 1 /* VNodeType.Comment */:
|
|
3910
|
+
// VComment has no special capability, fallback to the owner's renderer
|
|
3911
|
+
mountComment(node, parent, anchor, renderer);
|
|
3912
|
+
break;
|
|
3913
|
+
case 4 /* VNodeType.Static */:
|
|
3914
|
+
// VStatic cannot have a custom renderer associated to them, using owner's renderer
|
|
3915
|
+
mountStatic(node, parent, anchor, renderer);
|
|
3916
|
+
break;
|
|
3917
|
+
case 5 /* VNodeType.Fragment */:
|
|
3918
|
+
mountFragment(node, parent, anchor, renderer);
|
|
3919
|
+
break;
|
|
3920
|
+
case 2 /* VNodeType.Element */:
|
|
3921
|
+
// If the vnode data has a renderer override use it, else fallback to owner's renderer
|
|
3922
|
+
mountElement(node, parent, anchor, (_a = node.data.renderer) !== null && _a !== void 0 ? _a : renderer);
|
|
3923
|
+
break;
|
|
3924
|
+
case 3 /* VNodeType.CustomElement */:
|
|
3925
|
+
// If the vnode data has a renderer override use it, else fallback to owner's renderer
|
|
3926
|
+
mountCustomElement(node, parent, anchor, (_b = node.data.renderer) !== null && _b !== void 0 ? _b : renderer);
|
|
3927
|
+
break;
|
|
3928
|
+
}
|
|
4116
3929
|
}
|
|
4117
3930
|
function patchText(n1, n2, renderer) {
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
3931
|
+
n2.elm = n1.elm;
|
|
3932
|
+
if (n2.text !== n1.text) {
|
|
3933
|
+
updateTextContent(n2, renderer);
|
|
3934
|
+
}
|
|
4122
3935
|
}
|
|
4123
3936
|
function mountText(vnode, parent, anchor, renderer) {
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
} = renderer;
|
|
4130
|
-
const textNode = vnode.elm = createText(vnode.text);
|
|
4131
|
-
linkNodeToShadow(textNode, owner, renderer);
|
|
4132
|
-
insertNode(textNode, parent, anchor, renderer);
|
|
3937
|
+
const { owner } = vnode;
|
|
3938
|
+
const { createText } = renderer;
|
|
3939
|
+
const textNode = (vnode.elm = createText(vnode.text));
|
|
3940
|
+
linkNodeToShadow(textNode, owner, renderer);
|
|
3941
|
+
insertNode(textNode, parent, anchor, renderer);
|
|
4133
3942
|
}
|
|
4134
3943
|
function patchComment(n1, n2, renderer) {
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
3944
|
+
n2.elm = n1.elm;
|
|
3945
|
+
// FIXME: Comment nodes should be static, we shouldn't need to diff them together. However
|
|
3946
|
+
// it is the case today.
|
|
3947
|
+
if (n2.text !== n1.text) {
|
|
3948
|
+
updateTextContent(n2, renderer);
|
|
3949
|
+
}
|
|
4141
3950
|
}
|
|
4142
3951
|
function mountComment(vnode, parent, anchor, renderer) {
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
} = renderer;
|
|
4149
|
-
const commentNode = vnode.elm = createComment(vnode.text);
|
|
4150
|
-
linkNodeToShadow(commentNode, owner, renderer);
|
|
4151
|
-
insertNode(commentNode, parent, anchor, renderer);
|
|
3952
|
+
const { owner } = vnode;
|
|
3953
|
+
const { createComment } = renderer;
|
|
3954
|
+
const commentNode = (vnode.elm = createComment(vnode.text));
|
|
3955
|
+
linkNodeToShadow(commentNode, owner, renderer);
|
|
3956
|
+
insertNode(commentNode, parent, anchor, renderer);
|
|
4152
3957
|
}
|
|
4153
3958
|
function mountFragment(vnode, parent, anchor, renderer) {
|
|
4154
|
-
|
|
4155
|
-
children
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
// children of a fragment will always have at least the two delimiters.
|
|
4159
|
-
vnode.elm = children[children.length - 1].elm;
|
|
3959
|
+
const { children } = vnode;
|
|
3960
|
+
mountVNodes(children, parent, renderer, anchor);
|
|
3961
|
+
// children of a fragment will always have at least the two delimiters.
|
|
3962
|
+
vnode.elm = children[children.length - 1].elm;
|
|
4160
3963
|
}
|
|
4161
3964
|
function patchFragment(n1, n2, parent, renderer) {
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
// Note: not reusing n1.elm, because during patching, it may be patched with another text node.
|
|
4172
|
-
n2.elm = children[children.length - 1].elm;
|
|
3965
|
+
const { children, stable } = n2;
|
|
3966
|
+
if (stable) {
|
|
3967
|
+
updateStaticChildren(n1.children, children, parent, renderer);
|
|
3968
|
+
}
|
|
3969
|
+
else {
|
|
3970
|
+
updateDynamicChildren(n1.children, children, parent, renderer);
|
|
3971
|
+
}
|
|
3972
|
+
// Note: not reusing n1.elm, because during patching, it may be patched with another text node.
|
|
3973
|
+
n2.elm = children[children.length - 1].elm;
|
|
4173
3974
|
}
|
|
4174
3975
|
function mountElement(vnode, parent, anchor, renderer) {
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
const elm = vnode.elm = createElement(sel, namespace);
|
|
4187
|
-
linkNodeToShadow(elm, owner, renderer);
|
|
4188
|
-
applyStyleScoping(elm, owner, renderer);
|
|
4189
|
-
applyDomManual(elm, vnode);
|
|
4190
|
-
applyElementRestrictions(elm, vnode);
|
|
4191
|
-
patchElementPropsAndAttrs$1(null, vnode, renderer);
|
|
4192
|
-
insertNode(elm, parent, anchor, renderer);
|
|
4193
|
-
mountVNodes(vnode.children, elm, renderer, null);
|
|
3976
|
+
const { sel, owner, data: { svg }, } = vnode;
|
|
3977
|
+
const { createElement } = renderer;
|
|
3978
|
+
const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
|
|
3979
|
+
const elm = (vnode.elm = createElement(sel, namespace));
|
|
3980
|
+
linkNodeToShadow(elm, owner, renderer);
|
|
3981
|
+
applyStyleScoping(elm, owner, renderer);
|
|
3982
|
+
applyDomManual(elm, vnode);
|
|
3983
|
+
applyElementRestrictions(elm, vnode);
|
|
3984
|
+
patchElementPropsAndAttrs$1(null, vnode, renderer);
|
|
3985
|
+
insertNode(elm, parent, anchor, renderer);
|
|
3986
|
+
mountVNodes(vnode.children, elm, renderer, null);
|
|
4194
3987
|
}
|
|
4195
3988
|
function patchElement(n1, n2, renderer) {
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
3989
|
+
const elm = (n2.elm = n1.elm);
|
|
3990
|
+
patchElementPropsAndAttrs$1(n1, n2, renderer);
|
|
3991
|
+
patchChildren(n1.children, n2.children, elm, renderer);
|
|
4199
3992
|
}
|
|
4200
3993
|
function mountStatic(vnode, parent, anchor, renderer) {
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
const {
|
|
4213
|
-
renderMode,
|
|
4214
|
-
shadowMode
|
|
4215
|
-
} = owner;
|
|
4216
|
-
if (isSyntheticShadowDefined) {
|
|
4217
|
-
if (shadowMode === 1 /* ShadowMode.Synthetic */ || renderMode === 0 /* RenderMode.Light */) {
|
|
4218
|
-
elm[KEY__SHADOW_STATIC] = true;
|
|
3994
|
+
const { owner } = vnode;
|
|
3995
|
+
const { cloneNode, isSyntheticShadowDefined } = renderer;
|
|
3996
|
+
const elm = (vnode.elm = cloneNode(vnode.fragment, true));
|
|
3997
|
+
linkNodeToShadow(elm, owner, renderer);
|
|
3998
|
+
applyElementRestrictions(elm, vnode);
|
|
3999
|
+
// Marks this node as Static to propagate the shadow resolver. must happen after elm is assigned to the proper shadow
|
|
4000
|
+
const { renderMode, shadowMode } = owner;
|
|
4001
|
+
if (isSyntheticShadowDefined) {
|
|
4002
|
+
if (shadowMode === 1 /* ShadowMode.Synthetic */ || renderMode === 0 /* RenderMode.Light */) {
|
|
4003
|
+
elm[KEY__SHADOW_STATIC] = true;
|
|
4004
|
+
}
|
|
4219
4005
|
}
|
|
4220
|
-
|
|
4221
|
-
insertNode(elm, parent, anchor, renderer);
|
|
4006
|
+
insertNode(elm, parent, anchor, renderer);
|
|
4222
4007
|
}
|
|
4223
4008
|
function mountCustomElement(vnode, parent, anchor, renderer) {
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
*/
|
|
4237
|
-
let vm;
|
|
4238
|
-
const upgradeCallback = elm => {
|
|
4239
|
-
// the custom element from the registry is expecting an upgrade callback
|
|
4240
|
-
vm = createViewModelHook(elm, vnode, renderer);
|
|
4241
|
-
};
|
|
4242
|
-
let connectedCallback;
|
|
4243
|
-
let disconnectedCallback;
|
|
4244
|
-
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
4245
|
-
connectedCallback = elm => {
|
|
4246
|
-
connectRootElement(elm);
|
|
4247
|
-
};
|
|
4248
|
-
disconnectedCallback = elm => {
|
|
4249
|
-
disconnectRootElement(elm);
|
|
4009
|
+
const { sel, owner } = vnode;
|
|
4010
|
+
const { createCustomElement } = renderer;
|
|
4011
|
+
/**
|
|
4012
|
+
* Note: if the upgradable constructor does not expect, or throw when we new it
|
|
4013
|
+
* with a callback as the first argument, we could implement a more advanced
|
|
4014
|
+
* mechanism that only passes that argument if the constructor is known to be
|
|
4015
|
+
* an upgradable custom element.
|
|
4016
|
+
*/
|
|
4017
|
+
let vm;
|
|
4018
|
+
const upgradeCallback = (elm) => {
|
|
4019
|
+
// the custom element from the registry is expecting an upgrade callback
|
|
4020
|
+
vm = createViewModelHook(elm, vnode, renderer);
|
|
4250
4021
|
};
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4022
|
+
let connectedCallback;
|
|
4023
|
+
let disconnectedCallback;
|
|
4024
|
+
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
4025
|
+
connectedCallback = (elm) => {
|
|
4026
|
+
connectRootElement(elm);
|
|
4027
|
+
};
|
|
4028
|
+
disconnectedCallback = (elm) => {
|
|
4029
|
+
disconnectRootElement(elm);
|
|
4030
|
+
};
|
|
4031
|
+
}
|
|
4032
|
+
// Should never get a tag with upper case letter at this point; the compiler
|
|
4033
|
+
// should produce only tags with lowercase letters. However, the Java
|
|
4034
|
+
// compiler may generate tagnames with uppercase letters so - for backwards
|
|
4035
|
+
// compatibility, we lower case the tagname here.
|
|
4036
|
+
const normalizedTagname = sel.toLowerCase();
|
|
4037
|
+
const elm = createCustomElement(normalizedTagname, upgradeCallback, connectedCallback, disconnectedCallback);
|
|
4038
|
+
vnode.elm = elm;
|
|
4039
|
+
vnode.vm = vm;
|
|
4040
|
+
linkNodeToShadow(elm, owner, renderer);
|
|
4041
|
+
applyStyleScoping(elm, owner, renderer);
|
|
4042
|
+
if (vm) {
|
|
4043
|
+
allocateChildren(vnode, vm);
|
|
4044
|
+
}
|
|
4045
|
+
patchElementPropsAndAttrs$1(null, vnode, renderer);
|
|
4046
|
+
insertNode(elm, parent, anchor, renderer);
|
|
4047
|
+
if (vm) {
|
|
4048
|
+
{
|
|
4049
|
+
// On the server, we don't have native custom element lifecycle callbacks, so we must
|
|
4050
|
+
// manually invoke the connectedCallback for a child component.
|
|
4051
|
+
runConnectedCallback(vm);
|
|
4052
|
+
}
|
|
4053
|
+
}
|
|
4054
|
+
mountVNodes(vnode.children, elm, renderer, null);
|
|
4055
|
+
if (vm) {
|
|
4056
|
+
appendVM(vm);
|
|
4272
4057
|
}
|
|
4273
|
-
}
|
|
4274
|
-
mountVNodes(vnode.children, elm, renderer, null);
|
|
4275
|
-
if (vm) {
|
|
4276
|
-
appendVM(vm);
|
|
4277
|
-
}
|
|
4278
4058
|
}
|
|
4279
4059
|
function patchCustomElement(n1, n2, parent, renderer) {
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
|
|
4324
|
-
|
|
4060
|
+
if (n1.ctor !== n2.ctor) {
|
|
4061
|
+
// If the constructor, unmount the current component and mount a new one using the new
|
|
4062
|
+
// constructor.
|
|
4063
|
+
const anchor = renderer.nextSibling(n1.elm);
|
|
4064
|
+
unmount(n1, parent, renderer, true);
|
|
4065
|
+
mountCustomElement(n2, parent, anchor, renderer);
|
|
4066
|
+
}
|
|
4067
|
+
else {
|
|
4068
|
+
// Otherwise patch the existing component with new props/attrs/etc.
|
|
4069
|
+
const elm = (n2.elm = n1.elm);
|
|
4070
|
+
const vm = (n2.vm = n1.vm);
|
|
4071
|
+
patchElementPropsAndAttrs$1(n1, n2, renderer);
|
|
4072
|
+
if (!isUndefined$1(vm)) {
|
|
4073
|
+
// in fallback mode, the allocation will always set children to
|
|
4074
|
+
// empty and delegate the real allocation to the slot elements
|
|
4075
|
+
allocateChildren(n2, vm);
|
|
4076
|
+
// Solves an edge case with slotted VFragments in native shadow mode.
|
|
4077
|
+
//
|
|
4078
|
+
// During allocation, in native shadow, slotted VFragment nodes are flattened and their text delimiters are removed
|
|
4079
|
+
// to avoid interfering with native slot behavior. When this happens, if any of the fragments
|
|
4080
|
+
// were not stable, the children must go through the dynamic diffing algo.
|
|
4081
|
+
//
|
|
4082
|
+
// If the new children (n2.children) contain no VFragments, but the previous children (n1.children) were dynamic,
|
|
4083
|
+
// the new nodes must be marked dynamic so that all nodes are properly updated. The only indicator that the new
|
|
4084
|
+
// nodes need to be dynamic comes from the previous children, so we check that to determine whether we need to
|
|
4085
|
+
// mark the new children dynamic.
|
|
4086
|
+
//
|
|
4087
|
+
// Example:
|
|
4088
|
+
// n1.children: [div, VFragment('', div, null, ''), div] => [div, div, null, div]; // marked dynamic
|
|
4089
|
+
// n2.children: [div, null, div] => [div, null, div] // marked ???
|
|
4090
|
+
const { shadowMode, renderMode } = vm;
|
|
4091
|
+
if (shadowMode == 0 /* ShadowMode.Native */ &&
|
|
4092
|
+
renderMode !== 0 /* RenderMode.Light */ &&
|
|
4093
|
+
hasDynamicChildren(n1.children)) {
|
|
4094
|
+
// No-op if children has already been marked dynamic by 'allocateChildren()'.
|
|
4095
|
+
markAsDynamicChildren(n2.children);
|
|
4096
|
+
}
|
|
4097
|
+
}
|
|
4098
|
+
// in fallback mode, the children will be always empty, so, nothing
|
|
4099
|
+
// will happen, but in native, it does allocate the light dom
|
|
4100
|
+
patchChildren(n1.children, n2.children, elm, renderer);
|
|
4101
|
+
if (!isUndefined$1(vm)) {
|
|
4102
|
+
// this will probably update the shadowRoot, but only if the vm is in a dirty state
|
|
4103
|
+
// this is important to preserve the top to bottom synchronous rendering phase.
|
|
4104
|
+
rerenderVM(vm);
|
|
4105
|
+
}
|
|
4325
4106
|
}
|
|
4326
|
-
}
|
|
4327
4107
|
}
|
|
4328
4108
|
function mountVNodes(vnodes, parent, renderer, anchor, start = 0, end = vnodes.length) {
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4109
|
+
for (; start < end; ++start) {
|
|
4110
|
+
const vnode = vnodes[start];
|
|
4111
|
+
if (isVNode(vnode)) {
|
|
4112
|
+
mount(vnode, parent, renderer, anchor);
|
|
4113
|
+
}
|
|
4333
4114
|
}
|
|
4334
|
-
}
|
|
4335
4115
|
}
|
|
4336
4116
|
function unmount(vnode, parent, renderer, doRemove = false) {
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
vm
|
|
4366
|
-
} = vnode;
|
|
4367
|
-
// No need to unmount the children here, `removeVM` will take care of removing the
|
|
4368
|
-
// children.
|
|
4369
|
-
if (!isUndefined$1(vm)) {
|
|
4370
|
-
removeVM(vm);
|
|
4117
|
+
const { type, elm, sel } = vnode;
|
|
4118
|
+
// When unmounting a VNode subtree not all the elements have to removed from the DOM. The
|
|
4119
|
+
// subtree root, is the only element worth unmounting from the subtree.
|
|
4120
|
+
if (doRemove) {
|
|
4121
|
+
if (type === 5 /* VNodeType.Fragment */) {
|
|
4122
|
+
unmountVNodes(vnode.children, parent, renderer, doRemove);
|
|
4123
|
+
}
|
|
4124
|
+
else {
|
|
4125
|
+
// The vnode might or might not have a data.renderer associated to it
|
|
4126
|
+
// but the removal used here is from the owner instead.
|
|
4127
|
+
removeNode(elm, parent, renderer);
|
|
4128
|
+
}
|
|
4129
|
+
}
|
|
4130
|
+
switch (type) {
|
|
4131
|
+
case 2 /* VNodeType.Element */: {
|
|
4132
|
+
// Slot content is removed to trigger slotchange event when removing slot.
|
|
4133
|
+
// Only required for synthetic shadow.
|
|
4134
|
+
const shouldRemoveChildren = sel === 'slot' && vnode.owner.shadowMode === 1 /* ShadowMode.Synthetic */;
|
|
4135
|
+
unmountVNodes(vnode.children, elm, renderer, shouldRemoveChildren);
|
|
4136
|
+
break;
|
|
4137
|
+
}
|
|
4138
|
+
case 3 /* VNodeType.CustomElement */: {
|
|
4139
|
+
const { vm } = vnode;
|
|
4140
|
+
// No need to unmount the children here, `removeVM` will take care of removing the
|
|
4141
|
+
// children.
|
|
4142
|
+
if (!isUndefined$1(vm)) {
|
|
4143
|
+
removeVM(vm);
|
|
4144
|
+
}
|
|
4371
4145
|
}
|
|
4372
|
-
|
|
4373
|
-
}
|
|
4146
|
+
}
|
|
4374
4147
|
}
|
|
4375
4148
|
function unmountVNodes(vnodes, parent, renderer, doRemove = false, start = 0, end = vnodes.length) {
|
|
4376
|
-
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4149
|
+
for (; start < end; ++start) {
|
|
4150
|
+
const ch = vnodes[start];
|
|
4151
|
+
if (isVNode(ch)) {
|
|
4152
|
+
unmount(ch, parent, renderer, doRemove);
|
|
4153
|
+
}
|
|
4380
4154
|
}
|
|
4381
|
-
}
|
|
4382
4155
|
}
|
|
4383
4156
|
function isVNode(vnode) {
|
|
4384
|
-
|
|
4157
|
+
return vnode != null;
|
|
4385
4158
|
}
|
|
4386
4159
|
function linkNodeToShadow(elm, owner, renderer) {
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
} = renderer;
|
|
4395
|
-
// TODO [#1164]: this should eventually be done by the polyfill directly
|
|
4396
|
-
if (isSyntheticShadowDefined) {
|
|
4397
|
-
if (shadowMode === 1 /* ShadowMode.Synthetic */ || renderMode === 0 /* RenderMode.Light */) {
|
|
4398
|
-
elm[KEY__SHADOW_RESOLVER] = renderRoot[KEY__SHADOW_RESOLVER];
|
|
4160
|
+
const { renderRoot, renderMode, shadowMode } = owner;
|
|
4161
|
+
const { isSyntheticShadowDefined } = renderer;
|
|
4162
|
+
// TODO [#1164]: this should eventually be done by the polyfill directly
|
|
4163
|
+
if (isSyntheticShadowDefined) {
|
|
4164
|
+
if (shadowMode === 1 /* ShadowMode.Synthetic */ || renderMode === 0 /* RenderMode.Light */) {
|
|
4165
|
+
elm[KEY__SHADOW_RESOLVER] = renderRoot[KEY__SHADOW_RESOLVER];
|
|
4166
|
+
}
|
|
4399
4167
|
}
|
|
4400
|
-
}
|
|
4401
4168
|
}
|
|
4402
4169
|
function updateTextContent(vnode, renderer) {
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
setText
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
}
|
|
4413
|
-
setText(elm, text);
|
|
4414
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
4415
|
-
lockDomMutation();
|
|
4416
|
-
}
|
|
4170
|
+
const { elm, text } = vnode;
|
|
4171
|
+
const { setText } = renderer;
|
|
4172
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4173
|
+
unlockDomMutation();
|
|
4174
|
+
}
|
|
4175
|
+
setText(elm, text);
|
|
4176
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4177
|
+
lockDomMutation();
|
|
4178
|
+
}
|
|
4417
4179
|
}
|
|
4418
4180
|
function insertNode(node, parent, anchor, renderer) {
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
|
|
4181
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4182
|
+
unlockDomMutation();
|
|
4183
|
+
}
|
|
4184
|
+
renderer.insert(node, parent, anchor);
|
|
4185
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4186
|
+
lockDomMutation();
|
|
4187
|
+
}
|
|
4426
4188
|
}
|
|
4427
4189
|
function removeNode(node, parent, renderer) {
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
|
|
4190
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4191
|
+
unlockDomMutation();
|
|
4192
|
+
}
|
|
4193
|
+
renderer.remove(node, parent);
|
|
4194
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4195
|
+
lockDomMutation();
|
|
4196
|
+
}
|
|
4435
4197
|
}
|
|
4436
4198
|
function patchElementPropsAndAttrs$1(oldVnode, vnode, renderer) {
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4199
|
+
if (isNull(oldVnode)) {
|
|
4200
|
+
applyEventListeners(vnode, renderer);
|
|
4201
|
+
applyStaticClassAttribute(vnode, renderer);
|
|
4202
|
+
applyStaticStyleAttribute(vnode, renderer);
|
|
4203
|
+
}
|
|
4204
|
+
// Attrs need to be applied to element before props IE11 will wipe out value on radio inputs if
|
|
4205
|
+
// value is set before type=radio.
|
|
4206
|
+
patchClassAttribute(oldVnode, vnode, renderer);
|
|
4207
|
+
patchStyleAttribute(oldVnode, vnode, renderer);
|
|
4208
|
+
if (vnode.data.external) {
|
|
4209
|
+
patchAttrUnlessProp(oldVnode, vnode, renderer);
|
|
4210
|
+
}
|
|
4211
|
+
else {
|
|
4212
|
+
patchAttributes(oldVnode, vnode, renderer);
|
|
4213
|
+
}
|
|
4214
|
+
patchProps(oldVnode, vnode, renderer);
|
|
4452
4215
|
}
|
|
4453
4216
|
function applyStyleScoping(elm, owner, renderer) {
|
|
4454
|
-
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
|
|
4466
|
-
|
|
4467
|
-
} = owner.context;
|
|
4468
|
-
if (owner.shadowMode === 1 /* ShadowMode.Synthetic */ && !isUndefined$1(syntheticToken)) {
|
|
4469
|
-
elm.$shadowToken$ = syntheticToken;
|
|
4470
|
-
}
|
|
4217
|
+
// Set the class name for `*.scoped.css` style scoping.
|
|
4218
|
+
const scopeToken = getScopeTokenClass(owner);
|
|
4219
|
+
if (!isNull(scopeToken)) {
|
|
4220
|
+
const { getClassList } = renderer;
|
|
4221
|
+
// TODO [#2762]: this dot notation with add is probably problematic
|
|
4222
|
+
// probably we should have a renderer api for just the add operation
|
|
4223
|
+
getClassList(elm).add(scopeToken);
|
|
4224
|
+
}
|
|
4225
|
+
// Set property element for synthetic shadow DOM style scoping.
|
|
4226
|
+
const { stylesheetToken: syntheticToken } = owner.context;
|
|
4227
|
+
if (owner.shadowMode === 1 /* ShadowMode.Synthetic */ && !isUndefined$1(syntheticToken)) {
|
|
4228
|
+
elm.$shadowToken$ = syntheticToken;
|
|
4229
|
+
}
|
|
4471
4230
|
}
|
|
4472
4231
|
function applyDomManual(elm, vnode) {
|
|
4473
|
-
|
|
4474
|
-
|
|
4475
|
-
owner
|
|
4476
|
-
|
|
4477
|
-
context
|
|
4232
|
+
var _a;
|
|
4233
|
+
const { owner, data: { context }, } = vnode;
|
|
4234
|
+
if (owner.shadowMode === 1 /* ShadowMode.Synthetic */ && ((_a = context === null || context === void 0 ? void 0 : context.lwc) === null || _a === void 0 ? void 0 : _a.dom) === "manual" /* LwcDomMode.Manual */) {
|
|
4235
|
+
elm.$domManual$ = true;
|
|
4478
4236
|
}
|
|
4479
|
-
} = vnode;
|
|
4480
|
-
if (owner.shadowMode === 1 /* ShadowMode.Synthetic */ && ((_a = context === null || context === void 0 ? void 0 : context.lwc) === null || _a === void 0 ? void 0 : _a.dom) === "manual" /* LwcDomMode.Manual */) {
|
|
4481
|
-
elm.$domManual$ = true;
|
|
4482
|
-
}
|
|
4483
4237
|
}
|
|
4484
4238
|
function applyElementRestrictions(elm, vnode) {
|
|
4485
|
-
|
|
4486
|
-
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4239
|
+
var _a, _b;
|
|
4240
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4241
|
+
const isSynthetic = vnode.owner.shadowMode === 1 /* ShadowMode.Synthetic */;
|
|
4242
|
+
const isPortal = vnode.type === 2 /* VNodeType.Element */ && ((_b = (_a = vnode.data.context) === null || _a === void 0 ? void 0 : _a.lwc) === null || _b === void 0 ? void 0 : _b.dom) === "manual" /* LwcDomMode.Manual */;
|
|
4243
|
+
const isLight = vnode.owner.renderMode === 0 /* RenderMode.Light */;
|
|
4244
|
+
patchElementWithRestrictions(elm, {
|
|
4245
|
+
isPortal,
|
|
4246
|
+
isLight,
|
|
4247
|
+
isSynthetic,
|
|
4248
|
+
});
|
|
4249
|
+
}
|
|
4496
4250
|
}
|
|
4497
4251
|
function allocateChildren(vnode, vm) {
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
vnode.children = EmptyArray;
|
|
4533
|
-
}
|
|
4252
|
+
// A component with slots will re-render because:
|
|
4253
|
+
// 1- There is a change of the internal state.
|
|
4254
|
+
// 2- There is a change on the external api (ex: slots)
|
|
4255
|
+
//
|
|
4256
|
+
// In case #1, the vnodes in the cmpSlots will be reused since they didn't changed. This routine emptied the
|
|
4257
|
+
// slotted children when those VCustomElement were rendered and therefore in subsequent calls to allocate children
|
|
4258
|
+
// in a reused VCustomElement, there won't be any slotted children.
|
|
4259
|
+
// For those cases, we will use the reference for allocated children stored when rendering the fresh VCustomElement.
|
|
4260
|
+
//
|
|
4261
|
+
// In case #2, we will always get a fresh VCustomElement.
|
|
4262
|
+
const children = vnode.aChildren || vnode.children;
|
|
4263
|
+
const { renderMode, shadowMode } = vm;
|
|
4264
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4265
|
+
// If any of the children being allocated is a scoped slot fragment, make sure the receiving
|
|
4266
|
+
// component is a light DOM component. This is mainly to validate light dom parent running
|
|
4267
|
+
// in native shadow mode.
|
|
4268
|
+
if (renderMode !== 0 /* RenderMode.Light */ &&
|
|
4269
|
+
ArraySome.call(children, (child) => !isNull(child) && isVScopedSlotFragment(child))) {
|
|
4270
|
+
logError(`Invalid usage of 'lwc:slot-data' on ${getComponentTag(vm)} tag. Scoped slot content can only be passed to a light dom child.`);
|
|
4271
|
+
}
|
|
4272
|
+
}
|
|
4273
|
+
// If any of the children being allocated are VFragments, we remove the text delimiters and flatten all immediate
|
|
4274
|
+
// children VFragments to avoid them interfering with default slot behavior.
|
|
4275
|
+
const allocatedChildren = flattenFragmentsInChildren(children);
|
|
4276
|
+
vnode.children = allocatedChildren;
|
|
4277
|
+
vm.aChildren = allocatedChildren;
|
|
4278
|
+
if (shadowMode === 1 /* ShadowMode.Synthetic */ || renderMode === 0 /* RenderMode.Light */) {
|
|
4279
|
+
// slow path
|
|
4280
|
+
allocateInSlot(vm, allocatedChildren, vnode.owner);
|
|
4281
|
+
// save the allocated children in case this vnode is reused.
|
|
4282
|
+
vnode.aChildren = allocatedChildren;
|
|
4283
|
+
// every child vnode is now allocated, and the host should receive none directly, it receives them via the shadow!
|
|
4284
|
+
vnode.children = EmptyArray;
|
|
4285
|
+
}
|
|
4534
4286
|
}
|
|
4535
4287
|
/**
|
|
4536
4288
|
* Flattens the contents of all VFragments in an array of VNodes, removes the text delimiters on those VFragments, and
|
|
@@ -4542,275 +4294,278 @@ function allocateChildren(vnode, vm) {
|
|
|
4542
4294
|
* This function is used for slotted VFragments to avoid the text delimiters interfering with slotting functionality.
|
|
4543
4295
|
*/
|
|
4544
4296
|
function flattenFragmentsInChildren(children) {
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
|
|
4549
|
-
|
|
4550
|
-
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
|
|
4574
|
-
|
|
4297
|
+
const flattenedChildren = [];
|
|
4298
|
+
// Initialize our stack with the direct children of the custom component and check whether we have a VFragment.
|
|
4299
|
+
// If no VFragment is found in children, we don't need to traverse anything or mark the children dynamic and can return early.
|
|
4300
|
+
const nodeStack = [];
|
|
4301
|
+
let fragmentFound = false;
|
|
4302
|
+
for (let i = children.length - 1; i > -1; i -= 1) {
|
|
4303
|
+
const child = children[i];
|
|
4304
|
+
ArrayPush$1.call(nodeStack, child);
|
|
4305
|
+
fragmentFound = fragmentFound || !!(child && isVFragment(child));
|
|
4306
|
+
}
|
|
4307
|
+
if (!fragmentFound) {
|
|
4308
|
+
return children;
|
|
4309
|
+
}
|
|
4310
|
+
let currentNode;
|
|
4311
|
+
while (!isUndefined$1((currentNode = ArrayPop.call(nodeStack)))) {
|
|
4312
|
+
if (!isNull(currentNode) && isVFragment(currentNode)) {
|
|
4313
|
+
const fChildren = currentNode.children;
|
|
4314
|
+
// Ignore the start and end text node delimiters
|
|
4315
|
+
for (let i = fChildren.length - 2; i > 0; i -= 1) {
|
|
4316
|
+
ArrayPush$1.call(nodeStack, fChildren[i]);
|
|
4317
|
+
}
|
|
4318
|
+
}
|
|
4319
|
+
else {
|
|
4320
|
+
ArrayPush$1.call(flattenedChildren, currentNode);
|
|
4321
|
+
}
|
|
4322
|
+
}
|
|
4323
|
+
// We always mark the children as dynamic because nothing generates stable VFragments yet.
|
|
4324
|
+
// If/when stable VFragments are generated by the compiler, this code should be updated to
|
|
4325
|
+
// not mark dynamic if all flattened VFragments were stable.
|
|
4326
|
+
markAsDynamicChildren(flattenedChildren);
|
|
4327
|
+
return flattenedChildren;
|
|
4575
4328
|
}
|
|
4576
4329
|
function createViewModelHook(elm, vnode, renderer) {
|
|
4577
|
-
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
|
|
4330
|
+
let vm = getAssociatedVMIfPresent(elm);
|
|
4331
|
+
// There is a possibility that a custom element is registered under tagName, in which case, the
|
|
4332
|
+
// initialization is already carry on, and there is nothing else to do here since this hook is
|
|
4333
|
+
// called right after invoking `document.createElement`.
|
|
4334
|
+
if (!isUndefined$1(vm)) {
|
|
4335
|
+
return vm;
|
|
4336
|
+
}
|
|
4337
|
+
const { sel, mode, ctor, owner } = vnode;
|
|
4338
|
+
vm = createVM(elm, ctor, renderer, {
|
|
4339
|
+
mode,
|
|
4340
|
+
owner,
|
|
4341
|
+
tagName: sel,
|
|
4342
|
+
});
|
|
4343
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4344
|
+
assert.isTrue(isArray$1(vnode.children), `Invalid vnode for a custom element, it must have children defined.`);
|
|
4345
|
+
}
|
|
4582
4346
|
return vm;
|
|
4583
|
-
}
|
|
4584
|
-
const {
|
|
4585
|
-
sel,
|
|
4586
|
-
mode,
|
|
4587
|
-
ctor,
|
|
4588
|
-
owner
|
|
4589
|
-
} = vnode;
|
|
4590
|
-
vm = createVM(elm, ctor, renderer, {
|
|
4591
|
-
mode,
|
|
4592
|
-
owner,
|
|
4593
|
-
tagName: sel
|
|
4594
|
-
});
|
|
4595
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
4596
|
-
assert.isTrue(isArray$1(vnode.children), `Invalid vnode for a custom element, it must have children defined.`);
|
|
4597
|
-
}
|
|
4598
|
-
return vm;
|
|
4599
4347
|
}
|
|
4600
4348
|
function allocateInSlot(vm, children, owner) {
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
markComponentAsDirty(vm);
|
|
4651
|
-
return;
|
|
4349
|
+
var _a, _b;
|
|
4350
|
+
const { cmpSlots: { slotAssignments: oldSlotsMapping }, } = vm;
|
|
4351
|
+
const cmpSlotsMapping = create(null);
|
|
4352
|
+
// Collect all slots into cmpSlotsMapping
|
|
4353
|
+
for (let i = 0, len = children.length; i < len; i += 1) {
|
|
4354
|
+
const vnode = children[i];
|
|
4355
|
+
if (isNull(vnode)) {
|
|
4356
|
+
continue;
|
|
4357
|
+
}
|
|
4358
|
+
let slotName = '';
|
|
4359
|
+
if (isVBaseElement(vnode)) {
|
|
4360
|
+
slotName = (_b = (_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) !== null && _b !== void 0 ? _b : '';
|
|
4361
|
+
}
|
|
4362
|
+
else if (isVScopedSlotFragment(vnode)) {
|
|
4363
|
+
slotName = vnode.slotName;
|
|
4364
|
+
}
|
|
4365
|
+
// Can't use toString here because Symbol(1).toString() is 'Symbol(1)'
|
|
4366
|
+
// but elm.setAttribute('slot', Symbol(1)) is an error.
|
|
4367
|
+
// the following line also throws same error for symbols
|
|
4368
|
+
// Similar for Object.create(null)
|
|
4369
|
+
const normalizedSlotName = '' + slotName;
|
|
4370
|
+
const vnodes = (cmpSlotsMapping[normalizedSlotName] =
|
|
4371
|
+
cmpSlotsMapping[normalizedSlotName] || []);
|
|
4372
|
+
ArrayPush$1.call(vnodes, vnode);
|
|
4373
|
+
}
|
|
4374
|
+
vm.cmpSlots = { owner, slotAssignments: cmpSlotsMapping };
|
|
4375
|
+
if (isFalse(vm.isDirty)) {
|
|
4376
|
+
// We need to determine if the old allocation is really different from the new one
|
|
4377
|
+
// and mark the vm as dirty
|
|
4378
|
+
const oldKeys = keys(oldSlotsMapping);
|
|
4379
|
+
if (oldKeys.length !== keys(cmpSlotsMapping).length) {
|
|
4380
|
+
markComponentAsDirty(vm);
|
|
4381
|
+
return;
|
|
4382
|
+
}
|
|
4383
|
+
for (let i = 0, len = oldKeys.length; i < len; i += 1) {
|
|
4384
|
+
const key = oldKeys[i];
|
|
4385
|
+
if (isUndefined$1(cmpSlotsMapping[key]) ||
|
|
4386
|
+
oldSlotsMapping[key].length !== cmpSlotsMapping[key].length) {
|
|
4387
|
+
markComponentAsDirty(vm);
|
|
4388
|
+
return;
|
|
4389
|
+
}
|
|
4390
|
+
const oldVNodes = oldSlotsMapping[key];
|
|
4391
|
+
const vnodes = cmpSlotsMapping[key];
|
|
4392
|
+
for (let j = 0, a = cmpSlotsMapping[key].length; j < a; j += 1) {
|
|
4393
|
+
if (oldVNodes[j] !== vnodes[j]) {
|
|
4394
|
+
markComponentAsDirty(vm);
|
|
4395
|
+
return;
|
|
4396
|
+
}
|
|
4397
|
+
}
|
|
4652
4398
|
}
|
|
4653
|
-
}
|
|
4654
4399
|
}
|
|
4655
|
-
}
|
|
4656
4400
|
}
|
|
4657
4401
|
// Using a WeakMap instead of a WeakSet because this one works in IE11 :(
|
|
4658
4402
|
const DynamicChildren = new WeakMap();
|
|
4659
4403
|
// dynamic children means it was either generated by an iteration in a template
|
|
4660
4404
|
// or part of an unstable fragment, and will require a more complex diffing algo.
|
|
4661
4405
|
function markAsDynamicChildren(children) {
|
|
4662
|
-
|
|
4406
|
+
DynamicChildren.set(children, 1);
|
|
4663
4407
|
}
|
|
4664
4408
|
function hasDynamicChildren(children) {
|
|
4665
|
-
|
|
4409
|
+
return DynamicChildren.has(children);
|
|
4666
4410
|
}
|
|
4667
4411
|
function createKeyToOldIdx(children, beginIdx, endIdx) {
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
|
|
4680
|
-
}
|
|
4681
|
-
return map;
|
|
4412
|
+
const map = {};
|
|
4413
|
+
// TODO [#1637]: simplify this by assuming that all vnodes has keys
|
|
4414
|
+
for (let j = beginIdx; j <= endIdx; ++j) {
|
|
4415
|
+
const ch = children[j];
|
|
4416
|
+
if (isVNode(ch)) {
|
|
4417
|
+
const { key } = ch;
|
|
4418
|
+
if (key !== undefined) {
|
|
4419
|
+
map[key] = j;
|
|
4420
|
+
}
|
|
4421
|
+
}
|
|
4422
|
+
}
|
|
4423
|
+
return map;
|
|
4682
4424
|
}
|
|
4683
4425
|
function updateDynamicChildren(oldCh, newCh, parent, renderer) {
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
|
|
4694
|
-
|
|
4695
|
-
|
|
4696
|
-
|
|
4697
|
-
|
|
4698
|
-
|
|
4699
|
-
|
|
4700
|
-
|
|
4701
|
-
|
|
4702
|
-
|
|
4703
|
-
|
|
4704
|
-
|
|
4705
|
-
|
|
4706
|
-
|
|
4707
|
-
|
|
4708
|
-
|
|
4709
|
-
|
|
4710
|
-
|
|
4711
|
-
|
|
4712
|
-
|
|
4713
|
-
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
|
|
4730
|
-
|
|
4731
|
-
|
|
4732
|
-
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
if (isVNode(elmToMove)) {
|
|
4739
|
-
if (elmToMove.sel !== newStartVnode.sel) {
|
|
4740
|
-
// New element
|
|
4741
|
-
mount(newStartVnode, parent, renderer, oldStartVnode.elm);
|
|
4742
|
-
} else {
|
|
4743
|
-
patch(elmToMove, newStartVnode, parent, renderer);
|
|
4744
|
-
// Delete the old child, but copy the array since it is read-only.
|
|
4745
|
-
// The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
|
|
4746
|
-
// so we only care about the `oldCh` object inside this function.
|
|
4747
|
-
// To avoid cloning over and over again, we check `clonedOldCh`
|
|
4748
|
-
// and only clone once.
|
|
4749
|
-
if (!clonedOldCh) {
|
|
4750
|
-
clonedOldCh = true;
|
|
4751
|
-
oldCh = [...oldCh];
|
|
4426
|
+
let oldStartIdx = 0;
|
|
4427
|
+
let newStartIdx = 0;
|
|
4428
|
+
let oldEndIdx = oldCh.length - 1;
|
|
4429
|
+
let oldStartVnode = oldCh[0];
|
|
4430
|
+
let oldEndVnode = oldCh[oldEndIdx];
|
|
4431
|
+
const newChEnd = newCh.length - 1;
|
|
4432
|
+
let newEndIdx = newChEnd;
|
|
4433
|
+
let newStartVnode = newCh[0];
|
|
4434
|
+
let newEndVnode = newCh[newEndIdx];
|
|
4435
|
+
let oldKeyToIdx;
|
|
4436
|
+
let idxInOld;
|
|
4437
|
+
let elmToMove;
|
|
4438
|
+
let before;
|
|
4439
|
+
let clonedOldCh = false;
|
|
4440
|
+
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
|
4441
|
+
if (!isVNode(oldStartVnode)) {
|
|
4442
|
+
oldStartVnode = oldCh[++oldStartIdx]; // Vnode might have been moved left
|
|
4443
|
+
}
|
|
4444
|
+
else if (!isVNode(oldEndVnode)) {
|
|
4445
|
+
oldEndVnode = oldCh[--oldEndIdx];
|
|
4446
|
+
}
|
|
4447
|
+
else if (!isVNode(newStartVnode)) {
|
|
4448
|
+
newStartVnode = newCh[++newStartIdx];
|
|
4449
|
+
}
|
|
4450
|
+
else if (!isVNode(newEndVnode)) {
|
|
4451
|
+
newEndVnode = newCh[--newEndIdx];
|
|
4452
|
+
}
|
|
4453
|
+
else if (isSameVnode(oldStartVnode, newStartVnode)) {
|
|
4454
|
+
patch(oldStartVnode, newStartVnode, parent, renderer);
|
|
4455
|
+
oldStartVnode = oldCh[++oldStartIdx];
|
|
4456
|
+
newStartVnode = newCh[++newStartIdx];
|
|
4457
|
+
}
|
|
4458
|
+
else if (isSameVnode(oldEndVnode, newEndVnode)) {
|
|
4459
|
+
patch(oldEndVnode, newEndVnode, parent, renderer);
|
|
4460
|
+
oldEndVnode = oldCh[--oldEndIdx];
|
|
4461
|
+
newEndVnode = newCh[--newEndIdx];
|
|
4462
|
+
}
|
|
4463
|
+
else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
4464
|
+
// Vnode moved right
|
|
4465
|
+
patch(oldStartVnode, newEndVnode, parent, renderer);
|
|
4466
|
+
insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
|
|
4467
|
+
oldStartVnode = oldCh[++oldStartIdx];
|
|
4468
|
+
newEndVnode = newCh[--newEndIdx];
|
|
4469
|
+
}
|
|
4470
|
+
else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
4471
|
+
// Vnode moved left
|
|
4472
|
+
patch(oldEndVnode, newStartVnode, parent, renderer);
|
|
4473
|
+
insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
|
|
4474
|
+
oldEndVnode = oldCh[--oldEndIdx];
|
|
4475
|
+
newStartVnode = newCh[++newStartIdx];
|
|
4476
|
+
}
|
|
4477
|
+
else {
|
|
4478
|
+
if (oldKeyToIdx === undefined) {
|
|
4479
|
+
oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
|
|
4752
4480
|
}
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
|
|
4481
|
+
idxInOld = oldKeyToIdx[newStartVnode.key];
|
|
4482
|
+
if (isUndefined$1(idxInOld)) {
|
|
4483
|
+
// New element
|
|
4484
|
+
mount(newStartVnode, parent, renderer, oldStartVnode.elm);
|
|
4485
|
+
newStartVnode = newCh[++newStartIdx];
|
|
4486
|
+
}
|
|
4487
|
+
else {
|
|
4488
|
+
elmToMove = oldCh[idxInOld];
|
|
4489
|
+
if (isVNode(elmToMove)) {
|
|
4490
|
+
if (elmToMove.sel !== newStartVnode.sel) {
|
|
4491
|
+
// New element
|
|
4492
|
+
mount(newStartVnode, parent, renderer, oldStartVnode.elm);
|
|
4493
|
+
}
|
|
4494
|
+
else {
|
|
4495
|
+
patch(elmToMove, newStartVnode, parent, renderer);
|
|
4496
|
+
// Delete the old child, but copy the array since it is read-only.
|
|
4497
|
+
// The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
|
|
4498
|
+
// so we only care about the `oldCh` object inside this function.
|
|
4499
|
+
// To avoid cloning over and over again, we check `clonedOldCh`
|
|
4500
|
+
// and only clone once.
|
|
4501
|
+
if (!clonedOldCh) {
|
|
4502
|
+
clonedOldCh = true;
|
|
4503
|
+
oldCh = [...oldCh];
|
|
4504
|
+
}
|
|
4505
|
+
// We've already cloned at least once, so it's no longer read-only
|
|
4506
|
+
oldCh[idxInOld] = undefined;
|
|
4507
|
+
insertNode(elmToMove.elm, parent, oldStartVnode.elm, renderer);
|
|
4508
|
+
}
|
|
4509
|
+
}
|
|
4510
|
+
newStartVnode = newCh[++newStartIdx];
|
|
4511
|
+
}
|
|
4512
|
+
}
|
|
4513
|
+
}
|
|
4514
|
+
if (oldStartIdx <= oldEndIdx || newStartIdx <= newEndIdx) {
|
|
4515
|
+
if (oldStartIdx > oldEndIdx) {
|
|
4516
|
+
// There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
|
|
4517
|
+
// already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
|
|
4518
|
+
let i = newEndIdx;
|
|
4519
|
+
let n;
|
|
4520
|
+
do {
|
|
4521
|
+
n = newCh[++i];
|
|
4522
|
+
} while (!isVNode(n) && i < newChEnd);
|
|
4523
|
+
before = isVNode(n) ? n.elm : null;
|
|
4524
|
+
mountVNodes(newCh, parent, renderer, before, newStartIdx, newEndIdx + 1);
|
|
4525
|
+
}
|
|
4526
|
+
else {
|
|
4527
|
+
unmountVNodes(oldCh, parent, renderer, true, oldStartIdx, oldEndIdx + 1);
|
|
4528
|
+
}
|
|
4529
|
+
}
|
|
4777
4530
|
}
|
|
4778
4531
|
function updateStaticChildren(c1, c2, parent, renderer) {
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
|
|
4813
|
-
|
|
4532
|
+
const c1Length = c1.length;
|
|
4533
|
+
const c2Length = c2.length;
|
|
4534
|
+
if (c1Length === 0) {
|
|
4535
|
+
// the old list is empty, we can directly insert anything new
|
|
4536
|
+
mountVNodes(c2, parent, renderer, null);
|
|
4537
|
+
return;
|
|
4538
|
+
}
|
|
4539
|
+
if (c2Length === 0) {
|
|
4540
|
+
// the old list is nonempty and the new list is empty so we can directly remove all old nodes
|
|
4541
|
+
// this is the case in which the dynamic children of an if-directive should be removed
|
|
4542
|
+
unmountVNodes(c1, parent, renderer, true);
|
|
4543
|
+
return;
|
|
4544
|
+
}
|
|
4545
|
+
// if the old list is not empty, the new list MUST have the same
|
|
4546
|
+
// amount of nodes, that's why we call this static children
|
|
4547
|
+
let anchor = null;
|
|
4548
|
+
for (let i = c2Length - 1; i >= 0; i -= 1) {
|
|
4549
|
+
const n1 = c1[i];
|
|
4550
|
+
const n2 = c2[i];
|
|
4551
|
+
if (n2 !== n1) {
|
|
4552
|
+
if (isVNode(n1)) {
|
|
4553
|
+
if (isVNode(n2)) {
|
|
4554
|
+
// both vnodes are equivalent, and we just need to patch them
|
|
4555
|
+
patch(n1, n2, parent, renderer);
|
|
4556
|
+
anchor = n2.elm;
|
|
4557
|
+
}
|
|
4558
|
+
else {
|
|
4559
|
+
// removing the old vnode since the new one is null
|
|
4560
|
+
unmount(n1, parent, renderer, true);
|
|
4561
|
+
}
|
|
4562
|
+
}
|
|
4563
|
+
else if (isVNode(n2)) {
|
|
4564
|
+
mount(n2, parent, renderer, anchor);
|
|
4565
|
+
anchor = n2.elm;
|
|
4566
|
+
}
|
|
4567
|
+
}
|
|
4568
|
+
}
|
|
4814
4569
|
}
|
|
4815
4570
|
|
|
4816
4571
|
/*
|
|
@@ -5747,398 +5502,366 @@ let idx = 0;
|
|
|
5747
5502
|
/** The internal slot used to associate different objects the engine manipulates with the VM */
|
|
5748
5503
|
const ViewModelReflection = new WeakMap();
|
|
5749
5504
|
function callHook(cmp, fn, args = []) {
|
|
5750
|
-
|
|
5505
|
+
return fn.apply(cmp, args);
|
|
5751
5506
|
}
|
|
5752
5507
|
function setHook(cmp, prop, newValue) {
|
|
5753
|
-
|
|
5508
|
+
cmp[prop] = newValue;
|
|
5754
5509
|
}
|
|
5755
5510
|
function getHook(cmp, prop) {
|
|
5756
|
-
|
|
5511
|
+
return cmp[prop];
|
|
5757
5512
|
}
|
|
5758
5513
|
function rerenderVM(vm) {
|
|
5759
|
-
|
|
5514
|
+
rehydrate(vm);
|
|
5760
5515
|
}
|
|
5761
5516
|
function connectRootElement(elm) {
|
|
5762
|
-
|
|
5763
|
-
|
|
5764
|
-
|
|
5765
|
-
|
|
5766
|
-
|
|
5767
|
-
|
|
5768
|
-
|
|
5769
|
-
|
|
5770
|
-
|
|
5771
|
-
|
|
5517
|
+
const vm = getAssociatedVM(elm);
|
|
5518
|
+
logGlobalOperationStart(7 /* OperationId.GlobalHydrate */, vm);
|
|
5519
|
+
// Usually means moving the element from one place to another, which is observable via
|
|
5520
|
+
// life-cycle hooks.
|
|
5521
|
+
if (vm.state === 1 /* VMState.connected */) {
|
|
5522
|
+
disconnectRootElement(elm);
|
|
5523
|
+
}
|
|
5524
|
+
runConnectedCallback(vm);
|
|
5525
|
+
rehydrate(vm);
|
|
5526
|
+
logGlobalOperationEnd(7 /* OperationId.GlobalHydrate */, vm);
|
|
5772
5527
|
}
|
|
5773
5528
|
function disconnectRootElement(elm) {
|
|
5774
|
-
|
|
5775
|
-
|
|
5529
|
+
const vm = getAssociatedVM(elm);
|
|
5530
|
+
resetComponentStateWhenRemoved(vm);
|
|
5776
5531
|
}
|
|
5777
5532
|
function appendVM(vm) {
|
|
5778
|
-
|
|
5533
|
+
rehydrate(vm);
|
|
5779
5534
|
}
|
|
5780
5535
|
// just in case the component comes back, with this we guarantee re-rendering it
|
|
5781
5536
|
// while preventing any attempt to rehydration until after reinsertion.
|
|
5782
5537
|
function resetComponentStateWhenRemoved(vm) {
|
|
5783
|
-
|
|
5784
|
-
state
|
|
5785
|
-
|
|
5786
|
-
|
|
5787
|
-
|
|
5788
|
-
|
|
5789
|
-
|
|
5790
|
-
|
|
5791
|
-
|
|
5792
|
-
|
|
5793
|
-
|
|
5794
|
-
|
|
5795
|
-
|
|
5796
|
-
}
|
|
5797
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
5798
|
-
removeActiveVM(vm);
|
|
5799
|
-
}
|
|
5538
|
+
const { state } = vm;
|
|
5539
|
+
if (state !== 2 /* VMState.disconnected */) {
|
|
5540
|
+
const { tro } = vm;
|
|
5541
|
+
// Making sure that any observing record will not trigger the rehydrated on this vm
|
|
5542
|
+
tro.reset();
|
|
5543
|
+
runDisconnectedCallback(vm);
|
|
5544
|
+
// Spec: https://dom.spec.whatwg.org/#concept-node-remove (step 14-15)
|
|
5545
|
+
runChildNodesDisconnectedCallback(vm);
|
|
5546
|
+
runLightChildNodesDisconnectedCallback(vm);
|
|
5547
|
+
}
|
|
5548
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
5549
|
+
removeActiveVM(vm);
|
|
5550
|
+
}
|
|
5800
5551
|
}
|
|
5801
5552
|
// this method is triggered by the diffing algo only when a vnode from the
|
|
5802
5553
|
// old vnode.children is removed from the DOM.
|
|
5803
5554
|
function removeVM(vm) {
|
|
5804
|
-
|
|
5805
|
-
|
|
5806
|
-
|
|
5807
|
-
|
|
5555
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
5556
|
+
assert.isTrue(vm.state === 1 /* VMState.connected */ || vm.state === 2 /* VMState.disconnected */, `${vm} must have been connected.`);
|
|
5557
|
+
}
|
|
5558
|
+
resetComponentStateWhenRemoved(vm);
|
|
5808
5559
|
}
|
|
5809
5560
|
function getNearestShadowAncestor(vm) {
|
|
5810
|
-
|
|
5811
|
-
|
|
5812
|
-
|
|
5813
|
-
|
|
5814
|
-
|
|
5561
|
+
let ancestor = vm.owner;
|
|
5562
|
+
while (!isNull(ancestor) && ancestor.renderMode === 0 /* RenderMode.Light */) {
|
|
5563
|
+
ancestor = ancestor.owner;
|
|
5564
|
+
}
|
|
5565
|
+
return ancestor;
|
|
5815
5566
|
}
|
|
5816
5567
|
function createVM(elm, ctor, renderer, options) {
|
|
5817
|
-
|
|
5818
|
-
|
|
5819
|
-
|
|
5820
|
-
|
|
5821
|
-
|
|
5822
|
-
|
|
5823
|
-
|
|
5824
|
-
|
|
5825
|
-
|
|
5826
|
-
|
|
5827
|
-
|
|
5828
|
-
|
|
5829
|
-
|
|
5830
|
-
|
|
5831
|
-
|
|
5832
|
-
|
|
5833
|
-
|
|
5834
|
-
|
|
5835
|
-
|
|
5836
|
-
|
|
5837
|
-
|
|
5838
|
-
|
|
5839
|
-
|
|
5840
|
-
|
|
5841
|
-
|
|
5842
|
-
|
|
5843
|
-
|
|
5844
|
-
|
|
5845
|
-
|
|
5846
|
-
|
|
5847
|
-
|
|
5848
|
-
|
|
5849
|
-
|
|
5850
|
-
|
|
5851
|
-
|
|
5852
|
-
|
|
5853
|
-
|
|
5854
|
-
|
|
5855
|
-
|
|
5856
|
-
|
|
5857
|
-
|
|
5858
|
-
|
|
5859
|
-
|
|
5860
|
-
|
|
5861
|
-
component: null,
|
|
5862
|
-
shadowRoot: null,
|
|
5863
|
-
renderRoot: null,
|
|
5864
|
-
callHook,
|
|
5865
|
-
setHook,
|
|
5866
|
-
getHook,
|
|
5867
|
-
renderer
|
|
5868
|
-
};
|
|
5869
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
5870
|
-
vm.debugInfo = create(null);
|
|
5871
|
-
}
|
|
5872
|
-
vm.stylesheets = computeStylesheets(vm, def.ctor);
|
|
5873
|
-
vm.shadowMode = computeShadowMode(vm, renderer);
|
|
5874
|
-
vm.tro = getTemplateReactiveObserver();
|
|
5875
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
5876
|
-
vm.toString = () => {
|
|
5877
|
-
return `[object:vm ${def.name} (${vm.idx})]`;
|
|
5568
|
+
const { mode, owner, tagName, hydrated } = options;
|
|
5569
|
+
const def = getComponentInternalDef(ctor);
|
|
5570
|
+
const vm = {
|
|
5571
|
+
elm,
|
|
5572
|
+
def,
|
|
5573
|
+
idx: idx++,
|
|
5574
|
+
state: 0 /* VMState.created */,
|
|
5575
|
+
isScheduled: false,
|
|
5576
|
+
isDirty: true,
|
|
5577
|
+
tagName,
|
|
5578
|
+
mode,
|
|
5579
|
+
owner,
|
|
5580
|
+
refVNodes: null,
|
|
5581
|
+
children: EmptyArray,
|
|
5582
|
+
aChildren: EmptyArray,
|
|
5583
|
+
velements: EmptyArray,
|
|
5584
|
+
cmpProps: create(null),
|
|
5585
|
+
cmpFields: create(null),
|
|
5586
|
+
cmpSlots: { slotAssignments: create(null) },
|
|
5587
|
+
cmpTemplate: null,
|
|
5588
|
+
hydrated: Boolean(hydrated),
|
|
5589
|
+
renderMode: def.renderMode,
|
|
5590
|
+
context: {
|
|
5591
|
+
stylesheetToken: undefined,
|
|
5592
|
+
hasTokenInClass: undefined,
|
|
5593
|
+
hasTokenInAttribute: undefined,
|
|
5594
|
+
hasScopedStyles: undefined,
|
|
5595
|
+
styleVNodes: null,
|
|
5596
|
+
tplCache: EmptyObject,
|
|
5597
|
+
wiredConnecting: EmptyArray,
|
|
5598
|
+
wiredDisconnecting: EmptyArray,
|
|
5599
|
+
},
|
|
5600
|
+
// Properties set right after VM creation.
|
|
5601
|
+
tro: null,
|
|
5602
|
+
shadowMode: null,
|
|
5603
|
+
stylesheets: null,
|
|
5604
|
+
// Properties set by the LightningElement constructor.
|
|
5605
|
+
component: null,
|
|
5606
|
+
shadowRoot: null,
|
|
5607
|
+
renderRoot: null,
|
|
5608
|
+
callHook,
|
|
5609
|
+
setHook,
|
|
5610
|
+
getHook,
|
|
5611
|
+
renderer,
|
|
5878
5612
|
};
|
|
5879
|
-
if (
|
|
5880
|
-
|
|
5881
|
-
}
|
|
5882
|
-
|
|
5883
|
-
|
|
5884
|
-
|
|
5885
|
-
|
|
5886
|
-
|
|
5887
|
-
|
|
5888
|
-
|
|
5889
|
-
|
|
5613
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
5614
|
+
vm.debugInfo = create(null);
|
|
5615
|
+
}
|
|
5616
|
+
vm.stylesheets = computeStylesheets(vm, def.ctor);
|
|
5617
|
+
vm.shadowMode = computeShadowMode(vm, renderer);
|
|
5618
|
+
vm.tro = getTemplateReactiveObserver();
|
|
5619
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
5620
|
+
vm.toString = () => {
|
|
5621
|
+
return `[object:vm ${def.name} (${vm.idx})]`;
|
|
5622
|
+
};
|
|
5623
|
+
if (lwcRuntimeFlags.ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST) {
|
|
5624
|
+
vm.shadowMode = 0 /* ShadowMode.Native */;
|
|
5625
|
+
}
|
|
5626
|
+
}
|
|
5627
|
+
// Create component instance associated to the vm and the element.
|
|
5628
|
+
invokeComponentConstructor(vm, def.ctor);
|
|
5629
|
+
// Initializing the wire decorator per instance only when really needed
|
|
5630
|
+
if (hasWireAdapters(vm)) {
|
|
5631
|
+
installWireAdapters(vm);
|
|
5632
|
+
}
|
|
5633
|
+
return vm;
|
|
5890
5634
|
}
|
|
5891
5635
|
function validateComponentStylesheets(vm, stylesheets) {
|
|
5892
|
-
|
|
5893
|
-
|
|
5894
|
-
|
|
5895
|
-
|
|
5896
|
-
|
|
5897
|
-
|
|
5898
|
-
|
|
5899
|
-
|
|
5900
|
-
|
|
5901
|
-
|
|
5902
|
-
|
|
5903
|
-
|
|
5904
|
-
|
|
5905
|
-
|
|
5906
|
-
|
|
5907
|
-
|
|
5908
|
-
|
|
5636
|
+
let valid = true;
|
|
5637
|
+
const validate = (arrayOrStylesheet) => {
|
|
5638
|
+
if (isArray$1(arrayOrStylesheet)) {
|
|
5639
|
+
for (let i = 0; i < arrayOrStylesheet.length; i++) {
|
|
5640
|
+
validate(arrayOrStylesheet[i]);
|
|
5641
|
+
}
|
|
5642
|
+
}
|
|
5643
|
+
else if (!isFunction$1(arrayOrStylesheet)) {
|
|
5644
|
+
// function assumed to be a stylesheet factory
|
|
5645
|
+
valid = false;
|
|
5646
|
+
}
|
|
5647
|
+
};
|
|
5648
|
+
if (!isArray$1(stylesheets)) {
|
|
5649
|
+
valid = false;
|
|
5650
|
+
}
|
|
5651
|
+
else {
|
|
5652
|
+
validate(stylesheets);
|
|
5653
|
+
}
|
|
5654
|
+
return valid;
|
|
5909
5655
|
}
|
|
5910
5656
|
// Validate and flatten any stylesheets defined as `static stylesheets`
|
|
5911
5657
|
function computeStylesheets(vm, ctor) {
|
|
5912
|
-
|
|
5913
|
-
|
|
5914
|
-
stylesheets
|
|
5915
|
-
|
|
5916
|
-
|
|
5917
|
-
|
|
5918
|
-
|
|
5919
|
-
|
|
5920
|
-
|
|
5921
|
-
|
|
5922
|
-
}
|
|
5923
|
-
|
|
5924
|
-
return null;
|
|
5658
|
+
warnOnStylesheetsMutation(ctor);
|
|
5659
|
+
const { stylesheets } = ctor;
|
|
5660
|
+
if (!isUndefined$1(stylesheets)) {
|
|
5661
|
+
const valid = validateComponentStylesheets(vm, stylesheets);
|
|
5662
|
+
if (valid) {
|
|
5663
|
+
return flattenStylesheets(stylesheets);
|
|
5664
|
+
}
|
|
5665
|
+
else if (process.env.NODE_ENV !== 'production') {
|
|
5666
|
+
logError(`static stylesheets must be an array of CSS stylesheets. Found invalid stylesheets on <${vm.tagName}>`, vm);
|
|
5667
|
+
}
|
|
5668
|
+
}
|
|
5669
|
+
return null;
|
|
5925
5670
|
}
|
|
5926
5671
|
function warnOnStylesheetsMutation(ctor) {
|
|
5927
|
-
|
|
5928
|
-
|
|
5929
|
-
|
|
5930
|
-
|
|
5931
|
-
|
|
5932
|
-
|
|
5933
|
-
|
|
5934
|
-
|
|
5935
|
-
|
|
5936
|
-
|
|
5937
|
-
|
|
5938
|
-
|
|
5939
|
-
|
|
5940
|
-
|
|
5941
|
-
}
|
|
5942
|
-
}
|
|
5672
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
5673
|
+
let { stylesheets } = ctor;
|
|
5674
|
+
defineProperty(ctor, 'stylesheets', {
|
|
5675
|
+
enumerable: true,
|
|
5676
|
+
configurable: true,
|
|
5677
|
+
get() {
|
|
5678
|
+
return stylesheets;
|
|
5679
|
+
},
|
|
5680
|
+
set(newValue) {
|
|
5681
|
+
logWarnOnce(`Dynamically setting the "stylesheets" static property on ${ctor.name} ` +
|
|
5682
|
+
'will not affect the stylesheets injected.');
|
|
5683
|
+
stylesheets = newValue;
|
|
5684
|
+
},
|
|
5685
|
+
});
|
|
5686
|
+
}
|
|
5943
5687
|
}
|
|
5944
5688
|
function computeShadowMode(vm, renderer) {
|
|
5945
|
-
|
|
5946
|
-
|
|
5947
|
-
|
|
5948
|
-
|
|
5949
|
-
|
|
5950
|
-
|
|
5951
|
-
|
|
5952
|
-
let shadowMode;
|
|
5953
|
-
if (isSyntheticShadowDefined) {
|
|
5954
|
-
if (def.renderMode === 0 /* RenderMode.Light */) {
|
|
5955
|
-
// ShadowMode.Native implies "not synthetic shadow" which is consistent with how
|
|
5956
|
-
// everything defaults to native when the synthetic shadow polyfill is unavailable.
|
|
5957
|
-
shadowMode = 0 /* ShadowMode.Native */;
|
|
5958
|
-
} else if (isNativeShadowDefined) {
|
|
5959
|
-
// Not combined with above condition because @lwc/features only supports identifiers in
|
|
5960
|
-
// the if-condition.
|
|
5961
|
-
if (lwcRuntimeFlags.ENABLE_MIXED_SHADOW_MODE) {
|
|
5962
|
-
if (def.shadowSupportMode === "any" /* ShadowSupportMode.Any */) {
|
|
5963
|
-
shadowMode = 0 /* ShadowMode.Native */;
|
|
5964
|
-
} else {
|
|
5965
|
-
const shadowAncestor = getNearestShadowAncestor(vm);
|
|
5966
|
-
if (!isNull(shadowAncestor) && shadowAncestor.shadowMode === 0 /* ShadowMode.Native */) {
|
|
5967
|
-
// Transitive support for native Shadow DOM. A component in native mode
|
|
5968
|
-
// transitively opts all of its descendants into native.
|
|
5689
|
+
const { def } = vm;
|
|
5690
|
+
const { isSyntheticShadowDefined, isNativeShadowDefined } = renderer;
|
|
5691
|
+
let shadowMode;
|
|
5692
|
+
if (isSyntheticShadowDefined) {
|
|
5693
|
+
if (def.renderMode === 0 /* RenderMode.Light */) {
|
|
5694
|
+
// ShadowMode.Native implies "not synthetic shadow" which is consistent with how
|
|
5695
|
+
// everything defaults to native when the synthetic shadow polyfill is unavailable.
|
|
5969
5696
|
shadowMode = 0 /* ShadowMode.Native */;
|
|
5970
|
-
|
|
5971
|
-
|
|
5972
|
-
//
|
|
5697
|
+
}
|
|
5698
|
+
else if (isNativeShadowDefined) {
|
|
5699
|
+
// Not combined with above condition because @lwc/features only supports identifiers in
|
|
5700
|
+
// the if-condition.
|
|
5701
|
+
if (lwcRuntimeFlags.ENABLE_MIXED_SHADOW_MODE) {
|
|
5702
|
+
if (def.shadowSupportMode === "any" /* ShadowSupportMode.Any */) {
|
|
5703
|
+
shadowMode = 0 /* ShadowMode.Native */;
|
|
5704
|
+
}
|
|
5705
|
+
else {
|
|
5706
|
+
const shadowAncestor = getNearestShadowAncestor(vm);
|
|
5707
|
+
if (!isNull(shadowAncestor) &&
|
|
5708
|
+
shadowAncestor.shadowMode === 0 /* ShadowMode.Native */) {
|
|
5709
|
+
// Transitive support for native Shadow DOM. A component in native mode
|
|
5710
|
+
// transitively opts all of its descendants into native.
|
|
5711
|
+
shadowMode = 0 /* ShadowMode.Native */;
|
|
5712
|
+
}
|
|
5713
|
+
else {
|
|
5714
|
+
// Synthetic if neither this component nor any of its ancestors are configured
|
|
5715
|
+
// to be native.
|
|
5716
|
+
shadowMode = 1 /* ShadowMode.Synthetic */;
|
|
5717
|
+
}
|
|
5718
|
+
}
|
|
5719
|
+
}
|
|
5720
|
+
else {
|
|
5721
|
+
shadowMode = 1 /* ShadowMode.Synthetic */;
|
|
5722
|
+
}
|
|
5723
|
+
}
|
|
5724
|
+
else {
|
|
5725
|
+
// Synthetic if there is no native Shadow DOM support.
|
|
5973
5726
|
shadowMode = 1 /* ShadowMode.Synthetic */;
|
|
5974
|
-
|
|
5975
|
-
|
|
5976
|
-
|
|
5977
|
-
|
|
5978
|
-
|
|
5979
|
-
}
|
|
5980
|
-
|
|
5981
|
-
shadowMode = 1 /* ShadowMode.Synthetic */;
|
|
5982
|
-
}
|
|
5983
|
-
} else {
|
|
5984
|
-
// Native if the synthetic shadow polyfill is unavailable.
|
|
5985
|
-
shadowMode = 0 /* ShadowMode.Native */;
|
|
5986
|
-
}
|
|
5987
|
-
|
|
5988
|
-
return shadowMode;
|
|
5727
|
+
}
|
|
5728
|
+
}
|
|
5729
|
+
else {
|
|
5730
|
+
// Native if the synthetic shadow polyfill is unavailable.
|
|
5731
|
+
shadowMode = 0 /* ShadowMode.Native */;
|
|
5732
|
+
}
|
|
5733
|
+
return shadowMode;
|
|
5989
5734
|
}
|
|
5990
5735
|
function assertIsVM(obj) {
|
|
5991
|
-
|
|
5992
|
-
|
|
5993
|
-
|
|
5736
|
+
if (isNull(obj) || !isObject(obj) || !('renderRoot' in obj)) {
|
|
5737
|
+
throw new TypeError(`${obj} is not a VM.`);
|
|
5738
|
+
}
|
|
5994
5739
|
}
|
|
5995
5740
|
function associateVM(obj, vm) {
|
|
5996
|
-
|
|
5741
|
+
ViewModelReflection.set(obj, vm);
|
|
5997
5742
|
}
|
|
5998
5743
|
function getAssociatedVM(obj) {
|
|
5999
|
-
|
|
6000
|
-
|
|
6001
|
-
|
|
6002
|
-
|
|
6003
|
-
|
|
5744
|
+
const vm = ViewModelReflection.get(obj);
|
|
5745
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
5746
|
+
assertIsVM(vm);
|
|
5747
|
+
}
|
|
5748
|
+
return vm;
|
|
6004
5749
|
}
|
|
6005
5750
|
function getAssociatedVMIfPresent(obj) {
|
|
6006
|
-
|
|
6007
|
-
|
|
6008
|
-
|
|
6009
|
-
|
|
5751
|
+
const maybeVm = ViewModelReflection.get(obj);
|
|
5752
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
5753
|
+
if (!isUndefined$1(maybeVm)) {
|
|
5754
|
+
assertIsVM(maybeVm);
|
|
5755
|
+
}
|
|
6010
5756
|
}
|
|
6011
|
-
|
|
6012
|
-
return maybeVm;
|
|
5757
|
+
return maybeVm;
|
|
6013
5758
|
}
|
|
6014
5759
|
function rehydrate(vm) {
|
|
6015
|
-
|
|
6016
|
-
|
|
6017
|
-
|
|
6018
|
-
|
|
5760
|
+
if (isTrue(vm.isDirty)) {
|
|
5761
|
+
const children = renderComponent$1(vm);
|
|
5762
|
+
patchShadowRoot(vm, children);
|
|
5763
|
+
}
|
|
6019
5764
|
}
|
|
6020
5765
|
function patchShadowRoot(vm, newCh) {
|
|
6021
|
-
|
|
6022
|
-
|
|
6023
|
-
children
|
|
6024
|
-
|
|
6025
|
-
|
|
6026
|
-
|
|
6027
|
-
|
|
6028
|
-
|
|
6029
|
-
|
|
6030
|
-
|
|
6031
|
-
|
|
6032
|
-
|
|
6033
|
-
|
|
6034
|
-
|
|
6035
|
-
|
|
6036
|
-
|
|
6037
|
-
|
|
6038
|
-
|
|
6039
|
-
// post
|
|
6040
|
-
logOperationEnd(2 /* OperationId.Patch */, vm);
|
|
6041
|
-
});
|
|
5766
|
+
const { renderRoot, children: oldCh, renderer } = vm;
|
|
5767
|
+
// caching the new children collection
|
|
5768
|
+
vm.children = newCh;
|
|
5769
|
+
if (newCh.length > 0 || oldCh.length > 0) {
|
|
5770
|
+
// patch function mutates vnodes by adding the element reference,
|
|
5771
|
+
// however, if patching fails it contains partial changes.
|
|
5772
|
+
if (oldCh !== newCh) {
|
|
5773
|
+
runWithBoundaryProtection(vm, vm, () => {
|
|
5774
|
+
// pre
|
|
5775
|
+
logOperationStart(2 /* OperationId.Patch */, vm);
|
|
5776
|
+
}, () => {
|
|
5777
|
+
// job
|
|
5778
|
+
patchChildren(oldCh, newCh, renderRoot, renderer);
|
|
5779
|
+
}, () => {
|
|
5780
|
+
// post
|
|
5781
|
+
logOperationEnd(2 /* OperationId.Patch */, vm);
|
|
5782
|
+
});
|
|
5783
|
+
}
|
|
6042
5784
|
}
|
|
6043
|
-
|
|
6044
|
-
if (vm.state === 1 /* VMState.connected */) ;
|
|
5785
|
+
if (vm.state === 1 /* VMState.connected */) ;
|
|
6045
5786
|
}
|
|
6046
|
-
|
|
6047
5787
|
function runConnectedCallback(vm) {
|
|
6048
|
-
|
|
6049
|
-
state
|
|
6050
|
-
|
|
6051
|
-
|
|
6052
|
-
|
|
6053
|
-
|
|
6054
|
-
|
|
6055
|
-
|
|
6056
|
-
|
|
6057
|
-
|
|
6058
|
-
|
|
6059
|
-
|
|
6060
|
-
|
|
6061
|
-
|
|
6062
|
-
|
|
6063
|
-
|
|
6064
|
-
|
|
6065
|
-
|
|
6066
|
-
|
|
6067
|
-
connectedCallback
|
|
6068
|
-
} = vm.def;
|
|
6069
|
-
if (!isUndefined$1(connectedCallback)) {
|
|
6070
|
-
logOperationStart(3 /* OperationId.ConnectedCallback */, vm);
|
|
6071
|
-
invokeComponentCallback(vm, connectedCallback);
|
|
6072
|
-
logOperationEnd(3 /* OperationId.ConnectedCallback */, vm);
|
|
6073
|
-
}
|
|
5788
|
+
const { state } = vm;
|
|
5789
|
+
if (state === 1 /* VMState.connected */) {
|
|
5790
|
+
return; // nothing to do since it was already connected
|
|
5791
|
+
}
|
|
5792
|
+
vm.state = 1 /* VMState.connected */;
|
|
5793
|
+
// reporting connection
|
|
5794
|
+
const { connected } = Services;
|
|
5795
|
+
if (connected) {
|
|
5796
|
+
invokeServiceHook(vm, connected);
|
|
5797
|
+
}
|
|
5798
|
+
if (hasWireAdapters(vm)) {
|
|
5799
|
+
connectWireAdapters(vm);
|
|
5800
|
+
}
|
|
5801
|
+
const { connectedCallback } = vm.def;
|
|
5802
|
+
if (!isUndefined$1(connectedCallback)) {
|
|
5803
|
+
logOperationStart(3 /* OperationId.ConnectedCallback */, vm);
|
|
5804
|
+
invokeComponentCallback(vm, connectedCallback);
|
|
5805
|
+
logOperationEnd(3 /* OperationId.ConnectedCallback */, vm);
|
|
5806
|
+
}
|
|
6074
5807
|
}
|
|
6075
5808
|
function hasWireAdapters(vm) {
|
|
6076
|
-
|
|
5809
|
+
return getOwnPropertyNames$1(vm.def.wire).length > 0;
|
|
6077
5810
|
}
|
|
6078
5811
|
function runDisconnectedCallback(vm) {
|
|
6079
|
-
|
|
6080
|
-
|
|
6081
|
-
|
|
6082
|
-
|
|
6083
|
-
|
|
6084
|
-
|
|
6085
|
-
|
|
6086
|
-
|
|
6087
|
-
|
|
6088
|
-
|
|
6089
|
-
|
|
6090
|
-
|
|
6091
|
-
|
|
6092
|
-
disconnected
|
|
6093
|
-
|
|
6094
|
-
|
|
6095
|
-
|
|
6096
|
-
|
|
6097
|
-
|
|
6098
|
-
|
|
6099
|
-
|
|
6100
|
-
|
|
6101
|
-
|
|
6102
|
-
|
|
6103
|
-
|
|
6104
|
-
logOperationStart(5 /* OperationId.DisconnectedCallback */, vm);
|
|
6105
|
-
invokeComponentCallback(vm, disconnectedCallback);
|
|
6106
|
-
logOperationEnd(5 /* OperationId.DisconnectedCallback */, vm);
|
|
6107
|
-
}
|
|
5812
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
5813
|
+
assert.isTrue(vm.state !== 2 /* VMState.disconnected */, `${vm} must be inserted.`);
|
|
5814
|
+
}
|
|
5815
|
+
if (isFalse(vm.isDirty)) {
|
|
5816
|
+
// this guarantees that if the component is reused/reinserted,
|
|
5817
|
+
// it will be re-rendered because we are disconnecting the reactivity
|
|
5818
|
+
// linking, so mutations are not automatically reflected on the state
|
|
5819
|
+
// of disconnected components.
|
|
5820
|
+
vm.isDirty = true;
|
|
5821
|
+
}
|
|
5822
|
+
vm.state = 2 /* VMState.disconnected */;
|
|
5823
|
+
// reporting disconnection
|
|
5824
|
+
const { disconnected } = Services;
|
|
5825
|
+
if (disconnected) {
|
|
5826
|
+
invokeServiceHook(vm, disconnected);
|
|
5827
|
+
}
|
|
5828
|
+
if (hasWireAdapters(vm)) {
|
|
5829
|
+
disconnectWireAdapters(vm);
|
|
5830
|
+
}
|
|
5831
|
+
const { disconnectedCallback } = vm.def;
|
|
5832
|
+
if (!isUndefined$1(disconnectedCallback)) {
|
|
5833
|
+
logOperationStart(5 /* OperationId.DisconnectedCallback */, vm);
|
|
5834
|
+
invokeComponentCallback(vm, disconnectedCallback);
|
|
5835
|
+
logOperationEnd(5 /* OperationId.DisconnectedCallback */, vm);
|
|
5836
|
+
}
|
|
6108
5837
|
}
|
|
6109
5838
|
function runChildNodesDisconnectedCallback(vm) {
|
|
6110
|
-
|
|
6111
|
-
|
|
6112
|
-
|
|
6113
|
-
|
|
6114
|
-
|
|
6115
|
-
|
|
6116
|
-
|
|
6117
|
-
|
|
6118
|
-
|
|
6119
|
-
|
|
6120
|
-
|
|
6121
|
-
|
|
6122
|
-
|
|
6123
|
-
|
|
6124
|
-
|
|
6125
|
-
|
|
6126
|
-
|
|
6127
|
-
|
|
6128
|
-
|
|
6129
|
-
|
|
6130
|
-
|
|
6131
|
-
|
|
6132
|
-
resetComponentStateWhenRemoved(childVM);
|
|
6133
|
-
}
|
|
6134
|
-
}
|
|
6135
|
-
}
|
|
5839
|
+
const { velements: vCustomElementCollection } = vm;
|
|
5840
|
+
// Reporting disconnection for every child in inverse order since they are
|
|
5841
|
+
// inserted in reserved order.
|
|
5842
|
+
for (let i = vCustomElementCollection.length - 1; i >= 0; i -= 1) {
|
|
5843
|
+
const { elm } = vCustomElementCollection[i];
|
|
5844
|
+
// There are two cases where the element could be undefined:
|
|
5845
|
+
// * when there is an error during the construction phase, and an error
|
|
5846
|
+
// boundary picks it, there is a possibility that the VCustomElement
|
|
5847
|
+
// is not properly initialized, and therefore is should be ignored.
|
|
5848
|
+
// * when slotted custom element is not used by the element where it is
|
|
5849
|
+
// slotted into it, as a result, the custom element was never
|
|
5850
|
+
// initialized.
|
|
5851
|
+
if (!isUndefined$1(elm)) {
|
|
5852
|
+
const childVM = getAssociatedVMIfPresent(elm);
|
|
5853
|
+
// The VM associated with the element might be associated undefined
|
|
5854
|
+
// in the case where the VM failed in the middle of its creation,
|
|
5855
|
+
// eg: constructor throwing before invoking super().
|
|
5856
|
+
if (!isUndefined$1(childVM)) {
|
|
5857
|
+
resetComponentStateWhenRemoved(childVM);
|
|
5858
|
+
}
|
|
5859
|
+
}
|
|
5860
|
+
}
|
|
6136
5861
|
}
|
|
6137
5862
|
function runLightChildNodesDisconnectedCallback(vm) {
|
|
6138
|
-
|
|
6139
|
-
|
|
6140
|
-
} = vm;
|
|
6141
|
-
recursivelyDisconnectChildren(adoptedChildren);
|
|
5863
|
+
const { aChildren: adoptedChildren } = vm;
|
|
5864
|
+
recursivelyDisconnectChildren(adoptedChildren);
|
|
6142
5865
|
}
|
|
6143
5866
|
/**
|
|
6144
5867
|
* The recursion doesn't need to be a complete traversal of the vnode graph,
|
|
@@ -6148,78 +5871,72 @@ function runLightChildNodesDisconnectedCallback(vm) {
|
|
|
6148
5871
|
* defined on its shadow.
|
|
6149
5872
|
*/
|
|
6150
5873
|
function recursivelyDisconnectChildren(vnodes) {
|
|
6151
|
-
|
|
6152
|
-
|
|
6153
|
-
|
|
6154
|
-
|
|
6155
|
-
|
|
6156
|
-
|
|
6157
|
-
|
|
6158
|
-
|
|
6159
|
-
|
|
6160
|
-
|
|
6161
|
-
|
|
6162
|
-
|
|
6163
|
-
|
|
6164
|
-
|
|
5874
|
+
for (let i = 0, len = vnodes.length; i < len; i += 1) {
|
|
5875
|
+
const vnode = vnodes[i];
|
|
5876
|
+
if (!isNull(vnode) && !isUndefined$1(vnode.elm)) {
|
|
5877
|
+
switch (vnode.type) {
|
|
5878
|
+
case 2 /* VNodeType.Element */:
|
|
5879
|
+
recursivelyDisconnectChildren(vnode.children);
|
|
5880
|
+
break;
|
|
5881
|
+
case 3 /* VNodeType.CustomElement */: {
|
|
5882
|
+
const vm = getAssociatedVM(vnode.elm);
|
|
5883
|
+
resetComponentStateWhenRemoved(vm);
|
|
5884
|
+
break;
|
|
5885
|
+
}
|
|
5886
|
+
}
|
|
5887
|
+
}
|
|
6165
5888
|
}
|
|
6166
|
-
}
|
|
6167
5889
|
}
|
|
6168
5890
|
// This is a super optimized mechanism to remove the content of the root node (shadow root
|
|
6169
5891
|
// for shadow DOM components and the root element itself for light DOM) without having to go
|
|
6170
5892
|
// into snabbdom. Especially useful when the reset is a consequence of an error, in which case the
|
|
6171
5893
|
// children VNodes might not be representing the current state of the DOM.
|
|
6172
5894
|
function resetComponentRoot(vm) {
|
|
6173
|
-
|
|
6174
|
-
children
|
|
6175
|
-
|
|
6176
|
-
|
|
6177
|
-
|
|
6178
|
-
|
|
6179
|
-
|
|
6180
|
-
|
|
6181
|
-
|
|
6182
|
-
|
|
6183
|
-
remove(child.elm, renderRoot);
|
|
6184
|
-
}
|
|
6185
|
-
}
|
|
6186
|
-
vm.children = EmptyArray;
|
|
6187
|
-
runChildNodesDisconnectedCallback(vm);
|
|
6188
|
-
vm.velements = EmptyArray;
|
|
5895
|
+
const { children, renderRoot, renderer: { remove }, } = vm;
|
|
5896
|
+
for (let i = 0, len = children.length; i < len; i++) {
|
|
5897
|
+
const child = children[i];
|
|
5898
|
+
if (!isNull(child) && !isUndefined$1(child.elm)) {
|
|
5899
|
+
remove(child.elm, renderRoot);
|
|
5900
|
+
}
|
|
5901
|
+
}
|
|
5902
|
+
vm.children = EmptyArray;
|
|
5903
|
+
runChildNodesDisconnectedCallback(vm);
|
|
5904
|
+
vm.velements = EmptyArray;
|
|
6189
5905
|
}
|
|
6190
5906
|
function getErrorBoundaryVM(vm) {
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
|
|
5907
|
+
let currentVm = vm;
|
|
5908
|
+
while (!isNull(currentVm)) {
|
|
5909
|
+
if (!isUndefined$1(currentVm.def.errorCallback)) {
|
|
5910
|
+
return currentVm;
|
|
5911
|
+
}
|
|
5912
|
+
currentVm = currentVm.owner;
|
|
6195
5913
|
}
|
|
6196
|
-
currentVm = currentVm.owner;
|
|
6197
|
-
}
|
|
6198
5914
|
}
|
|
6199
5915
|
function runWithBoundaryProtection(vm, owner, pre, job, post) {
|
|
6200
|
-
|
|
6201
|
-
|
|
6202
|
-
|
|
6203
|
-
|
|
6204
|
-
|
|
6205
|
-
|
|
6206
|
-
|
|
6207
|
-
|
|
6208
|
-
|
|
6209
|
-
|
|
6210
|
-
|
|
6211
|
-
|
|
6212
|
-
|
|
6213
|
-
|
|
6214
|
-
|
|
6215
|
-
|
|
6216
|
-
|
|
6217
|
-
|
|
6218
|
-
|
|
6219
|
-
|
|
6220
|
-
|
|
5916
|
+
let error;
|
|
5917
|
+
pre();
|
|
5918
|
+
try {
|
|
5919
|
+
job();
|
|
5920
|
+
}
|
|
5921
|
+
catch (e) {
|
|
5922
|
+
error = Object(e);
|
|
5923
|
+
}
|
|
5924
|
+
finally {
|
|
5925
|
+
post();
|
|
5926
|
+
if (!isUndefined$1(error)) {
|
|
5927
|
+
addErrorComponentStack(vm, error);
|
|
5928
|
+
const errorBoundaryVm = isNull(owner) ? undefined : getErrorBoundaryVM(owner);
|
|
5929
|
+
if (isUndefined$1(errorBoundaryVm)) {
|
|
5930
|
+
throw error; // eslint-disable-line no-unsafe-finally
|
|
5931
|
+
}
|
|
5932
|
+
resetComponentRoot(vm); // remove offenders
|
|
5933
|
+
logOperationStart(6 /* OperationId.ErrorCallback */, vm);
|
|
5934
|
+
// error boundaries must have an ErrorCallback
|
|
5935
|
+
const errorCallback = errorBoundaryVm.def.errorCallback;
|
|
5936
|
+
invokeComponentCallback(errorBoundaryVm, errorCallback, [error, error.wcStack]);
|
|
5937
|
+
logOperationEnd(6 /* OperationId.ErrorCallback */, vm);
|
|
5938
|
+
}
|
|
6221
5939
|
}
|
|
6222
|
-
}
|
|
6223
5940
|
}
|
|
6224
5941
|
|
|
6225
5942
|
/*
|
|
@@ -6306,185 +6023,199 @@ function setHooks(hooks) {
|
|
|
6306
6023
|
const TEMPLATE_PROPS = ['slots', 'stylesheetToken', 'stylesheets', 'renderMode'];
|
|
6307
6024
|
// Expandos that may be placed on a stylesheet factory function, and which are meaningful to LWC at runtime
|
|
6308
6025
|
const STYLESHEET_PROPS = [
|
|
6309
|
-
// SEE `KEY__SCOPED_CSS` in @lwc/style-compiler
|
|
6310
|
-
'$scoped$'
|
|
6026
|
+
// SEE `KEY__SCOPED_CSS` in @lwc/style-compiler
|
|
6027
|
+
'$scoped$',
|
|
6028
|
+
];
|
|
6311
6029
|
// Via https://www.npmjs.com/package/object-observer
|
|
6312
|
-
const ARRAY_MUTATION_METHODS = [
|
|
6030
|
+
const ARRAY_MUTATION_METHODS = [
|
|
6031
|
+
'pop',
|
|
6032
|
+
'push',
|
|
6033
|
+
'shift',
|
|
6034
|
+
'unshift',
|
|
6035
|
+
'reverse',
|
|
6036
|
+
'sort',
|
|
6037
|
+
'fill',
|
|
6038
|
+
'splice',
|
|
6039
|
+
'copyWithin',
|
|
6040
|
+
];
|
|
6313
6041
|
let mutationTrackingDisabled = false;
|
|
6314
6042
|
function getOriginalArrayMethod(prop) {
|
|
6315
|
-
|
|
6316
|
-
|
|
6317
|
-
|
|
6318
|
-
|
|
6319
|
-
|
|
6320
|
-
|
|
6321
|
-
|
|
6322
|
-
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
|
|
6326
|
-
|
|
6327
|
-
|
|
6328
|
-
|
|
6329
|
-
|
|
6330
|
-
|
|
6331
|
-
|
|
6332
|
-
|
|
6333
|
-
|
|
6334
|
-
|
|
6043
|
+
switch (prop) {
|
|
6044
|
+
case 'pop':
|
|
6045
|
+
return ArrayPop;
|
|
6046
|
+
case 'push':
|
|
6047
|
+
return ArrayPush$1;
|
|
6048
|
+
case 'shift':
|
|
6049
|
+
return ArrayShift;
|
|
6050
|
+
case 'unshift':
|
|
6051
|
+
return ArrayUnshift;
|
|
6052
|
+
case 'reverse':
|
|
6053
|
+
return ArrayReverse;
|
|
6054
|
+
case 'sort':
|
|
6055
|
+
return ArraySort;
|
|
6056
|
+
case 'fill':
|
|
6057
|
+
return ArrayFill;
|
|
6058
|
+
case 'splice':
|
|
6059
|
+
return ArraySplice;
|
|
6060
|
+
case 'copyWithin':
|
|
6061
|
+
return ArrayCopyWithin;
|
|
6062
|
+
}
|
|
6335
6063
|
}
|
|
6336
6064
|
function reportViolation(type, eventId, prop) {
|
|
6337
|
-
|
|
6338
|
-
|
|
6339
|
-
|
|
6065
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6066
|
+
logWarnOnce(`Mutating the "${prop}" property on a ${type} ` +
|
|
6067
|
+
`is deprecated and will be removed in a future version of LWC. ` +
|
|
6068
|
+
`See: https://sfdc.co/template-mutation`);
|
|
6069
|
+
}
|
|
6340
6070
|
}
|
|
6341
6071
|
function reportTemplateViolation(prop) {
|
|
6342
|
-
|
|
6072
|
+
reportViolation('template', 3 /* ReportingEventId.TemplateMutation */, prop);
|
|
6343
6073
|
}
|
|
6344
6074
|
function reportStylesheetViolation(prop) {
|
|
6345
|
-
|
|
6075
|
+
reportViolation('stylesheet', 4 /* ReportingEventId.StylesheetMutation */, prop);
|
|
6346
6076
|
}
|
|
6347
6077
|
// Warn if the user tries to mutate a stylesheets array, e.g.:
|
|
6348
6078
|
// `tmpl.stylesheets.push(someStylesheetFunction)`
|
|
6349
6079
|
function warnOnArrayMutation(stylesheets) {
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
|
|
6353
|
-
|
|
6354
|
-
|
|
6355
|
-
|
|
6356
|
-
|
|
6357
|
-
|
|
6358
|
-
|
|
6359
|
-
|
|
6080
|
+
// We can't handle users calling Array.prototype.slice.call(tmpl.stylesheets), but
|
|
6081
|
+
// we can at least warn when they use the most common mutation methods.
|
|
6082
|
+
for (const prop of ARRAY_MUTATION_METHODS) {
|
|
6083
|
+
const originalArrayMethod = getOriginalArrayMethod(prop);
|
|
6084
|
+
stylesheets[prop] = function arrayMutationWarningWrapper() {
|
|
6085
|
+
reportTemplateViolation('stylesheets');
|
|
6086
|
+
// @ts-ignore
|
|
6087
|
+
return originalArrayMethod.apply(this, arguments);
|
|
6088
|
+
};
|
|
6089
|
+
}
|
|
6360
6090
|
}
|
|
6361
6091
|
// Warn if the user tries to mutate a stylesheet factory function, e.g.:
|
|
6362
6092
|
// `stylesheet.$scoped$ = true`
|
|
6363
6093
|
function warnOnStylesheetFunctionMutation(stylesheet) {
|
|
6364
|
-
|
|
6365
|
-
|
|
6366
|
-
|
|
6367
|
-
|
|
6368
|
-
|
|
6369
|
-
|
|
6370
|
-
|
|
6371
|
-
|
|
6372
|
-
|
|
6373
|
-
|
|
6374
|
-
|
|
6375
|
-
|
|
6376
|
-
|
|
6377
|
-
|
|
6094
|
+
for (const prop of STYLESHEET_PROPS) {
|
|
6095
|
+
let value = stylesheet[prop];
|
|
6096
|
+
defineProperty(stylesheet, prop, {
|
|
6097
|
+
enumerable: true,
|
|
6098
|
+
configurable: true,
|
|
6099
|
+
get() {
|
|
6100
|
+
return value;
|
|
6101
|
+
},
|
|
6102
|
+
set(newValue) {
|
|
6103
|
+
reportStylesheetViolation(prop);
|
|
6104
|
+
value = newValue;
|
|
6105
|
+
},
|
|
6106
|
+
});
|
|
6107
|
+
}
|
|
6378
6108
|
}
|
|
6379
6109
|
// Warn on either array or stylesheet (function) mutation, in a deeply-nested array
|
|
6380
6110
|
function trackStylesheetsMutation(stylesheets) {
|
|
6381
|
-
|
|
6382
|
-
|
|
6383
|
-
|
|
6384
|
-
|
|
6385
|
-
|
|
6386
|
-
|
|
6387
|
-
|
|
6111
|
+
traverseStylesheets(stylesheets, (subStylesheets) => {
|
|
6112
|
+
if (isArray$1(subStylesheets)) {
|
|
6113
|
+
warnOnArrayMutation(subStylesheets);
|
|
6114
|
+
}
|
|
6115
|
+
else {
|
|
6116
|
+
warnOnStylesheetFunctionMutation(subStylesheets);
|
|
6117
|
+
}
|
|
6118
|
+
});
|
|
6388
6119
|
}
|
|
6389
6120
|
// Deeply freeze the entire array (of arrays) of stylesheet factory functions
|
|
6390
6121
|
function deepFreeze(stylesheets) {
|
|
6391
|
-
|
|
6392
|
-
|
|
6393
|
-
|
|
6122
|
+
traverseStylesheets(stylesheets, (subStylesheets) => {
|
|
6123
|
+
freeze(subStylesheets);
|
|
6124
|
+
});
|
|
6394
6125
|
}
|
|
6395
6126
|
// Deep-traverse an array (of arrays) of stylesheet factory functions, and call the callback for every array/function
|
|
6396
6127
|
function traverseStylesheets(stylesheets, callback) {
|
|
6397
|
-
|
|
6398
|
-
|
|
6399
|
-
|
|
6400
|
-
|
|
6401
|
-
|
|
6402
|
-
|
|
6403
|
-
|
|
6128
|
+
callback(stylesheets);
|
|
6129
|
+
for (let i = 0; i < stylesheets.length; i++) {
|
|
6130
|
+
const stylesheet = stylesheets[i];
|
|
6131
|
+
if (isArray$1(stylesheet)) {
|
|
6132
|
+
traverseStylesheets(stylesheet, callback);
|
|
6133
|
+
}
|
|
6134
|
+
else {
|
|
6135
|
+
callback(stylesheet);
|
|
6136
|
+
}
|
|
6404
6137
|
}
|
|
6405
|
-
}
|
|
6406
6138
|
}
|
|
6407
6139
|
function trackMutations(tmpl) {
|
|
6408
|
-
|
|
6409
|
-
|
|
6410
|
-
}
|
|
6411
|
-
for (const prop of TEMPLATE_PROPS) {
|
|
6412
|
-
let value = tmpl[prop];
|
|
6413
|
-
defineProperty(tmpl, prop, {
|
|
6414
|
-
enumerable: true,
|
|
6415
|
-
configurable: true,
|
|
6416
|
-
get() {
|
|
6417
|
-
return value;
|
|
6418
|
-
},
|
|
6419
|
-
set(newValue) {
|
|
6420
|
-
if (!mutationTrackingDisabled) {
|
|
6421
|
-
reportTemplateViolation(prop);
|
|
6422
|
-
}
|
|
6423
|
-
value = newValue;
|
|
6424
|
-
}
|
|
6425
|
-
});
|
|
6426
|
-
}
|
|
6427
|
-
const originalDescriptor = getOwnPropertyDescriptor$1(tmpl, 'stylesheetTokens');
|
|
6428
|
-
defineProperty(tmpl, 'stylesheetTokens', {
|
|
6429
|
-
enumerable: true,
|
|
6430
|
-
configurable: true,
|
|
6431
|
-
get: originalDescriptor.get,
|
|
6432
|
-
set(value) {
|
|
6433
|
-
reportTemplateViolation('stylesheetTokens');
|
|
6434
|
-
// Avoid logging/reporting twice (for both stylesheetToken and stylesheetTokens)
|
|
6435
|
-
mutationTrackingDisabled = true;
|
|
6436
|
-
originalDescriptor.set.call(this, value);
|
|
6437
|
-
mutationTrackingDisabled = false;
|
|
6140
|
+
if (!isUndefined$1(tmpl.stylesheets)) {
|
|
6141
|
+
trackStylesheetsMutation(tmpl.stylesheets);
|
|
6438
6142
|
}
|
|
6439
|
-
|
|
6143
|
+
for (const prop of TEMPLATE_PROPS) {
|
|
6144
|
+
let value = tmpl[prop];
|
|
6145
|
+
defineProperty(tmpl, prop, {
|
|
6146
|
+
enumerable: true,
|
|
6147
|
+
configurable: true,
|
|
6148
|
+
get() {
|
|
6149
|
+
return value;
|
|
6150
|
+
},
|
|
6151
|
+
set(newValue) {
|
|
6152
|
+
if (!mutationTrackingDisabled) {
|
|
6153
|
+
reportTemplateViolation(prop);
|
|
6154
|
+
}
|
|
6155
|
+
value = newValue;
|
|
6156
|
+
},
|
|
6157
|
+
});
|
|
6158
|
+
}
|
|
6159
|
+
const originalDescriptor = getOwnPropertyDescriptor$1(tmpl, 'stylesheetTokens');
|
|
6160
|
+
defineProperty(tmpl, 'stylesheetTokens', {
|
|
6161
|
+
enumerable: true,
|
|
6162
|
+
configurable: true,
|
|
6163
|
+
get: originalDescriptor.get,
|
|
6164
|
+
set(value) {
|
|
6165
|
+
reportTemplateViolation('stylesheetTokens');
|
|
6166
|
+
// Avoid logging/reporting twice (for both stylesheetToken and stylesheetTokens)
|
|
6167
|
+
mutationTrackingDisabled = true;
|
|
6168
|
+
originalDescriptor.set.call(this, value);
|
|
6169
|
+
mutationTrackingDisabled = false;
|
|
6170
|
+
},
|
|
6171
|
+
});
|
|
6440
6172
|
}
|
|
6441
6173
|
function addLegacyStylesheetTokensShim(tmpl) {
|
|
6442
|
-
|
|
6443
|
-
|
|
6444
|
-
|
|
6445
|
-
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
-
|
|
6449
|
-
|
|
6450
|
-
|
|
6451
|
-
|
|
6452
|
-
|
|
6453
|
-
|
|
6454
|
-
|
|
6455
|
-
|
|
6456
|
-
|
|
6457
|
-
|
|
6458
|
-
|
|
6459
|
-
|
|
6460
|
-
|
|
6461
|
-
|
|
6462
|
-
|
|
6463
|
-
|
|
6464
|
-
|
|
6465
|
-
|
|
6466
|
-
}
|
|
6467
|
-
});
|
|
6174
|
+
// When ENABLE_FROZEN_TEMPLATE is false, then we shim stylesheetTokens on top of stylesheetToken for anyone who
|
|
6175
|
+
// is accessing the old internal API (backwards compat). Details: https://salesforce.quip.com/v1rmAFu2cKAr
|
|
6176
|
+
defineProperty(tmpl, 'stylesheetTokens', {
|
|
6177
|
+
enumerable: true,
|
|
6178
|
+
configurable: true,
|
|
6179
|
+
get() {
|
|
6180
|
+
const { stylesheetToken } = this;
|
|
6181
|
+
if (isUndefined$1(stylesheetToken)) {
|
|
6182
|
+
return stylesheetToken;
|
|
6183
|
+
}
|
|
6184
|
+
// Shim for the old `stylesheetTokens` property
|
|
6185
|
+
// See https://github.com/salesforce/lwc/pull/2332/files#diff-7901555acef29969adaa6583185b3e9bce475cdc6f23e799a54e0018cb18abaa
|
|
6186
|
+
return {
|
|
6187
|
+
hostAttribute: `${stylesheetToken}-host`,
|
|
6188
|
+
shadowAttribute: stylesheetToken,
|
|
6189
|
+
};
|
|
6190
|
+
},
|
|
6191
|
+
set(value) {
|
|
6192
|
+
// If the value is null or some other exotic object, you would be broken anyway in the past
|
|
6193
|
+
// because the engine would try to access hostAttribute/shadowAttribute, which would throw an error.
|
|
6194
|
+
// However it may be undefined in newer versions of LWC, so we need to guard against that case.
|
|
6195
|
+
this.stylesheetToken = isUndefined$1(value) ? undefined : value.shadowAttribute;
|
|
6196
|
+
},
|
|
6197
|
+
});
|
|
6468
6198
|
}
|
|
6469
6199
|
function freezeTemplate(tmpl) {
|
|
6470
|
-
|
|
6471
|
-
|
|
6472
|
-
|
|
6473
|
-
|
|
6474
|
-
|
|
6475
|
-
|
|
6200
|
+
// TODO [#2782]: remove this flag and delete the legacy behavior
|
|
6201
|
+
if (lwcRuntimeFlags.ENABLE_FROZEN_TEMPLATE) {
|
|
6202
|
+
// Deep freeze the template
|
|
6203
|
+
freeze(tmpl);
|
|
6204
|
+
if (!isUndefined$1(tmpl.stylesheets)) {
|
|
6205
|
+
deepFreeze(tmpl.stylesheets);
|
|
6206
|
+
}
|
|
6476
6207
|
}
|
|
6477
|
-
|
|
6478
|
-
|
|
6479
|
-
|
|
6480
|
-
|
|
6481
|
-
|
|
6482
|
-
|
|
6483
|
-
|
|
6208
|
+
else {
|
|
6209
|
+
// template is not frozen - shim, report, and warn
|
|
6210
|
+
// this shim should be applied in both dev and prod
|
|
6211
|
+
addLegacyStylesheetTokensShim(tmpl);
|
|
6212
|
+
// When ENABLE_FROZEN_TEMPLATE is false, we want to warn in dev mode whenever someone is mutating the template
|
|
6213
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6214
|
+
trackMutations(tmpl);
|
|
6215
|
+
}
|
|
6484
6216
|
}
|
|
6485
|
-
}
|
|
6486
6217
|
}
|
|
6487
|
-
/* version: 2.37.
|
|
6218
|
+
/* version: 2.37.1 */
|
|
6488
6219
|
|
|
6489
6220
|
/*
|
|
6490
6221
|
* Copyright (c) 2020, salesforce.com, inc.
|
|
@@ -6972,7 +6703,7 @@ seal(LightningElement.prototype);
|
|
|
6972
6703
|
function createElement() {
|
|
6973
6704
|
throw new Error('createElement is not supported in @lwc/engine-server, only @lwc/engine-dom.');
|
|
6974
6705
|
}
|
|
6975
|
-
/* version: 2.37.
|
|
6706
|
+
/* version: 2.37.1 */
|
|
6976
6707
|
|
|
6977
6708
|
exports.LightningElement = LightningElement;
|
|
6978
6709
|
exports.api = api$1;
|