lwc 2.36.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 +2235 -3076
- package/dist/engine-dom/iife/es2017/engine-dom.js +8216 -9057
- package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es2017/engine-dom_debug.js +6618 -7422
- package/dist/engine-dom/iife/es5/engine-dom.js +8142 -8795
- package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es5/engine-dom_debug.js +6702 -7309
- package/dist/engine-dom/umd/es2017/engine-dom.js +8217 -9058
- package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es2017/engine-dom_debug.js +6619 -7423
- package/dist/engine-dom/umd/es5/engine-dom.js +8143 -8796
- package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es5/engine-dom_debug.js +6703 -7310
- package/dist/engine-server/commonjs/es2017/engine-server.js +1984 -2239
- package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
- package/dist/engine-server/esm/es2017/engine-server.js +1984 -2240
- 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.
|
|
445
|
+
const LWC_VERSION = "2.37.1";
|
|
446
446
|
const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
|
|
447
|
-
/** version: 2.
|
|
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.
|
|
@@ -496,15 +464,15 @@ const features = {
|
|
|
496
464
|
ENABLE_WIRE_SYNC_EMIT: null,
|
|
497
465
|
ENABLE_LIGHT_GET_ROOT_NODE_PATCH: null,
|
|
498
466
|
DISABLE_LIGHT_DOM_UNSCOPED_CSS: null,
|
|
499
|
-
ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY: null,
|
|
500
467
|
ENABLE_FROZEN_TEMPLATE: null,
|
|
501
468
|
DISABLE_ARIA_REFLECTION_POLYFILL: null,
|
|
502
|
-
ENABLE_PROGRAMMATIC_STYLESHEETS: null,
|
|
503
469
|
};
|
|
470
|
+
// eslint-disable-next-line no-restricted-properties
|
|
504
471
|
if (!_globalThis.lwcRuntimeFlags) {
|
|
505
472
|
Object.defineProperty(_globalThis, 'lwcRuntimeFlags', { value: create(null) });
|
|
506
473
|
}
|
|
507
|
-
|
|
474
|
+
// eslint-disable-next-line no-restricted-properties
|
|
475
|
+
const flags = _globalThis.lwcRuntimeFlags;
|
|
508
476
|
/**
|
|
509
477
|
* Set the value at runtime of a given feature flag. This method only be invoked once per feature
|
|
510
478
|
* flag. It is meant to be used during the app initialization.
|
|
@@ -532,17 +500,17 @@ function setFeatureFlag(name, value) {
|
|
|
532
500
|
// This may seem redundant, but `process.env.NODE_ENV === 'test-karma-lwc'` is replaced by Karma tests
|
|
533
501
|
if (process.env.NODE_ENV === 'test-karma-lwc' || process.env.NODE_ENV !== 'production') {
|
|
534
502
|
// Allow the same flag to be set more than once outside of production to enable testing
|
|
535
|
-
|
|
503
|
+
flags[name] = value;
|
|
536
504
|
}
|
|
537
505
|
else {
|
|
538
506
|
// Disallow the same flag to be set more than once in production
|
|
539
|
-
const runtimeValue =
|
|
507
|
+
const runtimeValue = flags[name];
|
|
540
508
|
if (!isUndefined$1(runtimeValue)) {
|
|
541
509
|
// eslint-disable-next-line no-console
|
|
542
510
|
console.error(`Failed to set the value "${value}" for the runtime feature flag "${name}". "${name}" has already been set with the value "${runtimeValue}".`);
|
|
543
511
|
return;
|
|
544
512
|
}
|
|
545
|
-
defineProperty(
|
|
513
|
+
defineProperty(flags, name, { value });
|
|
546
514
|
}
|
|
547
515
|
}
|
|
548
516
|
/**
|
|
@@ -555,7 +523,39 @@ function setFeatureFlagForTest(name, value) {
|
|
|
555
523
|
setFeatureFlag(name, value);
|
|
556
524
|
}
|
|
557
525
|
}
|
|
558
|
-
/** version: 2.
|
|
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
|
+
}
|
|
559
559
|
|
|
560
560
|
/**
|
|
561
561
|
* Copyright (C) 2018 salesforce.com, inc.
|
|
@@ -619,32 +619,10 @@ function applyAriaReflection(prototype = Element.prototype) {
|
|
|
619
619
|
}
|
|
620
620
|
}
|
|
621
621
|
}
|
|
622
|
-
/** version: 2.
|
|
622
|
+
/** version: 2.37.1 */
|
|
623
623
|
|
|
624
624
|
/* proxy-compat-disable */
|
|
625
625
|
|
|
626
|
-
/*
|
|
627
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
628
|
-
* All rights reserved.
|
|
629
|
-
* SPDX-License-Identifier: MIT
|
|
630
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
631
|
-
*/
|
|
632
|
-
// Only used in LWC's Karma tests
|
|
633
|
-
if (process.env.NODE_ENV === 'test-karma-lwc') {
|
|
634
|
-
window.addEventListener('test-dummy-flag', () => {
|
|
635
|
-
let hasFlag = false;
|
|
636
|
-
if (lwcRuntimeFlags.DUMMY_TEST_FLAG) {
|
|
637
|
-
hasFlag = true;
|
|
638
|
-
}
|
|
639
|
-
window.dispatchEvent(new CustomEvent('has-dummy-flag', {
|
|
640
|
-
detail: {
|
|
641
|
-
package: '@lwc/engine-core',
|
|
642
|
-
hasFlag
|
|
643
|
-
}
|
|
644
|
-
}));
|
|
645
|
-
});
|
|
646
|
-
}
|
|
647
|
-
|
|
648
626
|
/*
|
|
649
627
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
650
628
|
* All rights reserved.
|
|
@@ -1883,50 +1861,45 @@ function getReactiveProxy(value) {
|
|
|
1883
1861
|
* for the Base Lightning Element, it also include the reactivity bit, so the standard property is reactive.
|
|
1884
1862
|
*/
|
|
1885
1863
|
function createBridgeToElementDescriptor(propName, descriptor) {
|
|
1886
|
-
|
|
1887
|
-
get
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
if (!isFunction$1(get)) {
|
|
1893
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1894
|
-
assert.fail(`Detected invalid public property descriptor for HTMLElement.prototype.${propName} definition. Missing the standard getter.`);
|
|
1895
|
-
}
|
|
1896
|
-
throw new TypeError();
|
|
1897
|
-
}
|
|
1898
|
-
if (!isFunction$1(set)) {
|
|
1899
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1900
|
-
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();
|
|
1901
1870
|
}
|
|
1902
|
-
|
|
1903
|
-
}
|
|
1904
|
-
return {
|
|
1905
|
-
enumerable,
|
|
1906
|
-
configurable,
|
|
1907
|
-
get() {
|
|
1908
|
-
const vm = getAssociatedVM(this);
|
|
1909
|
-
if (isBeingConstructed(vm)) {
|
|
1871
|
+
if (!isFunction$1(set)) {
|
|
1910
1872
|
if (process.env.NODE_ENV !== 'production') {
|
|
1911
|
-
|
|
1873
|
+
assert.fail(`Detected invalid public property descriptor for HTMLElement.prototype.${propName} definition. Missing the standard setter.`);
|
|
1912
1874
|
}
|
|
1913
|
-
|
|
1914
|
-
}
|
|
1915
|
-
return get.call(vm.elm);
|
|
1916
|
-
},
|
|
1917
|
-
set(newValue) {
|
|
1918
|
-
const vm = getAssociatedVM(this);
|
|
1919
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1920
|
-
const vmBeingRendered = getVMBeingRendered();
|
|
1921
|
-
assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${propName}`);
|
|
1922
|
-
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}`);
|
|
1923
|
-
assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
|
|
1924
|
-
assert.invariant(!isObject(newValue) || isNull(newValue), `Invalid value "${newValue}" for "${propName}" of ${vm}. Value cannot be an object, must be a primitive value.`);
|
|
1925
|
-
}
|
|
1926
|
-
updateComponentValue(vm, propName, newValue);
|
|
1927
|
-
return set.call(vm.elm, newValue);
|
|
1875
|
+
throw new TypeError();
|
|
1928
1876
|
}
|
|
1929
|
-
|
|
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
|
+
};
|
|
1930
1903
|
}
|
|
1931
1904
|
const refsCache = new WeakMap();
|
|
1932
1905
|
/**
|
|
@@ -1935,436 +1908,347 @@ const refsCache = new WeakMap();
|
|
|
1935
1908
|
**/
|
|
1936
1909
|
// @ts-ignore
|
|
1937
1910
|
const LightningElement = function () {
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
def
|
|
1947
|
-
elm
|
|
1948
|
-
} = vm;
|
|
1949
|
-
const {
|
|
1950
|
-
bridge
|
|
1951
|
-
} = def;
|
|
1952
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1953
|
-
const {
|
|
1954
|
-
assertInstanceOfHTMLElement
|
|
1955
|
-
} = vm.renderer;
|
|
1956
|
-
assertInstanceOfHTMLElement(vm.elm, `Component creation requires a DOM element to be associated to ${vm}.`);
|
|
1957
|
-
}
|
|
1958
|
-
const component = this;
|
|
1959
|
-
setPrototypeOf(elm, bridge.prototype);
|
|
1960
|
-
vm.component = this;
|
|
1961
|
-
// Locker hooks assignment. When the LWC engine run with Locker, Locker intercepts all the new
|
|
1962
|
-
// component creation and passes hooks to instrument all the component interactions with the
|
|
1963
|
-
// engine. We are intentionally hiding this argument from the formal API of LightningElement
|
|
1964
|
-
// because we don't want folks to know about it just yet.
|
|
1965
|
-
if (arguments.length === 1) {
|
|
1966
|
-
const {
|
|
1967
|
-
callHook,
|
|
1968
|
-
setHook,
|
|
1969
|
-
getHook
|
|
1970
|
-
} = arguments[0];
|
|
1971
|
-
vm.callHook = callHook;
|
|
1972
|
-
vm.setHook = setHook;
|
|
1973
|
-
vm.getHook = getHook;
|
|
1974
|
-
}
|
|
1975
|
-
// Linking elm, shadow root and component with the VM.
|
|
1976
|
-
associateVM(component, vm);
|
|
1977
|
-
associateVM(elm, vm);
|
|
1978
|
-
if (vm.renderMode === 1 /* RenderMode.Shadow */) {
|
|
1979
|
-
vm.renderRoot = doAttachShadow(vm);
|
|
1980
|
-
} else {
|
|
1981
|
-
vm.renderRoot = elm;
|
|
1982
|
-
}
|
|
1983
|
-
// Adding extra guard rails in DEV mode.
|
|
1984
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1985
|
-
patchCustomElementWithRestrictions(elm);
|
|
1986
|
-
patchComponentWithRestrictions(component);
|
|
1987
|
-
}
|
|
1988
|
-
return this;
|
|
1989
|
-
};
|
|
1990
|
-
function doAttachShadow(vm) {
|
|
1991
|
-
const {
|
|
1992
|
-
elm,
|
|
1993
|
-
mode,
|
|
1994
|
-
shadowMode,
|
|
1995
|
-
def: {
|
|
1996
|
-
ctor
|
|
1997
|
-
},
|
|
1998
|
-
renderer: {
|
|
1999
|
-
attachShadow
|
|
2000
|
-
}
|
|
2001
|
-
} = vm;
|
|
2002
|
-
const shadowRoot = attachShadow(elm, {
|
|
2003
|
-
[KEY__SYNTHETIC_MODE]: shadowMode === 1 /* ShadowMode.Synthetic */,
|
|
2004
|
-
delegatesFocus: Boolean(ctor.delegatesFocus),
|
|
2005
|
-
mode
|
|
2006
|
-
});
|
|
2007
|
-
vm.shadowRoot = shadowRoot;
|
|
2008
|
-
associateVM(shadowRoot, vm);
|
|
2009
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2010
|
-
patchShadowRootWithRestrictions(shadowRoot);
|
|
2011
|
-
}
|
|
2012
|
-
return shadowRoot;
|
|
2013
|
-
}
|
|
2014
|
-
function warnIfInvokedDuringConstruction(vm, methodOrPropName) {
|
|
2015
|
-
if (isBeingConstructed(vm)) {
|
|
2016
|
-
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.`);
|
|
2017
|
-
}
|
|
2018
|
-
}
|
|
2019
|
-
// @ts-ignore
|
|
2020
|
-
LightningElement.prototype = {
|
|
2021
|
-
constructor: LightningElement,
|
|
2022
|
-
dispatchEvent(event) {
|
|
2023
|
-
const vm = getAssociatedVM(this);
|
|
2024
|
-
const {
|
|
2025
|
-
elm,
|
|
2026
|
-
renderer: {
|
|
2027
|
-
dispatchEvent
|
|
2028
|
-
}
|
|
2029
|
-
} = vm;
|
|
2030
|
-
return dispatchEvent(elm, event);
|
|
2031
|
-
},
|
|
2032
|
-
addEventListener(type, listener, options) {
|
|
2033
|
-
const vm = getAssociatedVM(this);
|
|
2034
|
-
const {
|
|
2035
|
-
elm,
|
|
2036
|
-
renderer: {
|
|
2037
|
-
addEventListener
|
|
2038
|
-
}
|
|
2039
|
-
} = vm;
|
|
2040
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2041
|
-
const vmBeingRendered = getVMBeingRendered();
|
|
2042
|
-
assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm} by adding an event listener for "${type}".`);
|
|
2043
|
-
assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm} by adding an event listener for "${type}".`);
|
|
2044
|
-
assert.invariant(isFunction$1(listener), `Invalid second argument for this.addEventListener() in ${vm} for event "${type}". Expected an EventListener but received ${listener}.`);
|
|
2045
|
-
}
|
|
2046
|
-
const wrappedListener = getWrappedComponentsListener(vm, listener);
|
|
2047
|
-
addEventListener(elm, type, wrappedListener, options);
|
|
2048
|
-
},
|
|
2049
|
-
removeEventListener(type, listener, options) {
|
|
2050
|
-
const vm = getAssociatedVM(this);
|
|
2051
|
-
const {
|
|
2052
|
-
elm,
|
|
2053
|
-
renderer: {
|
|
2054
|
-
removeEventListener
|
|
2055
|
-
}
|
|
2056
|
-
} = vm;
|
|
2057
|
-
const wrappedListener = getWrappedComponentsListener(vm, listener);
|
|
2058
|
-
removeEventListener(elm, type, wrappedListener, options);
|
|
2059
|
-
},
|
|
2060
|
-
hasAttribute(name) {
|
|
2061
|
-
const vm = getAssociatedVM(this);
|
|
2062
|
-
const {
|
|
2063
|
-
elm,
|
|
2064
|
-
renderer: {
|
|
2065
|
-
getAttribute
|
|
2066
|
-
}
|
|
2067
|
-
} = vm;
|
|
2068
|
-
return !isNull(getAttribute(elm, name));
|
|
2069
|
-
},
|
|
2070
|
-
hasAttributeNS(namespace, name) {
|
|
2071
|
-
const vm = getAssociatedVM(this);
|
|
2072
|
-
const {
|
|
2073
|
-
elm,
|
|
2074
|
-
renderer: {
|
|
2075
|
-
getAttribute
|
|
2076
|
-
}
|
|
2077
|
-
} = vm;
|
|
2078
|
-
return !isNull(getAttribute(elm, name, namespace));
|
|
2079
|
-
},
|
|
2080
|
-
removeAttribute(name) {
|
|
2081
|
-
const vm = getAssociatedVM(this);
|
|
2082
|
-
const {
|
|
2083
|
-
elm,
|
|
2084
|
-
renderer: {
|
|
2085
|
-
removeAttribute
|
|
2086
|
-
}
|
|
2087
|
-
} = vm;
|
|
2088
|
-
unlockAttribute(elm, name);
|
|
2089
|
-
removeAttribute(elm, name);
|
|
2090
|
-
lockAttribute();
|
|
2091
|
-
},
|
|
2092
|
-
removeAttributeNS(namespace, name) {
|
|
2093
|
-
const {
|
|
2094
|
-
elm,
|
|
2095
|
-
renderer: {
|
|
2096
|
-
removeAttribute
|
|
2097
|
-
}
|
|
2098
|
-
} = getAssociatedVM(this);
|
|
2099
|
-
unlockAttribute(elm, name);
|
|
2100
|
-
removeAttribute(elm, name, namespace);
|
|
2101
|
-
lockAttribute();
|
|
2102
|
-
},
|
|
2103
|
-
getAttribute(name) {
|
|
2104
|
-
const vm = getAssociatedVM(this);
|
|
2105
|
-
const {
|
|
2106
|
-
elm
|
|
2107
|
-
} = vm;
|
|
2108
|
-
const {
|
|
2109
|
-
getAttribute
|
|
2110
|
-
} = vm.renderer;
|
|
2111
|
-
return getAttribute(elm, name);
|
|
2112
|
-
},
|
|
2113
|
-
getAttributeNS(namespace, name) {
|
|
2114
|
-
const vm = getAssociatedVM(this);
|
|
2115
|
-
const {
|
|
2116
|
-
elm
|
|
2117
|
-
} = vm;
|
|
2118
|
-
const {
|
|
2119
|
-
getAttribute
|
|
2120
|
-
} = vm.renderer;
|
|
2121
|
-
return getAttribute(elm, name, namespace);
|
|
2122
|
-
},
|
|
2123
|
-
setAttribute(name, value) {
|
|
2124
|
-
const vm = getAssociatedVM(this);
|
|
2125
|
-
const {
|
|
2126
|
-
elm,
|
|
2127
|
-
renderer: {
|
|
2128
|
-
setAttribute
|
|
2129
|
-
}
|
|
2130
|
-
} = vm;
|
|
2131
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2132
|
-
assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
|
|
2133
|
-
}
|
|
2134
|
-
unlockAttribute(elm, name);
|
|
2135
|
-
setAttribute(elm, name, value);
|
|
2136
|
-
lockAttribute();
|
|
2137
|
-
},
|
|
2138
|
-
setAttributeNS(namespace, name, value) {
|
|
2139
|
-
const vm = getAssociatedVM(this);
|
|
2140
|
-
const {
|
|
2141
|
-
elm,
|
|
2142
|
-
renderer: {
|
|
2143
|
-
setAttribute
|
|
2144
|
-
}
|
|
2145
|
-
} = vm;
|
|
2146
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2147
|
-
assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
|
|
2148
|
-
}
|
|
2149
|
-
unlockAttribute(elm, name);
|
|
2150
|
-
setAttribute(elm, name, value, namespace);
|
|
2151
|
-
lockAttribute();
|
|
2152
|
-
},
|
|
2153
|
-
getBoundingClientRect() {
|
|
2154
|
-
const vm = getAssociatedVM(this);
|
|
2155
|
-
const {
|
|
2156
|
-
elm,
|
|
2157
|
-
renderer: {
|
|
2158
|
-
getBoundingClientRect
|
|
2159
|
-
}
|
|
2160
|
-
} = 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;
|
|
2161
1920
|
if (process.env.NODE_ENV !== 'production') {
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
const vm = getAssociatedVM(this);
|
|
2178
|
-
const {
|
|
2179
|
-
elm,
|
|
2180
|
-
renderer: {
|
|
2181
|
-
getClassList
|
|
2182
|
-
}
|
|
2183
|
-
} = vm;
|
|
2184
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2185
|
-
// TODO [#1290]: this still fails in dev but works in production, eventually, we should
|
|
2186
|
-
// just throw in all modes
|
|
2187
|
-
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.`);
|
|
2188
|
-
}
|
|
2189
|
-
return getClassList(elm);
|
|
2190
|
-
},
|
|
2191
|
-
get template() {
|
|
2192
|
-
const vm = getAssociatedVM(this);
|
|
2193
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2194
|
-
if (vm.renderMode === 0 /* RenderMode.Light */) {
|
|
2195
|
-
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`.');
|
|
2196
|
-
}
|
|
2197
|
-
}
|
|
2198
|
-
return vm.shadowRoot;
|
|
2199
|
-
},
|
|
2200
|
-
get refs() {
|
|
2201
|
-
const vm = getAssociatedVM(this);
|
|
2202
|
-
if (isUpdatingTemplate) {
|
|
2203
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2204
|
-
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().`);
|
|
2205
|
-
}
|
|
2206
|
-
// If the template is in the process of being updated, then we don't want to go through the normal
|
|
2207
|
-
// process of returning the refs and caching them, because the state of the refs is unstable.
|
|
2208
|
-
// This can happen if e.g. a template contains `<div class={foo}></div>` and `foo` is computed
|
|
2209
|
-
// based on `this.refs.bar`.
|
|
2210
|
-
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;
|
|
2211
1936
|
}
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
cmpTemplate
|
|
2218
|
-
} = vm;
|
|
2219
|
-
// If the `cmpTemplate` is null, that means that the template has not been rendered yet. Most likely this occurs
|
|
2220
|
-
// if `this.refs` is called during the `connectedCallback` phase. The DOM elements have not been rendered yet,
|
|
2221
|
-
// so log a warning. Note we also check `isBeingConstructed()` to avoid a double warning (due to
|
|
2222
|
-
// `warnIfInvokedDuringConstruction` above).
|
|
2223
|
-
if (process.env.NODE_ENV !== 'production' && isNull(cmpTemplate) && !isBeingConstructed(vm)) {
|
|
2224
|
-
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().`);
|
|
2225
|
-
}
|
|
2226
|
-
// For backwards compatibility with component written before template refs
|
|
2227
|
-
// were introduced, we return undefined if the template has no refs defined
|
|
2228
|
-
// anywhere. This fixes components that may want to add an expando called `refs`
|
|
2229
|
-
// and are checking if it exists with `if (this.refs)` before adding it.
|
|
2230
|
-
// Note we use a null refVNodes to indicate that the template has no refs defined.
|
|
2231
|
-
if (isNull(refVNodes)) {
|
|
2232
|
-
return;
|
|
2233
|
-
}
|
|
2234
|
-
// The refNodes can be cached based on the refVNodes, since the refVNodes
|
|
2235
|
-
// are recreated from scratch every time the template is rendered.
|
|
2236
|
-
// This happens with `vm.refVNodes = null` in `template.ts` in `@lwc/engine-core`.
|
|
2237
|
-
let refs = refsCache.get(refVNodes);
|
|
2238
|
-
if (isUndefined$1(refs)) {
|
|
2239
|
-
refs = create(null);
|
|
2240
|
-
for (const key of keys(refVNodes)) {
|
|
2241
|
-
refs[key] = refVNodes[key].elm;
|
|
2242
|
-
}
|
|
2243
|
-
freeze(refs);
|
|
2244
|
-
refsCache.set(refVNodes, refs);
|
|
2245
|
-
}
|
|
2246
|
-
return refs;
|
|
2247
|
-
},
|
|
2248
|
-
// For backwards compat, we allow component authors to set `refs` as an expando
|
|
2249
|
-
set refs(value) {
|
|
2250
|
-
defineProperty(this, 'refs', {
|
|
2251
|
-
configurable: true,
|
|
2252
|
-
enumerable: true,
|
|
2253
|
-
writable: true,
|
|
2254
|
-
value
|
|
2255
|
-
});
|
|
2256
|
-
},
|
|
2257
|
-
get shadowRoot() {
|
|
2258
|
-
// From within the component instance, the shadowRoot is always reported as "closed".
|
|
2259
|
-
// Authors should rely on this.template instead.
|
|
2260
|
-
return null;
|
|
2261
|
-
},
|
|
2262
|
-
get children() {
|
|
2263
|
-
const vm = getAssociatedVM(this);
|
|
2264
|
-
const renderer = vm.renderer;
|
|
2265
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2266
|
-
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);
|
|
2267
1942
|
}
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
get childNodes() {
|
|
2271
|
-
const vm = getAssociatedVM(this);
|
|
2272
|
-
const renderer = vm.renderer;
|
|
2273
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2274
|
-
warnIfInvokedDuringConstruction(vm, 'childNodes');
|
|
1943
|
+
else {
|
|
1944
|
+
vm.renderRoot = elm;
|
|
2275
1945
|
}
|
|
2276
|
-
|
|
2277
|
-
},
|
|
2278
|
-
get firstChild() {
|
|
2279
|
-
const vm = getAssociatedVM(this);
|
|
2280
|
-
const renderer = vm.renderer;
|
|
1946
|
+
// Adding extra guard rails in DEV mode.
|
|
2281
1947
|
if (process.env.NODE_ENV !== 'production') {
|
|
2282
|
-
|
|
1948
|
+
patchCustomElementWithRestrictions(elm);
|
|
1949
|
+
patchComponentWithRestrictions(component);
|
|
2283
1950
|
}
|
|
2284
|
-
return
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
const
|
|
2288
|
-
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);
|
|
2289
1962
|
if (process.env.NODE_ENV !== 'production') {
|
|
2290
|
-
|
|
1963
|
+
patchShadowRootWithRestrictions(shadowRoot);
|
|
2291
1964
|
}
|
|
2292
|
-
return
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2298
|
-
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.`);
|
|
2299
1970
|
}
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
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
|
+
},
|
|
2318
2204
|
};
|
|
2319
2205
|
const queryAndChildGetterDescriptors = create(null);
|
|
2320
|
-
const queryMethods = [
|
|
2206
|
+
const queryMethods = [
|
|
2207
|
+
'getElementsByClassName',
|
|
2208
|
+
'getElementsByTagName',
|
|
2209
|
+
'querySelector',
|
|
2210
|
+
'querySelectorAll',
|
|
2211
|
+
];
|
|
2321
2212
|
// Generic passthrough for query APIs on HTMLElement to the relevant Renderer APIs
|
|
2322
2213
|
for (const queryMethod of queryMethods) {
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
enumerable: true,
|
|
2337
|
-
writable: true
|
|
2338
|
-
};
|
|
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
|
+
};
|
|
2339
2227
|
}
|
|
2340
2228
|
defineProperties(LightningElement.prototype, queryAndChildGetterDescriptors);
|
|
2341
2229
|
const lightningBasedDescriptors = create(null);
|
|
2342
2230
|
for (const propName in HTMLElementOriginalDescriptors) {
|
|
2343
|
-
|
|
2231
|
+
lightningBasedDescriptors[propName] = createBridgeToElementDescriptor(propName, HTMLElementOriginalDescriptors[propName]);
|
|
2344
2232
|
}
|
|
2345
2233
|
defineProperties(LightningElement.prototype, lightningBasedDescriptors);
|
|
2346
2234
|
function applyAriaReflectionToLightningElement() {
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
}
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
if (lwcRuntimeFlags.DISABLE_ARIA_REFLECTION_POLYFILL) {
|
|
2355
|
-
applyAriaReflectionToLightningElement();
|
|
2356
|
-
} else {
|
|
2357
|
-
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();
|
|
2358
2242
|
}
|
|
2359
2243
|
defineProperty(LightningElement, 'CustomElementConstructor', {
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
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,
|
|
2365
2249
|
});
|
|
2366
2250
|
if (process.env.NODE_ENV !== 'production') {
|
|
2367
|
-
|
|
2251
|
+
patchLightningElementPrototypeWithRestrictions(LightningElement.prototype);
|
|
2368
2252
|
}
|
|
2369
2253
|
|
|
2370
2254
|
function createObservedFieldPropertyDescriptor(key) {
|
|
@@ -2393,268 +2277,234 @@ const DeprecatedWiredParamsMeta = '$$DeprecatedWiredParamsMetaKey$$';
|
|
|
2393
2277
|
const WIRE_DEBUG_ENTRY = '@wire';
|
|
2394
2278
|
const WireMetaMap = new Map();
|
|
2395
2279
|
class WireContextRegistrationEvent extends CustomEvent {
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
}
|
|
2411
|
-
});
|
|
2412
|
-
}
|
|
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
|
+
}
|
|
2413
2294
|
}
|
|
2414
2295
|
function createFieldDataCallback(vm, name) {
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2296
|
+
return (value) => {
|
|
2297
|
+
updateComponentValue(vm, name, value);
|
|
2298
|
+
};
|
|
2418
2299
|
}
|
|
2419
2300
|
function createMethodDataCallback(vm, method) {
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
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
|
+
};
|
|
2427
2308
|
}
|
|
2428
2309
|
function createConfigWatcher(component, configCallback, callbackWhenConfigIsReady) {
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
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
|
+
};
|
|
2443
2324
|
}
|
|
2444
2325
|
function createContextWatcher(vm, wireDef, callbackWhenContextIsReady) {
|
|
2445
|
-
|
|
2446
|
-
adapter
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
setNewContext(newContext) {
|
|
2472
|
-
// eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo
|
|
2473
|
-
// TODO: dev-mode validation of config based on the adapter.contextSchema
|
|
2474
|
-
callbackWhenContextIsReady(newContext);
|
|
2475
|
-
},
|
|
2476
|
-
setDisconnectedCallback(disconnectCallback) {
|
|
2477
|
-
// adds this callback into the disconnect bucket so it gets disconnected from parent
|
|
2478
|
-
// the the element hosting the wire is disconnected
|
|
2479
|
-
ArrayPush$1.call(wiredDisconnecting, disconnectCallback);
|
|
2480
|
-
}
|
|
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);
|
|
2481
2352
|
});
|
|
2482
|
-
dispatchEvent(elm, contextRegistrationEvent);
|
|
2483
|
-
});
|
|
2484
2353
|
}
|
|
2485
2354
|
function createConnector(vm, name, wireDef) {
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
adapter,
|
|
2489
|
-
configCallback,
|
|
2490
|
-
dynamic
|
|
2491
|
-
} = wireDef;
|
|
2492
|
-
let debugInfo;
|
|
2493
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2494
|
-
const wiredPropOrMethod = isUndefined$1(method) ? name : method.name;
|
|
2495
|
-
debugInfo = create(null);
|
|
2496
|
-
debugInfo.wasDataProvisionedForConfig = false;
|
|
2497
|
-
vm.debugInfo[WIRE_DEBUG_ENTRY][wiredPropOrMethod] = debugInfo;
|
|
2498
|
-
}
|
|
2499
|
-
const fieldOrMethodCallback = isUndefined$1(method) ? createFieldDataCallback(vm, name) : createMethodDataCallback(vm, method);
|
|
2500
|
-
const dataCallback = value => {
|
|
2355
|
+
const { method, adapter, configCallback, dynamic } = wireDef;
|
|
2356
|
+
let debugInfo;
|
|
2501
2357
|
if (process.env.NODE_ENV !== 'production') {
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
// some conditions in which it does not, ex:
|
|
2505
|
-
// race conditions in a poor network while the adapter does not cancel a previous request.
|
|
2506
|
-
debugInfo.wasDataProvisionedForConfig = true;
|
|
2507
|
-
}
|
|
2508
|
-
fieldOrMethodCallback(value);
|
|
2509
|
-
};
|
|
2510
|
-
let context;
|
|
2511
|
-
let connector;
|
|
2512
|
-
// Workaround to pass the component element associated to this wire adapter instance.
|
|
2513
|
-
defineProperty(dataCallback, DeprecatedWiredElementHost, {
|
|
2514
|
-
value: vm.elm
|
|
2515
|
-
});
|
|
2516
|
-
defineProperty(dataCallback, DeprecatedWiredParamsMeta, {
|
|
2517
|
-
value: dynamic
|
|
2518
|
-
});
|
|
2519
|
-
runWithBoundaryProtection(vm, vm, noop, () => {
|
|
2520
|
-
// job
|
|
2521
|
-
connector = new adapter(dataCallback);
|
|
2522
|
-
}, noop);
|
|
2523
|
-
const updateConnectorConfig = config => {
|
|
2524
|
-
// every time the config is recomputed due to tracking,
|
|
2525
|
-
// this callback will be invoked with the new computed config
|
|
2526
|
-
runWithBoundaryProtection(vm, vm, noop, () => {
|
|
2527
|
-
// job
|
|
2528
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2529
|
-
debugInfo.config = config;
|
|
2530
|
-
debugInfo.context = context;
|
|
2358
|
+
const wiredPropOrMethod = isUndefined$1(method) ? name : method.name;
|
|
2359
|
+
debugInfo = create(null);
|
|
2531
2360
|
debugInfo.wasDataProvisionedForConfig = false;
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
}
|
|
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,
|
|
2556
2384
|
});
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
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
|
+
};
|
|
2564
2427
|
}
|
|
2565
2428
|
const AdapterToTokenMap = new Map();
|
|
2566
2429
|
function getAdapterToken(adapter) {
|
|
2567
|
-
|
|
2430
|
+
return AdapterToTokenMap.get(adapter);
|
|
2568
2431
|
}
|
|
2569
2432
|
function setAdapterToken(adapter, token) {
|
|
2570
|
-
|
|
2433
|
+
AdapterToTokenMap.set(adapter, token);
|
|
2571
2434
|
}
|
|
2572
2435
|
function storeWiredMethodMeta(descriptor, adapter, configCallback, dynamic) {
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
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);
|
|
2585
2448
|
}
|
|
2586
2449
|
function storeWiredFieldMeta(descriptor, adapter, configCallback, dynamic) {
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
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);
|
|
2597
2460
|
}
|
|
2598
2461
|
function installWireAdapters(vm) {
|
|
2599
|
-
|
|
2600
|
-
context,
|
|
2601
|
-
def: {
|
|
2602
|
-
wire
|
|
2603
|
-
}
|
|
2604
|
-
} = vm;
|
|
2605
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2606
|
-
vm.debugInfo[WIRE_DEBUG_ENTRY] = create(null);
|
|
2607
|
-
}
|
|
2608
|
-
const wiredConnecting = context.wiredConnecting = [];
|
|
2609
|
-
const wiredDisconnecting = context.wiredDisconnecting = [];
|
|
2610
|
-
for (const fieldNameOrMethod in wire) {
|
|
2611
|
-
const descriptor = wire[fieldNameOrMethod];
|
|
2612
|
-
const wireDef = WireMetaMap.get(descriptor);
|
|
2462
|
+
const { context, def: { wire }, } = vm;
|
|
2613
2463
|
if (process.env.NODE_ENV !== 'production') {
|
|
2614
|
-
|
|
2464
|
+
vm.debugInfo[WIRE_DEBUG_ENTRY] = create(null);
|
|
2615
2465
|
}
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
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
|
+
});
|
|
2630
2491
|
}
|
|
2631
|
-
computeConfigAndUpdate();
|
|
2632
|
-
});
|
|
2633
|
-
ArrayPush$1.call(wiredDisconnecting, () => {
|
|
2634
|
-
connector.disconnect();
|
|
2635
|
-
resetConfigWatcher();
|
|
2636
|
-
});
|
|
2637
2492
|
}
|
|
2638
|
-
}
|
|
2639
2493
|
}
|
|
2640
2494
|
function connectWireAdapters(vm) {
|
|
2641
|
-
|
|
2642
|
-
wiredConnecting
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
wiredConnecting[i]();
|
|
2646
|
-
}
|
|
2495
|
+
const { wiredConnecting } = vm.context;
|
|
2496
|
+
for (let i = 0, len = wiredConnecting.length; i < len; i += 1) {
|
|
2497
|
+
wiredConnecting[i]();
|
|
2498
|
+
}
|
|
2647
2499
|
}
|
|
2648
2500
|
function disconnectWireAdapters(vm) {
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
}
|
|
2657
|
-
}, 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);
|
|
2658
2508
|
}
|
|
2659
2509
|
|
|
2660
2510
|
/*
|
|
@@ -3094,145 +2944,136 @@ function sanitizeAttribute(tagName, namespaceUri, attrName, attrValue) {
|
|
|
3094
2944
|
const cachedGetterByKey = create(null);
|
|
3095
2945
|
const cachedSetterByKey = create(null);
|
|
3096
2946
|
function createGetter(key) {
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
}
|
|
3107
|
-
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;
|
|
3108
2956
|
}
|
|
3109
2957
|
function createSetter(key) {
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
}
|
|
3121
|
-
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;
|
|
3122
2968
|
}
|
|
3123
2969
|
function createMethodCaller(methodName) {
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
}
|
|
3130
|
-
const fn = component[methodName];
|
|
3131
|
-
return callHook(vm.component, fn, ArraySlice.call(arguments));
|
|
3132
|
-
};
|
|
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
|
+
};
|
|
3133
2976
|
}
|
|
3134
2977
|
function createAttributeChangedCallback(attributeToPropMap, superAttributeChangedCallback) {
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
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
|
+
};
|
|
3161
3004
|
}
|
|
3162
3005
|
function HTMLBridgeElementFactory(SuperClass, props, methods) {
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
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),
|
|
3180
3067
|
};
|
|
3181
|
-
//
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
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
|
+
},
|
|
3188
3074
|
});
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
// and false positives in case of inheritance.
|
|
3192
|
-
const attributeToPropMap = create(null);
|
|
3193
|
-
const {
|
|
3194
|
-
attributeChangedCallback: superAttributeChangedCallback
|
|
3195
|
-
} = SuperClass.prototype;
|
|
3196
|
-
const {
|
|
3197
|
-
observedAttributes: superObservedAttributes = []
|
|
3198
|
-
} = SuperClass;
|
|
3199
|
-
const descriptors = create(null);
|
|
3200
|
-
// expose getters and setters for each public props on the new Element Bridge
|
|
3201
|
-
for (let i = 0, len = props.length; i < len; i += 1) {
|
|
3202
|
-
const propName = props[i];
|
|
3203
|
-
attributeToPropMap[htmlPropertyToAttribute(propName)] = propName;
|
|
3204
|
-
descriptors[propName] = {
|
|
3205
|
-
get: createGetter(propName),
|
|
3206
|
-
set: createSetter(propName),
|
|
3207
|
-
enumerable: true,
|
|
3208
|
-
configurable: true
|
|
3209
|
-
};
|
|
3210
|
-
}
|
|
3211
|
-
// expose public methods as props on the new Element Bridge
|
|
3212
|
-
for (let i = 0, len = methods.length; i < len; i += 1) {
|
|
3213
|
-
const methodName = methods[i];
|
|
3214
|
-
descriptors[methodName] = {
|
|
3215
|
-
value: createMethodCaller(methodName),
|
|
3216
|
-
writable: true,
|
|
3217
|
-
configurable: true
|
|
3218
|
-
};
|
|
3219
|
-
}
|
|
3220
|
-
// creating a new attributeChangedCallback per bridge because they are bound to the corresponding
|
|
3221
|
-
// map of attributes to props. We do this after all other props and methods to avoid the possibility
|
|
3222
|
-
// of getting overrule by a class declaration in user-land, and we make it non-writable, non-configurable
|
|
3223
|
-
// to preserve this definition.
|
|
3224
|
-
descriptors.attributeChangedCallback = {
|
|
3225
|
-
value: createAttributeChangedCallback(attributeToPropMap, superAttributeChangedCallback)
|
|
3226
|
-
};
|
|
3227
|
-
// Specify attributes for which we want to reflect changes back to their corresponding
|
|
3228
|
-
// properties via attributeChangedCallback.
|
|
3229
|
-
defineProperty(HTMLBridgeElement, 'observedAttributes', {
|
|
3230
|
-
get() {
|
|
3231
|
-
return [...superObservedAttributes, ...keys(attributeToPropMap)];
|
|
3232
|
-
}
|
|
3233
|
-
});
|
|
3234
|
-
defineProperties(HTMLBridgeElement.prototype, descriptors);
|
|
3235
|
-
return HTMLBridgeElement;
|
|
3075
|
+
defineProperties(HTMLBridgeElement.prototype, descriptors);
|
|
3076
|
+
return HTMLBridgeElement;
|
|
3236
3077
|
}
|
|
3237
3078
|
const BaseBridgeElement = HTMLBridgeElementFactory(HTMLElementConstructor, getOwnPropertyNames$1(HTMLElementOriginalDescriptors), []);
|
|
3238
3079
|
freeze(BaseBridgeElement);
|
|
@@ -3552,157 +3393,137 @@ function getComponentDef(Ctor) {
|
|
|
3552
3393
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3553
3394
|
*/
|
|
3554
3395
|
function makeHostToken(token) {
|
|
3555
|
-
|
|
3396
|
+
return `${token}-host`;
|
|
3556
3397
|
}
|
|
3557
3398
|
function createInlineStyleVNode(content) {
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3399
|
+
return api.h('style', {
|
|
3400
|
+
key: 'style',
|
|
3401
|
+
attrs: {
|
|
3402
|
+
type: 'text/css',
|
|
3403
|
+
},
|
|
3404
|
+
}, [api.t(content)]);
|
|
3564
3405
|
}
|
|
3565
3406
|
function updateStylesheetToken(vm, template) {
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
renderMode
|
|
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
|
-
|
|
3605
|
-
|
|
3606
|
-
// associated stylesheets. In the case of light DOM, also ensure there is at least one scoped stylesheet.
|
|
3607
|
-
const hasNewStylesheets = hasStyles(newStylesheets);
|
|
3608
|
-
const hasNewVmStylesheets = hasStyles(newVmStylesheets);
|
|
3609
|
-
if (hasNewStylesheets || hasNewVmStylesheets) {
|
|
3610
|
-
newToken = newStylesheetToken;
|
|
3611
|
-
}
|
|
3612
|
-
// Set the new styling token on the host element
|
|
3613
|
-
if (!isUndefined$1(newToken)) {
|
|
3614
|
-
if (hasScopedStyles) {
|
|
3615
|
-
getClassList(elm).add(makeHostToken(newToken));
|
|
3616
|
-
newHasTokenInClass = true;
|
|
3617
|
-
}
|
|
3618
|
-
if (isSyntheticShadow) {
|
|
3619
|
-
setAttribute(elm, makeHostToken(newToken), '');
|
|
3620
|
-
newHasTokenInAttribute = true;
|
|
3621
|
-
}
|
|
3622
|
-
}
|
|
3623
|
-
// Update the styling tokens present on the context object.
|
|
3624
|
-
context.stylesheetToken = newToken;
|
|
3625
|
-
context.hasTokenInClass = newHasTokenInClass;
|
|
3626
|
-
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;
|
|
3627
3447
|
}
|
|
3628
3448
|
function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
|
|
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
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
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
|
+
}
|
|
3672
3499
|
}
|
|
3673
|
-
|
|
3674
|
-
return content;
|
|
3500
|
+
return content;
|
|
3675
3501
|
}
|
|
3676
3502
|
function getStylesheetsContent(vm, template) {
|
|
3677
|
-
|
|
3678
|
-
stylesheets
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
// VM (component) stylesheets apply after template stylesheets
|
|
3689
|
-
if (hasStyles(vmStylesheets)) {
|
|
3690
|
-
ArrayPush$1.apply(content, evaluateStylesheetsContent(vmStylesheets, stylesheetToken, vm));
|
|
3691
|
-
}
|
|
3692
|
-
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;
|
|
3693
3514
|
}
|
|
3694
3515
|
// It might be worth caching this to avoid doing the lookup repeatedly, but
|
|
3695
3516
|
// perf testing has not shown it to be a huge improvement yet:
|
|
3696
3517
|
// https://github.com/salesforce/lwc/pull/2460#discussion_r691208892
|
|
3697
3518
|
function getNearestShadowComponent(vm) {
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3519
|
+
let owner = vm;
|
|
3520
|
+
while (!isNull(owner)) {
|
|
3521
|
+
if (owner.renderMode === 1 /* RenderMode.Shadow */) {
|
|
3522
|
+
return owner;
|
|
3523
|
+
}
|
|
3524
|
+
owner = owner.owner;
|
|
3702
3525
|
}
|
|
3703
|
-
|
|
3704
|
-
}
|
|
3705
|
-
return owner;
|
|
3526
|
+
return owner;
|
|
3706
3527
|
}
|
|
3707
3528
|
/**
|
|
3708
3529
|
* If the component that is currently being rendered uses scoped styles,
|
|
@@ -3710,32 +3531,24 @@ function getNearestShadowComponent(vm) {
|
|
|
3710
3531
|
* it returns null.
|
|
3711
3532
|
*/
|
|
3712
3533
|
function getScopeTokenClass(owner) {
|
|
3713
|
-
|
|
3714
|
-
cmpTemplate
|
|
3715
|
-
context
|
|
3716
|
-
} = owner;
|
|
3717
|
-
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;
|
|
3718
3536
|
}
|
|
3719
3537
|
function createStylesheet(vm, stylesheets) {
|
|
3720
|
-
|
|
3721
|
-
renderMode
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
}
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
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
|
+
}
|
|
3543
|
+
}
|
|
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);
|
|
3730
3550
|
}
|
|
3731
|
-
|
|
3732
|
-
// Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
|
|
3733
|
-
// This works in the client, because the stylesheets are created, and cached in the VM
|
|
3734
|
-
// the first time the VM renders.
|
|
3735
|
-
// native shadow or light DOM, SSR
|
|
3736
|
-
return ArrayMap.call(stylesheets, createInlineStyleVNode);
|
|
3737
|
-
}
|
|
3738
|
-
return null;
|
|
3551
|
+
return null;
|
|
3739
3552
|
}
|
|
3740
3553
|
|
|
3741
3554
|
/*
|
|
@@ -4043,496 +3856,433 @@ function applyStaticStyleAttribute(vnode, renderer) {
|
|
|
4043
3856
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
4044
3857
|
*/
|
|
4045
3858
|
function patchChildren(c1, c2, parent, renderer) {
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
|
|
3859
|
+
if (hasDynamicChildren(c2)) {
|
|
3860
|
+
updateDynamicChildren(c1, c2, parent, renderer);
|
|
3861
|
+
}
|
|
3862
|
+
else {
|
|
3863
|
+
updateStaticChildren(c1, c2, parent, renderer);
|
|
3864
|
+
}
|
|
4051
3865
|
}
|
|
4052
3866
|
function patch(n1, n2, parent, renderer) {
|
|
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
|
-
|
|
4086
|
-
|
|
4087
|
-
patchCustomElement(n1, n2, parent, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
|
|
4088
|
-
break;
|
|
4089
|
-
}
|
|
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
|
+
}
|
|
4090
3901
|
}
|
|
4091
3902
|
function mount(node, parent, renderer, anchor) {
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
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
|
+
}
|
|
4118
3929
|
}
|
|
4119
3930
|
function patchText(n1, n2, renderer) {
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
3931
|
+
n2.elm = n1.elm;
|
|
3932
|
+
if (n2.text !== n1.text) {
|
|
3933
|
+
updateTextContent(n2, renderer);
|
|
3934
|
+
}
|
|
4124
3935
|
}
|
|
4125
3936
|
function mountText(vnode, parent, anchor, renderer) {
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
} = renderer;
|
|
4132
|
-
const textNode = vnode.elm = createText(vnode.text);
|
|
4133
|
-
linkNodeToShadow(textNode, owner, renderer);
|
|
4134
|
-
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);
|
|
4135
3942
|
}
|
|
4136
3943
|
function patchComment(n1, n2, renderer) {
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
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
|
+
}
|
|
4143
3950
|
}
|
|
4144
3951
|
function mountComment(vnode, parent, anchor, renderer) {
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
} = renderer;
|
|
4151
|
-
const commentNode = vnode.elm = createComment(vnode.text);
|
|
4152
|
-
linkNodeToShadow(commentNode, owner, renderer);
|
|
4153
|
-
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);
|
|
4154
3957
|
}
|
|
4155
3958
|
function mountFragment(vnode, parent, anchor, renderer) {
|
|
4156
|
-
|
|
4157
|
-
children
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
// children of a fragment will always have at least the two delimiters.
|
|
4161
|
-
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;
|
|
4162
3963
|
}
|
|
4163
3964
|
function patchFragment(n1, n2, parent, renderer) {
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
// Note: not reusing n1.elm, because during patching, it may be patched with another text node.
|
|
4174
|
-
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;
|
|
4175
3974
|
}
|
|
4176
3975
|
function mountElement(vnode, parent, anchor, renderer) {
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
const elm = vnode.elm = createElement(sel, namespace);
|
|
4189
|
-
linkNodeToShadow(elm, owner, renderer);
|
|
4190
|
-
applyStyleScoping(elm, owner, renderer);
|
|
4191
|
-
applyDomManual(elm, vnode);
|
|
4192
|
-
applyElementRestrictions(elm, vnode);
|
|
4193
|
-
patchElementPropsAndAttrs$1(null, vnode, renderer);
|
|
4194
|
-
insertNode(elm, parent, anchor, renderer);
|
|
4195
|
-
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);
|
|
4196
3987
|
}
|
|
4197
3988
|
function patchElement(n1, n2, renderer) {
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
3989
|
+
const elm = (n2.elm = n1.elm);
|
|
3990
|
+
patchElementPropsAndAttrs$1(n1, n2, renderer);
|
|
3991
|
+
patchChildren(n1.children, n2.children, elm, renderer);
|
|
4201
3992
|
}
|
|
4202
3993
|
function mountStatic(vnode, parent, anchor, renderer) {
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
const {
|
|
4215
|
-
renderMode,
|
|
4216
|
-
shadowMode
|
|
4217
|
-
} = owner;
|
|
4218
|
-
if (isSyntheticShadowDefined) {
|
|
4219
|
-
if (shadowMode === 1 /* ShadowMode.Synthetic */ || renderMode === 0 /* RenderMode.Light */) {
|
|
4220
|
-
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
|
+
}
|
|
4221
4005
|
}
|
|
4222
|
-
|
|
4223
|
-
insertNode(elm, parent, anchor, renderer);
|
|
4006
|
+
insertNode(elm, parent, anchor, renderer);
|
|
4224
4007
|
}
|
|
4225
4008
|
function mountCustomElement(vnode, parent, anchor, renderer) {
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
*/
|
|
4239
|
-
let vm;
|
|
4240
|
-
const upgradeCallback = elm => {
|
|
4241
|
-
// the custom element from the registry is expecting an upgrade callback
|
|
4242
|
-
vm = createViewModelHook(elm, vnode, renderer);
|
|
4243
|
-
};
|
|
4244
|
-
let connectedCallback;
|
|
4245
|
-
let disconnectedCallback;
|
|
4246
|
-
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
4247
|
-
connectedCallback = elm => {
|
|
4248
|
-
connectRootElement(elm);
|
|
4249
|
-
};
|
|
4250
|
-
disconnectedCallback = elm => {
|
|
4251
|
-
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);
|
|
4252
4021
|
};
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
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);
|
|
4274
4057
|
}
|
|
4275
|
-
}
|
|
4276
|
-
mountVNodes(vnode.children, elm, renderer, null);
|
|
4277
|
-
if (vm) {
|
|
4278
|
-
appendVM(vm);
|
|
4279
|
-
}
|
|
4280
4058
|
}
|
|
4281
4059
|
function patchCustomElement(n1, n2, parent, renderer) {
|
|
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
|
-
|
|
4325
|
-
|
|
4326
|
-
|
|
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
|
+
}
|
|
4327
4106
|
}
|
|
4328
|
-
}
|
|
4329
4107
|
}
|
|
4330
4108
|
function mountVNodes(vnodes, parent, renderer, anchor, start = 0, end = vnodes.length) {
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4109
|
+
for (; start < end; ++start) {
|
|
4110
|
+
const vnode = vnodes[start];
|
|
4111
|
+
if (isVNode(vnode)) {
|
|
4112
|
+
mount(vnode, parent, renderer, anchor);
|
|
4113
|
+
}
|
|
4335
4114
|
}
|
|
4336
|
-
}
|
|
4337
4115
|
}
|
|
4338
4116
|
function unmount(vnode, parent, renderer, doRemove = false) {
|
|
4339
|
-
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
// subtree root, is the only element worth unmounting from the subtree.
|
|
4346
|
-
if (doRemove) {
|
|
4347
|
-
if (type === 5 /* VNodeType.Fragment */) {
|
|
4348
|
-
unmountVNodes(vnode.children, parent, renderer, doRemove);
|
|
4349
|
-
} else {
|
|
4350
|
-
// The vnode might or might not have a data.renderer associated to it
|
|
4351
|
-
// but the removal used here is from the owner instead.
|
|
4352
|
-
removeNode(elm, parent, renderer);
|
|
4353
|
-
}
|
|
4354
|
-
}
|
|
4355
|
-
switch (type) {
|
|
4356
|
-
case 2 /* VNodeType.Element */:
|
|
4357
|
-
{
|
|
4358
|
-
// Slot content is removed to trigger slotchange event when removing slot.
|
|
4359
|
-
// Only required for synthetic shadow.
|
|
4360
|
-
const shouldRemoveChildren = sel === 'slot' && vnode.owner.shadowMode === 1 /* ShadowMode.Synthetic */;
|
|
4361
|
-
unmountVNodes(vnode.children, elm, renderer, shouldRemoveChildren);
|
|
4362
|
-
break;
|
|
4363
|
-
}
|
|
4364
|
-
case 3 /* VNodeType.CustomElement */:
|
|
4365
|
-
{
|
|
4366
|
-
const {
|
|
4367
|
-
vm
|
|
4368
|
-
} = vnode;
|
|
4369
|
-
// No need to unmount the children here, `removeVM` will take care of removing the
|
|
4370
|
-
// children.
|
|
4371
|
-
if (!isUndefined$1(vm)) {
|
|
4372
|
-
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);
|
|
4373
4123
|
}
|
|
4374
|
-
|
|
4375
|
-
|
|
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
|
+
}
|
|
4145
|
+
}
|
|
4146
|
+
}
|
|
4376
4147
|
}
|
|
4377
4148
|
function unmountVNodes(vnodes, parent, renderer, doRemove = false, start = 0, end = vnodes.length) {
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4149
|
+
for (; start < end; ++start) {
|
|
4150
|
+
const ch = vnodes[start];
|
|
4151
|
+
if (isVNode(ch)) {
|
|
4152
|
+
unmount(ch, parent, renderer, doRemove);
|
|
4153
|
+
}
|
|
4382
4154
|
}
|
|
4383
|
-
}
|
|
4384
4155
|
}
|
|
4385
4156
|
function isVNode(vnode) {
|
|
4386
|
-
|
|
4157
|
+
return vnode != null;
|
|
4387
4158
|
}
|
|
4388
4159
|
function linkNodeToShadow(elm, owner, renderer) {
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
} = renderer;
|
|
4397
|
-
// TODO [#1164]: this should eventually be done by the polyfill directly
|
|
4398
|
-
if (isSyntheticShadowDefined) {
|
|
4399
|
-
if (shadowMode === 1 /* ShadowMode.Synthetic */ || renderMode === 0 /* RenderMode.Light */) {
|
|
4400
|
-
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
|
+
}
|
|
4401
4167
|
}
|
|
4402
|
-
}
|
|
4403
4168
|
}
|
|
4404
4169
|
function updateTextContent(vnode, renderer) {
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
setText
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
}
|
|
4415
|
-
setText(elm, text);
|
|
4416
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
4417
|
-
lockDomMutation();
|
|
4418
|
-
}
|
|
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
|
+
}
|
|
4419
4179
|
}
|
|
4420
4180
|
function insertNode(node, parent, anchor, renderer) {
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
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
|
+
}
|
|
4428
4188
|
}
|
|
4429
4189
|
function removeNode(node, parent, renderer) {
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
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
|
+
}
|
|
4437
4197
|
}
|
|
4438
4198
|
function patchElementPropsAndAttrs$1(oldVnode, vnode, renderer) {
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
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);
|
|
4454
4215
|
}
|
|
4455
4216
|
function applyStyleScoping(elm, owner, renderer) {
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
|
|
4466
|
-
|
|
4467
|
-
|
|
4468
|
-
|
|
4469
|
-
} = owner.context;
|
|
4470
|
-
if (owner.shadowMode === 1 /* ShadowMode.Synthetic */ && !isUndefined$1(syntheticToken)) {
|
|
4471
|
-
elm.$shadowToken$ = syntheticToken;
|
|
4472
|
-
}
|
|
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
|
+
}
|
|
4473
4230
|
}
|
|
4474
4231
|
function applyDomManual(elm, vnode) {
|
|
4475
|
-
|
|
4476
|
-
|
|
4477
|
-
owner
|
|
4478
|
-
|
|
4479
|
-
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;
|
|
4480
4236
|
}
|
|
4481
|
-
} = vnode;
|
|
4482
|
-
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 */) {
|
|
4483
|
-
elm.$domManual$ = true;
|
|
4484
|
-
}
|
|
4485
4237
|
}
|
|
4486
4238
|
function applyElementRestrictions(elm, vnode) {
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
|
|
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
|
+
}
|
|
4498
4250
|
}
|
|
4499
4251
|
function allocateChildren(vnode, vm) {
|
|
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
|
-
|
|
4533
|
-
|
|
4534
|
-
vnode.children = EmptyArray;
|
|
4535
|
-
}
|
|
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
|
+
}
|
|
4536
4286
|
}
|
|
4537
4287
|
/**
|
|
4538
4288
|
* Flattens the contents of all VFragments in an array of VNodes, removes the text delimiters on those VFragments, and
|
|
@@ -4544,275 +4294,278 @@ function allocateChildren(vnode, vm) {
|
|
|
4544
4294
|
* This function is used for slotted VFragments to avoid the text delimiters interfering with slotting functionality.
|
|
4545
4295
|
*/
|
|
4546
4296
|
function flattenFragmentsInChildren(children) {
|
|
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
|
-
|
|
4575
|
-
|
|
4576
|
-
|
|
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;
|
|
4577
4328
|
}
|
|
4578
4329
|
function createViewModelHook(elm, vnode, renderer) {
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
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
|
+
}
|
|
4584
4346
|
return vm;
|
|
4585
|
-
}
|
|
4586
|
-
const {
|
|
4587
|
-
sel,
|
|
4588
|
-
mode,
|
|
4589
|
-
ctor,
|
|
4590
|
-
owner
|
|
4591
|
-
} = vnode;
|
|
4592
|
-
vm = createVM(elm, ctor, renderer, {
|
|
4593
|
-
mode,
|
|
4594
|
-
owner,
|
|
4595
|
-
tagName: sel
|
|
4596
|
-
});
|
|
4597
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
4598
|
-
assert.isTrue(isArray$1(vnode.children), `Invalid vnode for a custom element, it must have children defined.`);
|
|
4599
|
-
}
|
|
4600
|
-
return vm;
|
|
4601
4347
|
}
|
|
4602
4348
|
function allocateInSlot(vm, children, owner) {
|
|
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
|
-
|
|
4651
|
-
|
|
4652
|
-
markComponentAsDirty(vm);
|
|
4653
|
-
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
|
+
}
|
|
4654
4398
|
}
|
|
4655
|
-
}
|
|
4656
4399
|
}
|
|
4657
|
-
}
|
|
4658
4400
|
}
|
|
4659
4401
|
// Using a WeakMap instead of a WeakSet because this one works in IE11 :(
|
|
4660
4402
|
const DynamicChildren = new WeakMap();
|
|
4661
4403
|
// dynamic children means it was either generated by an iteration in a template
|
|
4662
4404
|
// or part of an unstable fragment, and will require a more complex diffing algo.
|
|
4663
4405
|
function markAsDynamicChildren(children) {
|
|
4664
|
-
|
|
4406
|
+
DynamicChildren.set(children, 1);
|
|
4665
4407
|
}
|
|
4666
4408
|
function hasDynamicChildren(children) {
|
|
4667
|
-
|
|
4409
|
+
return DynamicChildren.has(children);
|
|
4668
4410
|
}
|
|
4669
4411
|
function createKeyToOldIdx(children, beginIdx, endIdx) {
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
|
-
|
|
4682
|
-
}
|
|
4683
|
-
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;
|
|
4684
4424
|
}
|
|
4685
4425
|
function updateDynamicChildren(oldCh, newCh, parent, renderer) {
|
|
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
|
-
|
|
4739
|
-
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
// Delete the old child, but copy the array since it is read-only.
|
|
4747
|
-
// The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
|
|
4748
|
-
// so we only care about the `oldCh` object inside this function.
|
|
4749
|
-
// To avoid cloning over and over again, we check `clonedOldCh`
|
|
4750
|
-
// and only clone once.
|
|
4751
|
-
if (!clonedOldCh) {
|
|
4752
|
-
clonedOldCh = true;
|
|
4753
|
-
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);
|
|
4480
|
+
}
|
|
4481
|
+
idxInOld = oldKeyToIdx[newStartVnode.key];
|
|
4482
|
+
if (isUndefined$1(idxInOld)) {
|
|
4483
|
+
// New element
|
|
4484
|
+
mount(newStartVnode, parent, renderer, oldStartVnode.elm);
|
|
4485
|
+
newStartVnode = newCh[++newStartIdx];
|
|
4754
4486
|
}
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
|
|
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
|
+
}
|
|
4779
4530
|
}
|
|
4780
4531
|
function updateStaticChildren(c1, c2, parent, renderer) {
|
|
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
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
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
|
+
}
|
|
4816
4569
|
}
|
|
4817
4570
|
|
|
4818
4571
|
/*
|
|
@@ -5749,400 +5502,366 @@ let idx = 0;
|
|
|
5749
5502
|
/** The internal slot used to associate different objects the engine manipulates with the VM */
|
|
5750
5503
|
const ViewModelReflection = new WeakMap();
|
|
5751
5504
|
function callHook(cmp, fn, args = []) {
|
|
5752
|
-
|
|
5505
|
+
return fn.apply(cmp, args);
|
|
5753
5506
|
}
|
|
5754
5507
|
function setHook(cmp, prop, newValue) {
|
|
5755
|
-
|
|
5508
|
+
cmp[prop] = newValue;
|
|
5756
5509
|
}
|
|
5757
5510
|
function getHook(cmp, prop) {
|
|
5758
|
-
|
|
5511
|
+
return cmp[prop];
|
|
5759
5512
|
}
|
|
5760
5513
|
function rerenderVM(vm) {
|
|
5761
|
-
|
|
5514
|
+
rehydrate(vm);
|
|
5762
5515
|
}
|
|
5763
5516
|
function connectRootElement(elm) {
|
|
5764
|
-
|
|
5765
|
-
|
|
5766
|
-
|
|
5767
|
-
|
|
5768
|
-
|
|
5769
|
-
|
|
5770
|
-
|
|
5771
|
-
|
|
5772
|
-
|
|
5773
|
-
|
|
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);
|
|
5774
5527
|
}
|
|
5775
5528
|
function disconnectRootElement(elm) {
|
|
5776
|
-
|
|
5777
|
-
|
|
5529
|
+
const vm = getAssociatedVM(elm);
|
|
5530
|
+
resetComponentStateWhenRemoved(vm);
|
|
5778
5531
|
}
|
|
5779
5532
|
function appendVM(vm) {
|
|
5780
|
-
|
|
5533
|
+
rehydrate(vm);
|
|
5781
5534
|
}
|
|
5782
5535
|
// just in case the component comes back, with this we guarantee re-rendering it
|
|
5783
5536
|
// while preventing any attempt to rehydration until after reinsertion.
|
|
5784
5537
|
function resetComponentStateWhenRemoved(vm) {
|
|
5785
|
-
|
|
5786
|
-
state
|
|
5787
|
-
|
|
5788
|
-
|
|
5789
|
-
|
|
5790
|
-
|
|
5791
|
-
|
|
5792
|
-
|
|
5793
|
-
|
|
5794
|
-
|
|
5795
|
-
|
|
5796
|
-
|
|
5797
|
-
|
|
5798
|
-
}
|
|
5799
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
5800
|
-
removeActiveVM(vm);
|
|
5801
|
-
}
|
|
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
|
+
}
|
|
5802
5551
|
}
|
|
5803
5552
|
// this method is triggered by the diffing algo only when a vnode from the
|
|
5804
5553
|
// old vnode.children is removed from the DOM.
|
|
5805
5554
|
function removeVM(vm) {
|
|
5806
|
-
|
|
5807
|
-
|
|
5808
|
-
|
|
5809
|
-
|
|
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);
|
|
5810
5559
|
}
|
|
5811
5560
|
function getNearestShadowAncestor(vm) {
|
|
5812
|
-
|
|
5813
|
-
|
|
5814
|
-
|
|
5815
|
-
|
|
5816
|
-
|
|
5561
|
+
let ancestor = vm.owner;
|
|
5562
|
+
while (!isNull(ancestor) && ancestor.renderMode === 0 /* RenderMode.Light */) {
|
|
5563
|
+
ancestor = ancestor.owner;
|
|
5564
|
+
}
|
|
5565
|
+
return ancestor;
|
|
5817
5566
|
}
|
|
5818
5567
|
function createVM(elm, ctor, renderer, options) {
|
|
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
|
-
|
|
5862
|
-
|
|
5863
|
-
component: null,
|
|
5864
|
-
shadowRoot: null,
|
|
5865
|
-
renderRoot: null,
|
|
5866
|
-
callHook,
|
|
5867
|
-
setHook,
|
|
5868
|
-
getHook,
|
|
5869
|
-
renderer
|
|
5870
|
-
};
|
|
5871
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
5872
|
-
vm.debugInfo = create(null);
|
|
5873
|
-
}
|
|
5874
|
-
vm.stylesheets = computeStylesheets(vm, def.ctor);
|
|
5875
|
-
vm.shadowMode = computeShadowMode(vm, renderer);
|
|
5876
|
-
vm.tro = getTemplateReactiveObserver();
|
|
5877
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
5878
|
-
vm.toString = () => {
|
|
5879
|
-
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,
|
|
5880
5612
|
};
|
|
5881
|
-
if (
|
|
5882
|
-
|
|
5883
|
-
}
|
|
5884
|
-
|
|
5885
|
-
|
|
5886
|
-
|
|
5887
|
-
|
|
5888
|
-
|
|
5889
|
-
|
|
5890
|
-
|
|
5891
|
-
|
|
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;
|
|
5892
5634
|
}
|
|
5893
5635
|
function validateComponentStylesheets(vm, stylesheets) {
|
|
5894
|
-
|
|
5895
|
-
|
|
5896
|
-
|
|
5897
|
-
|
|
5898
|
-
|
|
5899
|
-
|
|
5900
|
-
|
|
5901
|
-
|
|
5902
|
-
|
|
5903
|
-
|
|
5904
|
-
|
|
5905
|
-
|
|
5906
|
-
|
|
5907
|
-
|
|
5908
|
-
|
|
5909
|
-
|
|
5910
|
-
|
|
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;
|
|
5911
5655
|
}
|
|
5912
5656
|
// Validate and flatten any stylesheets defined as `static stylesheets`
|
|
5913
5657
|
function computeStylesheets(vm, ctor) {
|
|
5914
|
-
if (lwcRuntimeFlags.ENABLE_PROGRAMMATIC_STYLESHEETS) {
|
|
5915
5658
|
warnOnStylesheetsMutation(ctor);
|
|
5916
|
-
const {
|
|
5917
|
-
stylesheets
|
|
5918
|
-
} = ctor;
|
|
5659
|
+
const { stylesheets } = ctor;
|
|
5919
5660
|
if (!isUndefined$1(stylesheets)) {
|
|
5920
|
-
|
|
5921
|
-
|
|
5922
|
-
|
|
5923
|
-
|
|
5924
|
-
|
|
5925
|
-
|
|
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
|
+
}
|
|
5926
5668
|
}
|
|
5927
|
-
|
|
5928
|
-
return null;
|
|
5669
|
+
return null;
|
|
5929
5670
|
}
|
|
5930
5671
|
function warnOnStylesheetsMutation(ctor) {
|
|
5931
|
-
|
|
5932
|
-
|
|
5933
|
-
|
|
5934
|
-
|
|
5935
|
-
|
|
5936
|
-
|
|
5937
|
-
|
|
5938
|
-
|
|
5939
|
-
|
|
5940
|
-
|
|
5941
|
-
|
|
5942
|
-
|
|
5943
|
-
|
|
5944
|
-
|
|
5945
|
-
}
|
|
5946
|
-
}
|
|
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
|
+
}
|
|
5947
5687
|
}
|
|
5948
5688
|
function computeShadowMode(vm, renderer) {
|
|
5949
|
-
|
|
5950
|
-
|
|
5951
|
-
|
|
5952
|
-
|
|
5953
|
-
|
|
5954
|
-
|
|
5955
|
-
|
|
5956
|
-
let shadowMode;
|
|
5957
|
-
if (isSyntheticShadowDefined) {
|
|
5958
|
-
if (def.renderMode === 0 /* RenderMode.Light */) {
|
|
5959
|
-
// ShadowMode.Native implies "not synthetic shadow" which is consistent with how
|
|
5960
|
-
// everything defaults to native when the synthetic shadow polyfill is unavailable.
|
|
5961
|
-
shadowMode = 0 /* ShadowMode.Native */;
|
|
5962
|
-
} else if (isNativeShadowDefined) {
|
|
5963
|
-
// Not combined with above condition because @lwc/features only supports identifiers in
|
|
5964
|
-
// the if-condition.
|
|
5965
|
-
if (lwcRuntimeFlags.ENABLE_MIXED_SHADOW_MODE) {
|
|
5966
|
-
if (def.shadowSupportMode === "any" /* ShadowSupportMode.Any */) {
|
|
5967
|
-
shadowMode = 0 /* ShadowMode.Native */;
|
|
5968
|
-
} else {
|
|
5969
|
-
const shadowAncestor = getNearestShadowAncestor(vm);
|
|
5970
|
-
if (!isNull(shadowAncestor) && shadowAncestor.shadowMode === 0 /* ShadowMode.Native */) {
|
|
5971
|
-
// Transitive support for native Shadow DOM. A component in native mode
|
|
5972
|
-
// 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.
|
|
5973
5696
|
shadowMode = 0 /* ShadowMode.Native */;
|
|
5974
|
-
|
|
5975
|
-
|
|
5976
|
-
//
|
|
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.
|
|
5977
5726
|
shadowMode = 1 /* ShadowMode.Synthetic */;
|
|
5978
|
-
|
|
5979
|
-
|
|
5980
|
-
|
|
5981
|
-
|
|
5982
|
-
|
|
5983
|
-
}
|
|
5984
|
-
|
|
5985
|
-
shadowMode = 1 /* ShadowMode.Synthetic */;
|
|
5986
|
-
}
|
|
5987
|
-
} else {
|
|
5988
|
-
// Native if the synthetic shadow polyfill is unavailable.
|
|
5989
|
-
shadowMode = 0 /* ShadowMode.Native */;
|
|
5990
|
-
}
|
|
5991
|
-
|
|
5992
|
-
return shadowMode;
|
|
5727
|
+
}
|
|
5728
|
+
}
|
|
5729
|
+
else {
|
|
5730
|
+
// Native if the synthetic shadow polyfill is unavailable.
|
|
5731
|
+
shadowMode = 0 /* ShadowMode.Native */;
|
|
5732
|
+
}
|
|
5733
|
+
return shadowMode;
|
|
5993
5734
|
}
|
|
5994
5735
|
function assertIsVM(obj) {
|
|
5995
|
-
|
|
5996
|
-
|
|
5997
|
-
|
|
5736
|
+
if (isNull(obj) || !isObject(obj) || !('renderRoot' in obj)) {
|
|
5737
|
+
throw new TypeError(`${obj} is not a VM.`);
|
|
5738
|
+
}
|
|
5998
5739
|
}
|
|
5999
5740
|
function associateVM(obj, vm) {
|
|
6000
|
-
|
|
5741
|
+
ViewModelReflection.set(obj, vm);
|
|
6001
5742
|
}
|
|
6002
5743
|
function getAssociatedVM(obj) {
|
|
6003
|
-
|
|
6004
|
-
|
|
6005
|
-
|
|
6006
|
-
|
|
6007
|
-
|
|
5744
|
+
const vm = ViewModelReflection.get(obj);
|
|
5745
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
5746
|
+
assertIsVM(vm);
|
|
5747
|
+
}
|
|
5748
|
+
return vm;
|
|
6008
5749
|
}
|
|
6009
5750
|
function getAssociatedVMIfPresent(obj) {
|
|
6010
|
-
|
|
6011
|
-
|
|
6012
|
-
|
|
6013
|
-
|
|
5751
|
+
const maybeVm = ViewModelReflection.get(obj);
|
|
5752
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
5753
|
+
if (!isUndefined$1(maybeVm)) {
|
|
5754
|
+
assertIsVM(maybeVm);
|
|
5755
|
+
}
|
|
6014
5756
|
}
|
|
6015
|
-
|
|
6016
|
-
return maybeVm;
|
|
5757
|
+
return maybeVm;
|
|
6017
5758
|
}
|
|
6018
5759
|
function rehydrate(vm) {
|
|
6019
|
-
|
|
6020
|
-
|
|
6021
|
-
|
|
6022
|
-
|
|
5760
|
+
if (isTrue(vm.isDirty)) {
|
|
5761
|
+
const children = renderComponent$1(vm);
|
|
5762
|
+
patchShadowRoot(vm, children);
|
|
5763
|
+
}
|
|
6023
5764
|
}
|
|
6024
5765
|
function patchShadowRoot(vm, newCh) {
|
|
6025
|
-
|
|
6026
|
-
|
|
6027
|
-
children
|
|
6028
|
-
|
|
6029
|
-
|
|
6030
|
-
|
|
6031
|
-
|
|
6032
|
-
|
|
6033
|
-
|
|
6034
|
-
|
|
6035
|
-
|
|
6036
|
-
|
|
6037
|
-
|
|
6038
|
-
|
|
6039
|
-
|
|
6040
|
-
|
|
6041
|
-
|
|
6042
|
-
|
|
6043
|
-
// post
|
|
6044
|
-
logOperationEnd(2 /* OperationId.Patch */, vm);
|
|
6045
|
-
});
|
|
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
|
+
}
|
|
6046
5784
|
}
|
|
6047
|
-
|
|
6048
|
-
if (vm.state === 1 /* VMState.connected */) ;
|
|
5785
|
+
if (vm.state === 1 /* VMState.connected */) ;
|
|
6049
5786
|
}
|
|
6050
|
-
|
|
6051
5787
|
function runConnectedCallback(vm) {
|
|
6052
|
-
|
|
6053
|
-
state
|
|
6054
|
-
|
|
6055
|
-
|
|
6056
|
-
|
|
6057
|
-
|
|
6058
|
-
|
|
6059
|
-
|
|
6060
|
-
|
|
6061
|
-
|
|
6062
|
-
|
|
6063
|
-
|
|
6064
|
-
|
|
6065
|
-
|
|
6066
|
-
|
|
6067
|
-
|
|
6068
|
-
|
|
6069
|
-
|
|
6070
|
-
|
|
6071
|
-
connectedCallback
|
|
6072
|
-
} = vm.def;
|
|
6073
|
-
if (!isUndefined$1(connectedCallback)) {
|
|
6074
|
-
logOperationStart(3 /* OperationId.ConnectedCallback */, vm);
|
|
6075
|
-
invokeComponentCallback(vm, connectedCallback);
|
|
6076
|
-
logOperationEnd(3 /* OperationId.ConnectedCallback */, vm);
|
|
6077
|
-
}
|
|
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
|
+
}
|
|
6078
5807
|
}
|
|
6079
5808
|
function hasWireAdapters(vm) {
|
|
6080
|
-
|
|
5809
|
+
return getOwnPropertyNames$1(vm.def.wire).length > 0;
|
|
6081
5810
|
}
|
|
6082
5811
|
function runDisconnectedCallback(vm) {
|
|
6083
|
-
|
|
6084
|
-
|
|
6085
|
-
|
|
6086
|
-
|
|
6087
|
-
|
|
6088
|
-
|
|
6089
|
-
|
|
6090
|
-
|
|
6091
|
-
|
|
6092
|
-
|
|
6093
|
-
|
|
6094
|
-
|
|
6095
|
-
|
|
6096
|
-
disconnected
|
|
6097
|
-
|
|
6098
|
-
|
|
6099
|
-
|
|
6100
|
-
|
|
6101
|
-
|
|
6102
|
-
|
|
6103
|
-
|
|
6104
|
-
|
|
6105
|
-
|
|
6106
|
-
|
|
6107
|
-
|
|
6108
|
-
logOperationStart(5 /* OperationId.DisconnectedCallback */, vm);
|
|
6109
|
-
invokeComponentCallback(vm, disconnectedCallback);
|
|
6110
|
-
logOperationEnd(5 /* OperationId.DisconnectedCallback */, vm);
|
|
6111
|
-
}
|
|
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
|
+
}
|
|
6112
5837
|
}
|
|
6113
5838
|
function runChildNodesDisconnectedCallback(vm) {
|
|
6114
|
-
|
|
6115
|
-
|
|
6116
|
-
|
|
6117
|
-
|
|
6118
|
-
|
|
6119
|
-
|
|
6120
|
-
|
|
6121
|
-
|
|
6122
|
-
|
|
6123
|
-
|
|
6124
|
-
|
|
6125
|
-
|
|
6126
|
-
|
|
6127
|
-
|
|
6128
|
-
|
|
6129
|
-
|
|
6130
|
-
|
|
6131
|
-
|
|
6132
|
-
|
|
6133
|
-
|
|
6134
|
-
|
|
6135
|
-
|
|
6136
|
-
resetComponentStateWhenRemoved(childVM);
|
|
6137
|
-
}
|
|
6138
|
-
}
|
|
6139
|
-
}
|
|
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
|
+
}
|
|
6140
5861
|
}
|
|
6141
5862
|
function runLightChildNodesDisconnectedCallback(vm) {
|
|
6142
|
-
|
|
6143
|
-
|
|
6144
|
-
} = vm;
|
|
6145
|
-
recursivelyDisconnectChildren(adoptedChildren);
|
|
5863
|
+
const { aChildren: adoptedChildren } = vm;
|
|
5864
|
+
recursivelyDisconnectChildren(adoptedChildren);
|
|
6146
5865
|
}
|
|
6147
5866
|
/**
|
|
6148
5867
|
* The recursion doesn't need to be a complete traversal of the vnode graph,
|
|
@@ -6152,78 +5871,72 @@ function runLightChildNodesDisconnectedCallback(vm) {
|
|
|
6152
5871
|
* defined on its shadow.
|
|
6153
5872
|
*/
|
|
6154
5873
|
function recursivelyDisconnectChildren(vnodes) {
|
|
6155
|
-
|
|
6156
|
-
|
|
6157
|
-
|
|
6158
|
-
|
|
6159
|
-
|
|
6160
|
-
|
|
6161
|
-
|
|
6162
|
-
|
|
6163
|
-
|
|
6164
|
-
|
|
6165
|
-
|
|
6166
|
-
|
|
6167
|
-
|
|
6168
|
-
|
|
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
|
+
}
|
|
6169
5888
|
}
|
|
6170
|
-
}
|
|
6171
5889
|
}
|
|
6172
5890
|
// This is a super optimized mechanism to remove the content of the root node (shadow root
|
|
6173
5891
|
// for shadow DOM components and the root element itself for light DOM) without having to go
|
|
6174
5892
|
// into snabbdom. Especially useful when the reset is a consequence of an error, in which case the
|
|
6175
5893
|
// children VNodes might not be representing the current state of the DOM.
|
|
6176
5894
|
function resetComponentRoot(vm) {
|
|
6177
|
-
|
|
6178
|
-
children
|
|
6179
|
-
|
|
6180
|
-
|
|
6181
|
-
|
|
6182
|
-
|
|
6183
|
-
|
|
6184
|
-
|
|
6185
|
-
|
|
6186
|
-
|
|
6187
|
-
remove(child.elm, renderRoot);
|
|
6188
|
-
}
|
|
6189
|
-
}
|
|
6190
|
-
vm.children = EmptyArray;
|
|
6191
|
-
runChildNodesDisconnectedCallback(vm);
|
|
6192
|
-
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;
|
|
6193
5905
|
}
|
|
6194
5906
|
function getErrorBoundaryVM(vm) {
|
|
6195
|
-
|
|
6196
|
-
|
|
6197
|
-
|
|
6198
|
-
|
|
5907
|
+
let currentVm = vm;
|
|
5908
|
+
while (!isNull(currentVm)) {
|
|
5909
|
+
if (!isUndefined$1(currentVm.def.errorCallback)) {
|
|
5910
|
+
return currentVm;
|
|
5911
|
+
}
|
|
5912
|
+
currentVm = currentVm.owner;
|
|
6199
5913
|
}
|
|
6200
|
-
currentVm = currentVm.owner;
|
|
6201
|
-
}
|
|
6202
5914
|
}
|
|
6203
5915
|
function runWithBoundaryProtection(vm, owner, pre, job, post) {
|
|
6204
|
-
|
|
6205
|
-
|
|
6206
|
-
|
|
6207
|
-
|
|
6208
|
-
|
|
6209
|
-
|
|
6210
|
-
|
|
6211
|
-
|
|
6212
|
-
|
|
6213
|
-
|
|
6214
|
-
|
|
6215
|
-
|
|
6216
|
-
|
|
6217
|
-
|
|
6218
|
-
|
|
6219
|
-
|
|
6220
|
-
|
|
6221
|
-
|
|
6222
|
-
|
|
6223
|
-
|
|
6224
|
-
|
|
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
|
+
}
|
|
6225
5939
|
}
|
|
6226
|
-
}
|
|
6227
5940
|
}
|
|
6228
5941
|
|
|
6229
5942
|
/*
|
|
@@ -6310,185 +6023,199 @@ function setHooks(hooks) {
|
|
|
6310
6023
|
const TEMPLATE_PROPS = ['slots', 'stylesheetToken', 'stylesheets', 'renderMode'];
|
|
6311
6024
|
// Expandos that may be placed on a stylesheet factory function, and which are meaningful to LWC at runtime
|
|
6312
6025
|
const STYLESHEET_PROPS = [
|
|
6313
|
-
// SEE `KEY__SCOPED_CSS` in @lwc/style-compiler
|
|
6314
|
-
'$scoped$'
|
|
6026
|
+
// SEE `KEY__SCOPED_CSS` in @lwc/style-compiler
|
|
6027
|
+
'$scoped$',
|
|
6028
|
+
];
|
|
6315
6029
|
// Via https://www.npmjs.com/package/object-observer
|
|
6316
|
-
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
|
+
];
|
|
6317
6041
|
let mutationTrackingDisabled = false;
|
|
6318
6042
|
function getOriginalArrayMethod(prop) {
|
|
6319
|
-
|
|
6320
|
-
|
|
6321
|
-
|
|
6322
|
-
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
|
|
6326
|
-
|
|
6327
|
-
|
|
6328
|
-
|
|
6329
|
-
|
|
6330
|
-
|
|
6331
|
-
|
|
6332
|
-
|
|
6333
|
-
|
|
6334
|
-
|
|
6335
|
-
|
|
6336
|
-
|
|
6337
|
-
|
|
6338
|
-
|
|
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
|
+
}
|
|
6339
6063
|
}
|
|
6340
6064
|
function reportViolation(type, eventId, prop) {
|
|
6341
|
-
|
|
6342
|
-
|
|
6343
|
-
|
|
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
|
+
}
|
|
6344
6070
|
}
|
|
6345
6071
|
function reportTemplateViolation(prop) {
|
|
6346
|
-
|
|
6072
|
+
reportViolation('template', 3 /* ReportingEventId.TemplateMutation */, prop);
|
|
6347
6073
|
}
|
|
6348
6074
|
function reportStylesheetViolation(prop) {
|
|
6349
|
-
|
|
6075
|
+
reportViolation('stylesheet', 4 /* ReportingEventId.StylesheetMutation */, prop);
|
|
6350
6076
|
}
|
|
6351
6077
|
// Warn if the user tries to mutate a stylesheets array, e.g.:
|
|
6352
6078
|
// `tmpl.stylesheets.push(someStylesheetFunction)`
|
|
6353
6079
|
function warnOnArrayMutation(stylesheets) {
|
|
6354
|
-
|
|
6355
|
-
|
|
6356
|
-
|
|
6357
|
-
|
|
6358
|
-
|
|
6359
|
-
|
|
6360
|
-
|
|
6361
|
-
|
|
6362
|
-
|
|
6363
|
-
|
|
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
|
+
}
|
|
6364
6090
|
}
|
|
6365
6091
|
// Warn if the user tries to mutate a stylesheet factory function, e.g.:
|
|
6366
6092
|
// `stylesheet.$scoped$ = true`
|
|
6367
6093
|
function warnOnStylesheetFunctionMutation(stylesheet) {
|
|
6368
|
-
|
|
6369
|
-
|
|
6370
|
-
|
|
6371
|
-
|
|
6372
|
-
|
|
6373
|
-
|
|
6374
|
-
|
|
6375
|
-
|
|
6376
|
-
|
|
6377
|
-
|
|
6378
|
-
|
|
6379
|
-
|
|
6380
|
-
|
|
6381
|
-
|
|
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
|
+
}
|
|
6382
6108
|
}
|
|
6383
6109
|
// Warn on either array or stylesheet (function) mutation, in a deeply-nested array
|
|
6384
6110
|
function trackStylesheetsMutation(stylesheets) {
|
|
6385
|
-
|
|
6386
|
-
|
|
6387
|
-
|
|
6388
|
-
|
|
6389
|
-
|
|
6390
|
-
|
|
6391
|
-
|
|
6111
|
+
traverseStylesheets(stylesheets, (subStylesheets) => {
|
|
6112
|
+
if (isArray$1(subStylesheets)) {
|
|
6113
|
+
warnOnArrayMutation(subStylesheets);
|
|
6114
|
+
}
|
|
6115
|
+
else {
|
|
6116
|
+
warnOnStylesheetFunctionMutation(subStylesheets);
|
|
6117
|
+
}
|
|
6118
|
+
});
|
|
6392
6119
|
}
|
|
6393
6120
|
// Deeply freeze the entire array (of arrays) of stylesheet factory functions
|
|
6394
6121
|
function deepFreeze(stylesheets) {
|
|
6395
|
-
|
|
6396
|
-
|
|
6397
|
-
|
|
6122
|
+
traverseStylesheets(stylesheets, (subStylesheets) => {
|
|
6123
|
+
freeze(subStylesheets);
|
|
6124
|
+
});
|
|
6398
6125
|
}
|
|
6399
6126
|
// Deep-traverse an array (of arrays) of stylesheet factory functions, and call the callback for every array/function
|
|
6400
6127
|
function traverseStylesheets(stylesheets, callback) {
|
|
6401
|
-
|
|
6402
|
-
|
|
6403
|
-
|
|
6404
|
-
|
|
6405
|
-
|
|
6406
|
-
|
|
6407
|
-
|
|
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
|
+
}
|
|
6408
6137
|
}
|
|
6409
|
-
}
|
|
6410
6138
|
}
|
|
6411
6139
|
function trackMutations(tmpl) {
|
|
6412
|
-
|
|
6413
|
-
|
|
6414
|
-
|
|
6415
|
-
|
|
6416
|
-
|
|
6417
|
-
|
|
6418
|
-
|
|
6419
|
-
|
|
6420
|
-
|
|
6421
|
-
|
|
6422
|
-
|
|
6423
|
-
|
|
6424
|
-
|
|
6425
|
-
|
|
6426
|
-
|
|
6427
|
-
|
|
6428
|
-
|
|
6429
|
-
|
|
6430
|
-
}
|
|
6431
|
-
const originalDescriptor = getOwnPropertyDescriptor$1(tmpl, 'stylesheetTokens');
|
|
6432
|
-
defineProperty(tmpl, 'stylesheetTokens', {
|
|
6433
|
-
enumerable: true,
|
|
6434
|
-
configurable: true,
|
|
6435
|
-
get: originalDescriptor.get,
|
|
6436
|
-
set(value) {
|
|
6437
|
-
reportTemplateViolation('stylesheetTokens');
|
|
6438
|
-
// Avoid logging/reporting twice (for both stylesheetToken and stylesheetTokens)
|
|
6439
|
-
mutationTrackingDisabled = true;
|
|
6440
|
-
originalDescriptor.set.call(this, value);
|
|
6441
|
-
mutationTrackingDisabled = false;
|
|
6140
|
+
if (!isUndefined$1(tmpl.stylesheets)) {
|
|
6141
|
+
trackStylesheetsMutation(tmpl.stylesheets);
|
|
6142
|
+
}
|
|
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
|
+
});
|
|
6442
6158
|
}
|
|
6443
|
-
|
|
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
|
+
});
|
|
6444
6172
|
}
|
|
6445
6173
|
function addLegacyStylesheetTokensShim(tmpl) {
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
-
|
|
6449
|
-
|
|
6450
|
-
|
|
6451
|
-
|
|
6452
|
-
|
|
6453
|
-
|
|
6454
|
-
|
|
6455
|
-
|
|
6456
|
-
|
|
6457
|
-
|
|
6458
|
-
|
|
6459
|
-
|
|
6460
|
-
|
|
6461
|
-
|
|
6462
|
-
|
|
6463
|
-
|
|
6464
|
-
|
|
6465
|
-
|
|
6466
|
-
|
|
6467
|
-
|
|
6468
|
-
|
|
6469
|
-
|
|
6470
|
-
}
|
|
6471
|
-
});
|
|
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
|
+
});
|
|
6472
6198
|
}
|
|
6473
6199
|
function freezeTemplate(tmpl) {
|
|
6474
|
-
|
|
6475
|
-
|
|
6476
|
-
|
|
6477
|
-
|
|
6478
|
-
|
|
6479
|
-
|
|
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
|
+
}
|
|
6480
6207
|
}
|
|
6481
|
-
|
|
6482
|
-
|
|
6483
|
-
|
|
6484
|
-
|
|
6485
|
-
|
|
6486
|
-
|
|
6487
|
-
|
|
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
|
+
}
|
|
6488
6216
|
}
|
|
6489
|
-
}
|
|
6490
6217
|
}
|
|
6491
|
-
/* version: 2.
|
|
6218
|
+
/* version: 2.37.1 */
|
|
6492
6219
|
|
|
6493
6220
|
/*
|
|
6494
6221
|
* Copyright (c) 2020, salesforce.com, inc.
|
|
@@ -6540,7 +6267,7 @@ function unsupportedMethod(name) {
|
|
|
6540
6267
|
throw new TypeError(`"${name}" is not supported in this environment`);
|
|
6541
6268
|
};
|
|
6542
6269
|
}
|
|
6543
|
-
function createElement(tagName, namespace) {
|
|
6270
|
+
function createElement$1(tagName, namespace) {
|
|
6544
6271
|
return {
|
|
6545
6272
|
[HostTypeKey]: HostNodeType.Element,
|
|
6546
6273
|
tagName,
|
|
@@ -6791,7 +6518,7 @@ const assertInstanceOfHTMLElement = noop;
|
|
|
6791
6518
|
const localRegistryRecord = new Map();
|
|
6792
6519
|
function createUpgradableElementConstructor(tagName) {
|
|
6793
6520
|
return function Ctor(upgradeCallback) {
|
|
6794
|
-
const elm = createElement(tagName);
|
|
6521
|
+
const elm = createElement$1(tagName);
|
|
6795
6522
|
if (isFunction$1(upgradeCallback)) {
|
|
6796
6523
|
upgradeCallback(elm); // nothing to do with the result for now
|
|
6797
6524
|
}
|
|
@@ -6818,7 +6545,7 @@ const renderer = {
|
|
|
6818
6545
|
remove,
|
|
6819
6546
|
cloneNode,
|
|
6820
6547
|
createFragment,
|
|
6821
|
-
createElement,
|
|
6548
|
+
createElement: createElement$1,
|
|
6822
6549
|
createText,
|
|
6823
6550
|
createComment,
|
|
6824
6551
|
createCustomElement,
|
|
@@ -6959,11 +6686,29 @@ function renderComponent(tagName, Ctor, props = {}) {
|
|
|
6959
6686
|
*/
|
|
6960
6687
|
freeze(LightningElement);
|
|
6961
6688
|
seal(LightningElement.prototype);
|
|
6962
|
-
|
|
6689
|
+
|
|
6690
|
+
/*
|
|
6691
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
6692
|
+
* All rights reserved.
|
|
6693
|
+
* SPDX-License-Identifier: MIT
|
|
6694
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6695
|
+
*/
|
|
6696
|
+
/**
|
|
6697
|
+
* This API is equivalent to the createElement function exposed by @lwc/engine-dom. It doesn't do anything on
|
|
6698
|
+
* the server side, however, you may import it.
|
|
6699
|
+
*
|
|
6700
|
+
* The whole point of defining this and exporting it is so that you can import it in isomorphic code without
|
|
6701
|
+
* an error being thrown by the import itself.
|
|
6702
|
+
*/
|
|
6703
|
+
function createElement() {
|
|
6704
|
+
throw new Error('createElement is not supported in @lwc/engine-server, only @lwc/engine-dom.');
|
|
6705
|
+
}
|
|
6706
|
+
/* version: 2.37.1 */
|
|
6963
6707
|
|
|
6964
6708
|
exports.LightningElement = LightningElement;
|
|
6965
6709
|
exports.api = api$1;
|
|
6966
6710
|
exports.createContextProvider = createContextProvider;
|
|
6711
|
+
exports.createElement = createElement;
|
|
6967
6712
|
exports.freezeTemplate = freezeTemplate;
|
|
6968
6713
|
exports.getComponentDef = getComponentDef;
|
|
6969
6714
|
exports.isComponentConstructor = isComponentConstructor;
|