lwc 2.32.1 → 2.33.0
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 +683 -560
- package/dist/engine-dom/iife/es2017/engine-dom.js +683 -560
- package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es2017/engine-dom_debug.js +593 -467
- package/dist/engine-dom/iife/es5/engine-dom.js +121 -95
- package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es5/engine-dom_debug.js +119 -92
- package/dist/engine-dom/umd/es2017/engine-dom.js +683 -560
- package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es2017/engine-dom_debug.js +593 -467
- package/dist/engine-dom/umd/es5/engine-dom.js +121 -95
- package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es5/engine-dom_debug.js +119 -92
- package/dist/engine-server/commonjs/es2017/engine-server.js +655 -474
- package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
- package/dist/engine-server/esm/es2017/engine-server.js +655 -474
- package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.min.js +2 -2
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +3 -3
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +7 -5
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow.min.js +2 -2
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +7 -5
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.min.js +2 -2
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +3 -3
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +7 -5
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow.min.js +2 -2
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +7 -5
- 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 +5 -3
- package/dist/wire-service/iife/es5/wire-service.min.js +1 -1
- package/dist/wire-service/iife/es5/wire-service_debug.js +5 -3
- 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 +5 -3
- package/dist/wire-service/umd/es5/wire-service.min.js +1 -1
- package/dist/wire-service/umd/es5/wire-service_debug.js +5 -3
- package/package.json +7 -7
|
@@ -118,6 +118,9 @@ function getPropertyDescriptor(o, p) {
|
|
|
118
118
|
* The above list of 46 aria attributes is consistent with the following resources:
|
|
119
119
|
* https://github.com/w3c/aria/pull/708/files#diff-eacf331f0ffc35d4b482f1d15a887d3bR11060
|
|
120
120
|
* https://wicg.github.io/aom/spec/aria-reflection.html
|
|
121
|
+
*
|
|
122
|
+
* NOTE: If you update this list, please update test files that implicitly reference this list!
|
|
123
|
+
* Searching the codebase for `aria-flowto` and `ariaFlowTo` should be good enough to find all usages.
|
|
121
124
|
*/
|
|
122
125
|
const AriaPropertyNames = [
|
|
123
126
|
'ariaActiveDescendant',
|
|
@@ -467,9 +470,9 @@ function htmlEscape(str, attrMode = false) {
|
|
|
467
470
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
468
471
|
*/
|
|
469
472
|
// Increment whenever the LWC template compiler changes
|
|
470
|
-
const LWC_VERSION = "2.
|
|
473
|
+
const LWC_VERSION = "2.33.0";
|
|
471
474
|
const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
|
|
472
|
-
/** version: 2.
|
|
475
|
+
/** version: 2.33.0 */
|
|
473
476
|
|
|
474
477
|
/*
|
|
475
478
|
* Copyright (c) 2020, salesforce.com, inc.
|
|
@@ -523,6 +526,7 @@ const features = {
|
|
|
523
526
|
DISABLE_LIGHT_DOM_UNSCOPED_CSS: null,
|
|
524
527
|
ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY: null,
|
|
525
528
|
ENABLE_FROZEN_TEMPLATE: null,
|
|
529
|
+
DISABLE_ARIA_REFLECTION_POLYFILL: null,
|
|
526
530
|
};
|
|
527
531
|
if (!_globalThis.lwcRuntimeFlags) {
|
|
528
532
|
Object.defineProperty(_globalThis, 'lwcRuntimeFlags', { value: create(null) });
|
|
@@ -576,7 +580,71 @@ function setFeatureFlagForTest(name, value) {
|
|
|
576
580
|
setFeatureFlag(name, value);
|
|
577
581
|
}
|
|
578
582
|
}
|
|
579
|
-
/** version: 2.
|
|
583
|
+
/** version: 2.33.0 */
|
|
584
|
+
|
|
585
|
+
/**
|
|
586
|
+
* Copyright (C) 2018 salesforce.com, inc.
|
|
587
|
+
*/
|
|
588
|
+
|
|
589
|
+
/*
|
|
590
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
591
|
+
* All rights reserved.
|
|
592
|
+
* SPDX-License-Identifier: MIT
|
|
593
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
594
|
+
*/
|
|
595
|
+
function detect(propName, prototype) {
|
|
596
|
+
return isUndefined$1(getOwnPropertyDescriptor$1(prototype, propName));
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
/*
|
|
600
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
601
|
+
* All rights reserved.
|
|
602
|
+
* SPDX-License-Identifier: MIT
|
|
603
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
604
|
+
*/
|
|
605
|
+
function createAriaPropertyPropertyDescriptor(attrName) {
|
|
606
|
+
// Note that we need to call this.{get,set,has,remove}Attribute rather than dereferencing
|
|
607
|
+
// from Element.prototype, because these methods are overridden in LightningElement.
|
|
608
|
+
return {
|
|
609
|
+
get() {
|
|
610
|
+
// reflect what's in the attribute
|
|
611
|
+
return this.hasAttribute(attrName) ? this.getAttribute(attrName) : null;
|
|
612
|
+
},
|
|
613
|
+
set(newValue) {
|
|
614
|
+
// reflect into the corresponding attribute
|
|
615
|
+
if (isNull(newValue)) {
|
|
616
|
+
this.removeAttribute(attrName);
|
|
617
|
+
}
|
|
618
|
+
else {
|
|
619
|
+
this.setAttribute(attrName, newValue);
|
|
620
|
+
}
|
|
621
|
+
},
|
|
622
|
+
configurable: true,
|
|
623
|
+
enumerable: true,
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
function patch$1(propName, prototype) {
|
|
627
|
+
const attrName = AriaPropNameToAttrNameMap[propName];
|
|
628
|
+
const descriptor = createAriaPropertyPropertyDescriptor(attrName);
|
|
629
|
+
defineProperty(prototype, propName, descriptor);
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
/*
|
|
633
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
634
|
+
* All rights reserved.
|
|
635
|
+
* SPDX-License-Identifier: MIT
|
|
636
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
637
|
+
*/
|
|
638
|
+
function applyAriaReflection(prototype = Element.prototype) {
|
|
639
|
+
const ElementPrototypeAriaPropertyNames = keys(AriaPropNameToAttrNameMap);
|
|
640
|
+
for (let i = 0, len = ElementPrototypeAriaPropertyNames.length; i < len; i += 1) {
|
|
641
|
+
const propName = ElementPrototypeAriaPropertyNames[i];
|
|
642
|
+
if (detect(propName, prototype)) {
|
|
643
|
+
patch$1(propName, prototype);
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
/** version: 2.33.0 */
|
|
580
648
|
|
|
581
649
|
/* proxy-compat-disable */
|
|
582
650
|
|
|
@@ -1833,45 +1901,50 @@ function getReactiveProxy(value) {
|
|
|
1833
1901
|
* for the Base Lightning Element, it also include the reactivity bit, so the standard property is reactive.
|
|
1834
1902
|
*/
|
|
1835
1903
|
function createBridgeToElementDescriptor(propName, descriptor) {
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1904
|
+
const {
|
|
1905
|
+
get,
|
|
1906
|
+
set,
|
|
1907
|
+
enumerable,
|
|
1908
|
+
configurable
|
|
1909
|
+
} = descriptor;
|
|
1910
|
+
if (!isFunction$1(get)) {
|
|
1911
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1912
|
+
assert.fail(`Detected invalid public property descriptor for HTMLElement.prototype.${propName} definition. Missing the standard getter.`);
|
|
1842
1913
|
}
|
|
1843
|
-
|
|
1914
|
+
throw new TypeError();
|
|
1915
|
+
}
|
|
1916
|
+
if (!isFunction$1(set)) {
|
|
1917
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1918
|
+
assert.fail(`Detected invalid public property descriptor for HTMLElement.prototype.${propName} definition. Missing the standard setter.`);
|
|
1919
|
+
}
|
|
1920
|
+
throw new TypeError();
|
|
1921
|
+
}
|
|
1922
|
+
return {
|
|
1923
|
+
enumerable,
|
|
1924
|
+
configurable,
|
|
1925
|
+
get() {
|
|
1926
|
+
const vm = getAssociatedVM(this);
|
|
1927
|
+
if (isBeingConstructed(vm)) {
|
|
1844
1928
|
if (process.env.NODE_ENV !== 'production') {
|
|
1845
|
-
|
|
1929
|
+
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);
|
|
1846
1930
|
}
|
|
1847
|
-
|
|
1931
|
+
return;
|
|
1932
|
+
}
|
|
1933
|
+
return get.call(vm.elm);
|
|
1934
|
+
},
|
|
1935
|
+
set(newValue) {
|
|
1936
|
+
const vm = getAssociatedVM(this);
|
|
1937
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1938
|
+
const vmBeingRendered = getVMBeingRendered();
|
|
1939
|
+
assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${propName}`);
|
|
1940
|
+
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}`);
|
|
1941
|
+
assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
|
|
1942
|
+
assert.invariant(!isObject(newValue) || isNull(newValue), `Invalid value "${newValue}" for "${propName}" of ${vm}. Value cannot be an object, must be a primitive value.`);
|
|
1943
|
+
}
|
|
1944
|
+
updateComponentValue(vm, propName, newValue);
|
|
1945
|
+
return set.call(vm.elm, newValue);
|
|
1848
1946
|
}
|
|
1849
|
-
|
|
1850
|
-
enumerable,
|
|
1851
|
-
configurable,
|
|
1852
|
-
get() {
|
|
1853
|
-
const vm = getAssociatedVM(this);
|
|
1854
|
-
if (isBeingConstructed(vm)) {
|
|
1855
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1856
|
-
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);
|
|
1857
|
-
}
|
|
1858
|
-
return;
|
|
1859
|
-
}
|
|
1860
|
-
return get.call(vm.elm);
|
|
1861
|
-
},
|
|
1862
|
-
set(newValue) {
|
|
1863
|
-
const vm = getAssociatedVM(this);
|
|
1864
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1865
|
-
const vmBeingRendered = getVMBeingRendered();
|
|
1866
|
-
assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${propName}`);
|
|
1867
|
-
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}`);
|
|
1868
|
-
assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
|
|
1869
|
-
assert.invariant(!isObject(newValue) || isNull(newValue), `Invalid value "${newValue}" for "${propName}" of ${vm}. Value cannot be an object, must be a primitive value.`);
|
|
1870
|
-
}
|
|
1871
|
-
updateComponentValue(vm, propName, newValue);
|
|
1872
|
-
return set.call(vm.elm, newValue);
|
|
1873
|
-
},
|
|
1874
|
-
};
|
|
1947
|
+
};
|
|
1875
1948
|
}
|
|
1876
1949
|
const EMPTY_REFS = freeze(create(null));
|
|
1877
1950
|
const refsCache = new WeakMap();
|
|
@@ -1881,344 +1954,443 @@ const refsCache = new WeakMap();
|
|
|
1881
1954
|
**/
|
|
1882
1955
|
// @ts-ignore
|
|
1883
1956
|
const LightningElement = function () {
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1957
|
+
// This should be as performant as possible, while any initialization should be done lazily
|
|
1958
|
+
if (isNull(vmBeingConstructed)) {
|
|
1959
|
+
// Thrown when doing something like `new LightningElement()` or
|
|
1960
|
+
// `class Foo extends LightningElement {}; new Foo()`
|
|
1961
|
+
throw new TypeError('Illegal constructor');
|
|
1962
|
+
}
|
|
1963
|
+
const vm = vmBeingConstructed;
|
|
1964
|
+
const {
|
|
1965
|
+
def,
|
|
1966
|
+
elm
|
|
1967
|
+
} = vm;
|
|
1968
|
+
const {
|
|
1969
|
+
bridge
|
|
1970
|
+
} = def;
|
|
1971
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1972
|
+
const {
|
|
1973
|
+
assertInstanceOfHTMLElement
|
|
1974
|
+
} = vm.renderer;
|
|
1975
|
+
assertInstanceOfHTMLElement(vm.elm, `Component creation requires a DOM element to be associated to ${vm}.`);
|
|
1976
|
+
}
|
|
1977
|
+
const component = this;
|
|
1978
|
+
setPrototypeOf(elm, bridge.prototype);
|
|
1979
|
+
vm.component = this;
|
|
1980
|
+
// Locker hooks assignment. When the LWC engine run with Locker, Locker intercepts all the new
|
|
1981
|
+
// component creation and passes hooks to instrument all the component interactions with the
|
|
1982
|
+
// engine. We are intentionally hiding this argument from the formal API of LightningElement
|
|
1983
|
+
// because we don't want folks to know about it just yet.
|
|
1984
|
+
if (arguments.length === 1) {
|
|
1985
|
+
const {
|
|
1986
|
+
callHook,
|
|
1987
|
+
setHook,
|
|
1988
|
+
getHook
|
|
1989
|
+
} = arguments[0];
|
|
1990
|
+
vm.callHook = callHook;
|
|
1991
|
+
vm.setHook = setHook;
|
|
1992
|
+
vm.getHook = getHook;
|
|
1993
|
+
}
|
|
1994
|
+
// Linking elm, shadow root and component with the VM.
|
|
1995
|
+
associateVM(component, vm);
|
|
1996
|
+
associateVM(elm, vm);
|
|
1997
|
+
if (vm.renderMode === 1 /* RenderMode.Shadow */) {
|
|
1998
|
+
vm.renderRoot = doAttachShadow(vm);
|
|
1999
|
+
} else {
|
|
2000
|
+
vm.renderRoot = elm;
|
|
2001
|
+
}
|
|
2002
|
+
// Adding extra guard rails in DEV mode.
|
|
2003
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2004
|
+
patchCustomElementWithRestrictions(elm);
|
|
2005
|
+
patchComponentWithRestrictions(component);
|
|
2006
|
+
}
|
|
2007
|
+
return this;
|
|
2008
|
+
};
|
|
2009
|
+
function doAttachShadow(vm) {
|
|
2010
|
+
const {
|
|
2011
|
+
elm,
|
|
2012
|
+
mode,
|
|
2013
|
+
shadowMode,
|
|
2014
|
+
def: {
|
|
2015
|
+
ctor
|
|
2016
|
+
},
|
|
2017
|
+
renderer: {
|
|
2018
|
+
attachShadow
|
|
2019
|
+
}
|
|
2020
|
+
} = vm;
|
|
2021
|
+
const shadowRoot = attachShadow(elm, {
|
|
2022
|
+
[KEY__SYNTHETIC_MODE]: shadowMode === 1 /* ShadowMode.Synthetic */,
|
|
2023
|
+
delegatesFocus: Boolean(ctor.delegatesFocus),
|
|
2024
|
+
mode
|
|
2025
|
+
});
|
|
2026
|
+
vm.shadowRoot = shadowRoot;
|
|
2027
|
+
associateVM(shadowRoot, vm);
|
|
2028
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2029
|
+
patchShadowRootWithRestrictions(shadowRoot);
|
|
2030
|
+
}
|
|
2031
|
+
return shadowRoot;
|
|
2032
|
+
}
|
|
2033
|
+
function warnIfInvokedDuringConstruction(vm, methodOrPropName) {
|
|
2034
|
+
if (isBeingConstructed(vm)) {
|
|
2035
|
+
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.`);
|
|
2036
|
+
}
|
|
2037
|
+
}
|
|
2038
|
+
// @ts-ignore
|
|
2039
|
+
LightningElement.prototype = {
|
|
2040
|
+
constructor: LightningElement,
|
|
2041
|
+
dispatchEvent(event) {
|
|
2042
|
+
const vm = getAssociatedVM(this);
|
|
2043
|
+
const {
|
|
2044
|
+
elm,
|
|
2045
|
+
renderer: {
|
|
2046
|
+
dispatchEvent
|
|
2047
|
+
}
|
|
2048
|
+
} = vm;
|
|
2049
|
+
return dispatchEvent(elm, event);
|
|
2050
|
+
},
|
|
2051
|
+
addEventListener(type, listener, options) {
|
|
2052
|
+
const vm = getAssociatedVM(this);
|
|
2053
|
+
const {
|
|
2054
|
+
elm,
|
|
2055
|
+
renderer: {
|
|
2056
|
+
addEventListener
|
|
2057
|
+
}
|
|
2058
|
+
} = vm;
|
|
1893
2059
|
if (process.env.NODE_ENV !== 'production') {
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
2060
|
+
const vmBeingRendered = getVMBeingRendered();
|
|
2061
|
+
assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm} by adding an event listener for "${type}".`);
|
|
2062
|
+
assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm} by adding an event listener for "${type}".`);
|
|
2063
|
+
assert.invariant(isFunction$1(listener), `Invalid second argument for this.addEventListener() in ${vm} for event "${type}". Expected an EventListener but received ${listener}.`);
|
|
2064
|
+
}
|
|
2065
|
+
const wrappedListener = getWrappedComponentsListener(vm, listener);
|
|
2066
|
+
addEventListener(elm, type, wrappedListener, options);
|
|
2067
|
+
},
|
|
2068
|
+
removeEventListener(type, listener, options) {
|
|
2069
|
+
const vm = getAssociatedVM(this);
|
|
2070
|
+
const {
|
|
2071
|
+
elm,
|
|
2072
|
+
renderer: {
|
|
2073
|
+
removeEventListener
|
|
2074
|
+
}
|
|
2075
|
+
} = vm;
|
|
2076
|
+
const wrappedListener = getWrappedComponentsListener(vm, listener);
|
|
2077
|
+
removeEventListener(elm, type, wrappedListener, options);
|
|
2078
|
+
},
|
|
2079
|
+
hasAttribute(name) {
|
|
2080
|
+
const vm = getAssociatedVM(this);
|
|
2081
|
+
const {
|
|
2082
|
+
elm,
|
|
2083
|
+
renderer: {
|
|
2084
|
+
getAttribute
|
|
2085
|
+
}
|
|
2086
|
+
} = vm;
|
|
2087
|
+
return !isNull(getAttribute(elm, name));
|
|
2088
|
+
},
|
|
2089
|
+
hasAttributeNS(namespace, name) {
|
|
2090
|
+
const vm = getAssociatedVM(this);
|
|
2091
|
+
const {
|
|
2092
|
+
elm,
|
|
2093
|
+
renderer: {
|
|
2094
|
+
getAttribute
|
|
2095
|
+
}
|
|
2096
|
+
} = vm;
|
|
2097
|
+
return !isNull(getAttribute(elm, name, namespace));
|
|
2098
|
+
},
|
|
2099
|
+
removeAttribute(name) {
|
|
2100
|
+
const vm = getAssociatedVM(this);
|
|
2101
|
+
const {
|
|
2102
|
+
elm,
|
|
2103
|
+
renderer: {
|
|
2104
|
+
removeAttribute
|
|
2105
|
+
}
|
|
2106
|
+
} = vm;
|
|
2107
|
+
unlockAttribute(elm, name);
|
|
2108
|
+
removeAttribute(elm, name);
|
|
2109
|
+
lockAttribute();
|
|
2110
|
+
},
|
|
2111
|
+
removeAttributeNS(namespace, name) {
|
|
2112
|
+
const {
|
|
2113
|
+
elm,
|
|
2114
|
+
renderer: {
|
|
2115
|
+
removeAttribute
|
|
2116
|
+
}
|
|
2117
|
+
} = getAssociatedVM(this);
|
|
2118
|
+
unlockAttribute(elm, name);
|
|
2119
|
+
removeAttribute(elm, name, namespace);
|
|
2120
|
+
lockAttribute();
|
|
2121
|
+
},
|
|
2122
|
+
getAttribute(name) {
|
|
2123
|
+
const vm = getAssociatedVM(this);
|
|
2124
|
+
const {
|
|
2125
|
+
elm
|
|
2126
|
+
} = vm;
|
|
2127
|
+
const {
|
|
2128
|
+
getAttribute
|
|
2129
|
+
} = vm.renderer;
|
|
2130
|
+
return getAttribute(elm, name);
|
|
2131
|
+
},
|
|
2132
|
+
getAttributeNS(namespace, name) {
|
|
2133
|
+
const vm = getAssociatedVM(this);
|
|
2134
|
+
const {
|
|
2135
|
+
elm
|
|
2136
|
+
} = vm;
|
|
2137
|
+
const {
|
|
2138
|
+
getAttribute
|
|
2139
|
+
} = vm.renderer;
|
|
2140
|
+
return getAttribute(elm, name, namespace);
|
|
2141
|
+
},
|
|
2142
|
+
setAttribute(name, value) {
|
|
2143
|
+
const vm = getAssociatedVM(this);
|
|
2144
|
+
const {
|
|
2145
|
+
elm,
|
|
2146
|
+
renderer: {
|
|
2147
|
+
setAttribute
|
|
2148
|
+
}
|
|
2149
|
+
} = vm;
|
|
2150
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2151
|
+
assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
|
|
2152
|
+
}
|
|
2153
|
+
unlockAttribute(elm, name);
|
|
2154
|
+
setAttribute(elm, name, value);
|
|
2155
|
+
lockAttribute();
|
|
2156
|
+
},
|
|
2157
|
+
setAttributeNS(namespace, name, value) {
|
|
2158
|
+
const vm = getAssociatedVM(this);
|
|
2159
|
+
const {
|
|
2160
|
+
elm,
|
|
2161
|
+
renderer: {
|
|
2162
|
+
setAttribute
|
|
2163
|
+
}
|
|
2164
|
+
} = vm;
|
|
2165
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2166
|
+
assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
|
|
2167
|
+
}
|
|
2168
|
+
unlockAttribute(elm, name);
|
|
2169
|
+
setAttribute(elm, name, value, namespace);
|
|
2170
|
+
lockAttribute();
|
|
2171
|
+
},
|
|
2172
|
+
getBoundingClientRect() {
|
|
2173
|
+
const vm = getAssociatedVM(this);
|
|
2174
|
+
const {
|
|
2175
|
+
elm,
|
|
2176
|
+
renderer: {
|
|
2177
|
+
getBoundingClientRect
|
|
2178
|
+
}
|
|
2179
|
+
} = vm;
|
|
2180
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2181
|
+
warnIfInvokedDuringConstruction(vm, 'getBoundingClientRect()');
|
|
1909
2182
|
}
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
2183
|
+
return getBoundingClientRect(elm);
|
|
2184
|
+
},
|
|
2185
|
+
get isConnected() {
|
|
2186
|
+
const vm = getAssociatedVM(this);
|
|
2187
|
+
const {
|
|
2188
|
+
elm,
|
|
2189
|
+
renderer: {
|
|
2190
|
+
isConnected
|
|
2191
|
+
}
|
|
2192
|
+
} = vm;
|
|
2193
|
+
return isConnected(elm);
|
|
2194
|
+
},
|
|
2195
|
+
get classList() {
|
|
2196
|
+
const vm = getAssociatedVM(this);
|
|
2197
|
+
const {
|
|
2198
|
+
elm,
|
|
2199
|
+
renderer: {
|
|
2200
|
+
getClassList
|
|
2201
|
+
}
|
|
2202
|
+
} = vm;
|
|
2203
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2204
|
+
// TODO [#1290]: this still fails in dev but works in production, eventually, we should
|
|
2205
|
+
// just throw in all modes
|
|
2206
|
+
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.`);
|
|
2207
|
+
}
|
|
2208
|
+
return getClassList(elm);
|
|
2209
|
+
},
|
|
2210
|
+
get template() {
|
|
2211
|
+
const vm = getAssociatedVM(this);
|
|
2212
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2213
|
+
if (vm.renderMode === 0 /* RenderMode.Light */) {
|
|
2214
|
+
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`.');
|
|
2215
|
+
}
|
|
1915
2216
|
}
|
|
1916
|
-
|
|
1917
|
-
|
|
2217
|
+
return vm.shadowRoot;
|
|
2218
|
+
},
|
|
2219
|
+
get refs() {
|
|
2220
|
+
const vm = getAssociatedVM(this);
|
|
2221
|
+
if (isUpdatingTemplate) {
|
|
2222
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2223
|
+
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().`);
|
|
2224
|
+
}
|
|
2225
|
+
// If the template is in the process of being updated, then we don't want to go through the normal
|
|
2226
|
+
// process of returning the refs and caching them, because the state of the refs is unstable.
|
|
2227
|
+
// This can happen if e.g. a template contains `<div class={foo}></div>` and `foo` is computed
|
|
2228
|
+
// based on `this.refs.bar`.
|
|
2229
|
+
return;
|
|
1918
2230
|
}
|
|
1919
|
-
// Adding extra guard rails in DEV mode.
|
|
1920
2231
|
if (process.env.NODE_ENV !== 'production') {
|
|
1921
|
-
|
|
1922
|
-
patchComponentWithRestrictions(component);
|
|
2232
|
+
warnIfInvokedDuringConstruction(vm, 'refs');
|
|
1923
2233
|
}
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
2234
|
+
const {
|
|
2235
|
+
refVNodes,
|
|
2236
|
+
hasRefVNodes,
|
|
2237
|
+
cmpTemplate
|
|
2238
|
+
} = vm;
|
|
2239
|
+
// If the `cmpTemplate` is null, that means that the template has not been rendered yet. Most likely this occurs
|
|
2240
|
+
// if `this.refs` is called during the `connectedCallback` phase. The DOM elements have not been rendered yet,
|
|
2241
|
+
// so log a warning. Note we also check `isBeingConstructed()` to avoid a double warning (due to
|
|
2242
|
+
// `warnIfInvokedDuringConstruction` above).
|
|
2243
|
+
if (process.env.NODE_ENV !== 'production' && isNull(cmpTemplate) && !isBeingConstructed(vm)) {
|
|
2244
|
+
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().`);
|
|
2245
|
+
}
|
|
2246
|
+
// For backwards compatibility with component written before template refs
|
|
2247
|
+
// were introduced, we return undefined if the template has no refs defined
|
|
2248
|
+
// anywhere. This fixes components that may want to add an expando called `refs`
|
|
2249
|
+
// and are checking if it exists with `if (this.refs)` before adding it.
|
|
2250
|
+
// Note it is not sufficient to just check if `refVNodes` is null or empty,
|
|
2251
|
+
// because a template may have `lwc:ref` defined within a falsy `if:true` block.
|
|
2252
|
+
if (!hasRefVNodes) {
|
|
2253
|
+
return;
|
|
2254
|
+
}
|
|
2255
|
+
// For templates that are using `lwc:ref`, if there are no refs currently available
|
|
2256
|
+
// (e.g. refs inside of a falsy `if:true` block), we return an empty object.
|
|
2257
|
+
if (isNull(refVNodes)) {
|
|
2258
|
+
return EMPTY_REFS;
|
|
2259
|
+
}
|
|
2260
|
+
// The refNodes can be cached based on the refVNodes, since the refVNodes
|
|
2261
|
+
// are recreated from scratch every time the template is rendered.
|
|
2262
|
+
// This happens with `vm.refVNodes = null` in `template.ts` in `@lwc/engine-core`.
|
|
2263
|
+
let refs = refsCache.get(refVNodes);
|
|
2264
|
+
if (isUndefined$1(refs)) {
|
|
2265
|
+
refs = create(null);
|
|
2266
|
+
for (const key of keys(refVNodes)) {
|
|
2267
|
+
refs[key] = refVNodes[key].elm;
|
|
2268
|
+
}
|
|
2269
|
+
freeze(refs);
|
|
2270
|
+
refsCache.set(refVNodes, refs);
|
|
2271
|
+
}
|
|
2272
|
+
return refs;
|
|
2273
|
+
},
|
|
2274
|
+
// For backwards compat, we allow component authors to set `refs` as an expando
|
|
2275
|
+
set refs(value) {
|
|
2276
|
+
defineProperty(this, 'refs', {
|
|
2277
|
+
configurable: true,
|
|
2278
|
+
enumerable: true,
|
|
2279
|
+
writable: true,
|
|
2280
|
+
value
|
|
1932
2281
|
});
|
|
1933
|
-
|
|
1934
|
-
|
|
2282
|
+
},
|
|
2283
|
+
get shadowRoot() {
|
|
2284
|
+
// From within the component instance, the shadowRoot is always reported as "closed".
|
|
2285
|
+
// Authors should rely on this.template instead.
|
|
2286
|
+
return null;
|
|
2287
|
+
},
|
|
2288
|
+
get children() {
|
|
2289
|
+
const vm = getAssociatedVM(this);
|
|
2290
|
+
const renderer = vm.renderer;
|
|
1935
2291
|
if (process.env.NODE_ENV !== 'production') {
|
|
1936
|
-
|
|
2292
|
+
warnIfInvokedDuringConstruction(vm, 'children');
|
|
1937
2293
|
}
|
|
1938
|
-
return
|
|
1939
|
-
}
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
2294
|
+
return renderer.getChildren(vm.elm);
|
|
2295
|
+
},
|
|
2296
|
+
get childNodes() {
|
|
2297
|
+
const vm = getAssociatedVM(this);
|
|
2298
|
+
const renderer = vm.renderer;
|
|
2299
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2300
|
+
warnIfInvokedDuringConstruction(vm, 'childNodes');
|
|
1943
2301
|
}
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
}
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
lockAttribute();
|
|
1987
|
-
},
|
|
1988
|
-
removeAttributeNS(namespace, name) {
|
|
1989
|
-
const { elm, renderer: { removeAttribute }, } = getAssociatedVM(this);
|
|
1990
|
-
unlockAttribute(elm, name);
|
|
1991
|
-
removeAttribute(elm, name, namespace);
|
|
1992
|
-
lockAttribute();
|
|
1993
|
-
},
|
|
1994
|
-
getAttribute(name) {
|
|
1995
|
-
const vm = getAssociatedVM(this);
|
|
1996
|
-
const { elm } = vm;
|
|
1997
|
-
const { getAttribute } = vm.renderer;
|
|
1998
|
-
return getAttribute(elm, name);
|
|
1999
|
-
},
|
|
2000
|
-
getAttributeNS(namespace, name) {
|
|
2001
|
-
const vm = getAssociatedVM(this);
|
|
2002
|
-
const { elm } = vm;
|
|
2003
|
-
const { getAttribute } = vm.renderer;
|
|
2004
|
-
return getAttribute(elm, name, namespace);
|
|
2005
|
-
},
|
|
2006
|
-
setAttribute(name, value) {
|
|
2007
|
-
const vm = getAssociatedVM(this);
|
|
2008
|
-
const { elm, renderer: { setAttribute }, } = vm;
|
|
2009
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2010
|
-
assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
|
|
2011
|
-
}
|
|
2012
|
-
unlockAttribute(elm, name);
|
|
2013
|
-
setAttribute(elm, name, value);
|
|
2014
|
-
lockAttribute();
|
|
2015
|
-
},
|
|
2016
|
-
setAttributeNS(namespace, name, value) {
|
|
2017
|
-
const vm = getAssociatedVM(this);
|
|
2018
|
-
const { elm, renderer: { setAttribute }, } = vm;
|
|
2019
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2020
|
-
assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
|
|
2021
|
-
}
|
|
2022
|
-
unlockAttribute(elm, name);
|
|
2023
|
-
setAttribute(elm, name, value, namespace);
|
|
2024
|
-
lockAttribute();
|
|
2025
|
-
},
|
|
2026
|
-
getBoundingClientRect() {
|
|
2027
|
-
const vm = getAssociatedVM(this);
|
|
2028
|
-
const { elm, renderer: { getBoundingClientRect }, } = vm;
|
|
2029
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2030
|
-
warnIfInvokedDuringConstruction(vm, 'getBoundingClientRect()');
|
|
2031
|
-
}
|
|
2032
|
-
return getBoundingClientRect(elm);
|
|
2033
|
-
},
|
|
2034
|
-
get isConnected() {
|
|
2035
|
-
const vm = getAssociatedVM(this);
|
|
2036
|
-
const { elm, renderer: { isConnected }, } = vm;
|
|
2037
|
-
return isConnected(elm);
|
|
2038
|
-
},
|
|
2039
|
-
get classList() {
|
|
2040
|
-
const vm = getAssociatedVM(this);
|
|
2041
|
-
const { elm, renderer: { getClassList }, } = vm;
|
|
2042
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2043
|
-
// TODO [#1290]: this still fails in dev but works in production, eventually, we should
|
|
2044
|
-
// just throw in all modes
|
|
2045
|
-
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.`);
|
|
2046
|
-
}
|
|
2047
|
-
return getClassList(elm);
|
|
2048
|
-
},
|
|
2049
|
-
get template() {
|
|
2050
|
-
const vm = getAssociatedVM(this);
|
|
2051
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2052
|
-
if (vm.renderMode === 0 /* RenderMode.Light */) {
|
|
2053
|
-
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`.');
|
|
2054
|
-
}
|
|
2055
|
-
}
|
|
2056
|
-
return vm.shadowRoot;
|
|
2057
|
-
},
|
|
2058
|
-
get refs() {
|
|
2059
|
-
const vm = getAssociatedVM(this);
|
|
2060
|
-
if (isUpdatingTemplate) {
|
|
2061
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2062
|
-
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().`);
|
|
2063
|
-
}
|
|
2064
|
-
// If the template is in the process of being updated, then we don't want to go through the normal
|
|
2065
|
-
// process of returning the refs and caching them, because the state of the refs is unstable.
|
|
2066
|
-
// This can happen if e.g. a template contains `<div class={foo}></div>` and `foo` is computed
|
|
2067
|
-
// based on `this.refs.bar`.
|
|
2068
|
-
return;
|
|
2069
|
-
}
|
|
2070
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2071
|
-
warnIfInvokedDuringConstruction(vm, 'refs');
|
|
2072
|
-
}
|
|
2073
|
-
const { refVNodes, hasRefVNodes, cmpTemplate } = vm;
|
|
2074
|
-
// If the `cmpTemplate` is null, that means that the template has not been rendered yet. Most likely this occurs
|
|
2075
|
-
// if `this.refs` is called during the `connectedCallback` phase. The DOM elements have not been rendered yet,
|
|
2076
|
-
// so log a warning. Note we also check `isBeingConstructed()` to avoid a double warning (due to
|
|
2077
|
-
// `warnIfInvokedDuringConstruction` above).
|
|
2078
|
-
if (process.env.NODE_ENV !== 'production' &&
|
|
2079
|
-
isNull(cmpTemplate) &&
|
|
2080
|
-
!isBeingConstructed(vm)) {
|
|
2081
|
-
logError(`this.refs is undefined for ${getComponentTag(vm)}. This is either because the attached template has no "lwc:ref" directive, or this.refs was ` +
|
|
2082
|
-
`invoked before renderedCallback(). Use this.refs only when the referenced HTML elements have ` +
|
|
2083
|
-
`been rendered to the DOM, such as within renderedCallback() or disconnectedCallback().`);
|
|
2084
|
-
}
|
|
2085
|
-
// For backwards compatibility with component written before template refs
|
|
2086
|
-
// were introduced, we return undefined if the template has no refs defined
|
|
2087
|
-
// anywhere. This fixes components that may want to add an expando called `refs`
|
|
2088
|
-
// and are checking if it exists with `if (this.refs)` before adding it.
|
|
2089
|
-
// Note it is not sufficient to just check if `refVNodes` is null or empty,
|
|
2090
|
-
// because a template may have `lwc:ref` defined within a falsy `if:true` block.
|
|
2091
|
-
if (!hasRefVNodes) {
|
|
2092
|
-
return;
|
|
2093
|
-
}
|
|
2094
|
-
// For templates that are using `lwc:ref`, if there are no refs currently available
|
|
2095
|
-
// (e.g. refs inside of a falsy `if:true` block), we return an empty object.
|
|
2096
|
-
if (isNull(refVNodes)) {
|
|
2097
|
-
return EMPTY_REFS;
|
|
2098
|
-
}
|
|
2099
|
-
// The refNodes can be cached based on the refVNodes, since the refVNodes
|
|
2100
|
-
// are recreated from scratch every time the template is rendered.
|
|
2101
|
-
// This happens with `vm.refVNodes = null` in `template.ts` in `@lwc/engine-core`.
|
|
2102
|
-
let refs = refsCache.get(refVNodes);
|
|
2103
|
-
if (isUndefined$1(refs)) {
|
|
2104
|
-
refs = create(null);
|
|
2105
|
-
for (const key of keys(refVNodes)) {
|
|
2106
|
-
refs[key] = refVNodes[key].elm;
|
|
2107
|
-
}
|
|
2108
|
-
freeze(refs);
|
|
2109
|
-
refsCache.set(refVNodes, refs);
|
|
2110
|
-
}
|
|
2111
|
-
return refs;
|
|
2112
|
-
},
|
|
2113
|
-
// For backwards compat, we allow component authors to set `refs` as an expando
|
|
2114
|
-
set refs(value) {
|
|
2115
|
-
defineProperty(this, 'refs', {
|
|
2116
|
-
configurable: true,
|
|
2117
|
-
enumerable: true,
|
|
2118
|
-
writable: true,
|
|
2119
|
-
value,
|
|
2120
|
-
});
|
|
2121
|
-
},
|
|
2122
|
-
get shadowRoot() {
|
|
2123
|
-
// From within the component instance, the shadowRoot is always reported as "closed".
|
|
2124
|
-
// Authors should rely on this.template instead.
|
|
2125
|
-
return null;
|
|
2126
|
-
},
|
|
2127
|
-
get children() {
|
|
2128
|
-
const vm = getAssociatedVM(this);
|
|
2129
|
-
const renderer = vm.renderer;
|
|
2130
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2131
|
-
warnIfInvokedDuringConstruction(vm, 'children');
|
|
2132
|
-
}
|
|
2133
|
-
return renderer.getChildren(vm.elm);
|
|
2134
|
-
},
|
|
2135
|
-
get childNodes() {
|
|
2136
|
-
const vm = getAssociatedVM(this);
|
|
2137
|
-
const renderer = vm.renderer;
|
|
2138
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2139
|
-
warnIfInvokedDuringConstruction(vm, 'childNodes');
|
|
2140
|
-
}
|
|
2141
|
-
return renderer.getChildNodes(vm.elm);
|
|
2142
|
-
},
|
|
2143
|
-
get firstChild() {
|
|
2144
|
-
const vm = getAssociatedVM(this);
|
|
2145
|
-
const renderer = vm.renderer;
|
|
2146
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2147
|
-
warnIfInvokedDuringConstruction(vm, 'firstChild');
|
|
2148
|
-
}
|
|
2149
|
-
return renderer.getFirstChild(vm.elm);
|
|
2150
|
-
},
|
|
2151
|
-
get firstElementChild() {
|
|
2152
|
-
const vm = getAssociatedVM(this);
|
|
2153
|
-
const renderer = vm.renderer;
|
|
2154
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2155
|
-
warnIfInvokedDuringConstruction(vm, 'firstElementChild');
|
|
2156
|
-
}
|
|
2157
|
-
return renderer.getFirstElementChild(vm.elm);
|
|
2158
|
-
},
|
|
2159
|
-
get lastChild() {
|
|
2160
|
-
const vm = getAssociatedVM(this);
|
|
2161
|
-
const renderer = vm.renderer;
|
|
2162
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2163
|
-
warnIfInvokedDuringConstruction(vm, 'lastChild');
|
|
2164
|
-
}
|
|
2165
|
-
return renderer.getLastChild(vm.elm);
|
|
2166
|
-
},
|
|
2167
|
-
get lastElementChild() {
|
|
2168
|
-
const vm = getAssociatedVM(this);
|
|
2169
|
-
const renderer = vm.renderer;
|
|
2170
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2171
|
-
warnIfInvokedDuringConstruction(vm, 'lastElementChild');
|
|
2172
|
-
}
|
|
2173
|
-
return renderer.getLastElementChild(vm.elm);
|
|
2174
|
-
},
|
|
2175
|
-
render() {
|
|
2176
|
-
const vm = getAssociatedVM(this);
|
|
2177
|
-
return vm.def.template;
|
|
2178
|
-
},
|
|
2179
|
-
toString() {
|
|
2180
|
-
const vm = getAssociatedVM(this);
|
|
2181
|
-
return `[object ${vm.def.name}]`;
|
|
2182
|
-
},
|
|
2302
|
+
return renderer.getChildNodes(vm.elm);
|
|
2303
|
+
},
|
|
2304
|
+
get firstChild() {
|
|
2305
|
+
const vm = getAssociatedVM(this);
|
|
2306
|
+
const renderer = vm.renderer;
|
|
2307
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2308
|
+
warnIfInvokedDuringConstruction(vm, 'firstChild');
|
|
2309
|
+
}
|
|
2310
|
+
return renderer.getFirstChild(vm.elm);
|
|
2311
|
+
},
|
|
2312
|
+
get firstElementChild() {
|
|
2313
|
+
const vm = getAssociatedVM(this);
|
|
2314
|
+
const renderer = vm.renderer;
|
|
2315
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2316
|
+
warnIfInvokedDuringConstruction(vm, 'firstElementChild');
|
|
2317
|
+
}
|
|
2318
|
+
return renderer.getFirstElementChild(vm.elm);
|
|
2319
|
+
},
|
|
2320
|
+
get lastChild() {
|
|
2321
|
+
const vm = getAssociatedVM(this);
|
|
2322
|
+
const renderer = vm.renderer;
|
|
2323
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2324
|
+
warnIfInvokedDuringConstruction(vm, 'lastChild');
|
|
2325
|
+
}
|
|
2326
|
+
return renderer.getLastChild(vm.elm);
|
|
2327
|
+
},
|
|
2328
|
+
get lastElementChild() {
|
|
2329
|
+
const vm = getAssociatedVM(this);
|
|
2330
|
+
const renderer = vm.renderer;
|
|
2331
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2332
|
+
warnIfInvokedDuringConstruction(vm, 'lastElementChild');
|
|
2333
|
+
}
|
|
2334
|
+
return renderer.getLastElementChild(vm.elm);
|
|
2335
|
+
},
|
|
2336
|
+
render() {
|
|
2337
|
+
const vm = getAssociatedVM(this);
|
|
2338
|
+
return vm.def.template;
|
|
2339
|
+
},
|
|
2340
|
+
toString() {
|
|
2341
|
+
const vm = getAssociatedVM(this);
|
|
2342
|
+
return `[object ${vm.def.name}]`;
|
|
2343
|
+
}
|
|
2183
2344
|
};
|
|
2184
2345
|
const queryAndChildGetterDescriptors = create(null);
|
|
2185
|
-
const queryMethods = [
|
|
2186
|
-
'getElementsByClassName',
|
|
2187
|
-
'getElementsByTagName',
|
|
2188
|
-
'querySelector',
|
|
2189
|
-
'querySelectorAll',
|
|
2190
|
-
];
|
|
2346
|
+
const queryMethods = ['getElementsByClassName', 'getElementsByTagName', 'querySelector', 'querySelectorAll'];
|
|
2191
2347
|
// Generic passthrough for query APIs on HTMLElement to the relevant Renderer APIs
|
|
2192
2348
|
for (const queryMethod of queryMethods) {
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
}
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2349
|
+
queryAndChildGetterDescriptors[queryMethod] = {
|
|
2350
|
+
value(arg) {
|
|
2351
|
+
const vm = getAssociatedVM(this);
|
|
2352
|
+
const {
|
|
2353
|
+
elm,
|
|
2354
|
+
renderer
|
|
2355
|
+
} = vm;
|
|
2356
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2357
|
+
warnIfInvokedDuringConstruction(vm, `${queryMethod}()`);
|
|
2358
|
+
}
|
|
2359
|
+
return renderer[queryMethod](elm, arg);
|
|
2360
|
+
},
|
|
2361
|
+
configurable: true,
|
|
2362
|
+
enumerable: true,
|
|
2363
|
+
writable: true
|
|
2364
|
+
};
|
|
2206
2365
|
}
|
|
2207
2366
|
defineProperties(LightningElement.prototype, queryAndChildGetterDescriptors);
|
|
2208
2367
|
const lightningBasedDescriptors = create(null);
|
|
2209
2368
|
for (const propName in HTMLElementOriginalDescriptors) {
|
|
2210
|
-
|
|
2369
|
+
lightningBasedDescriptors[propName] = createBridgeToElementDescriptor(propName, HTMLElementOriginalDescriptors[propName]);
|
|
2211
2370
|
}
|
|
2212
2371
|
defineProperties(LightningElement.prototype, lightningBasedDescriptors);
|
|
2372
|
+
function applyAriaReflectionToLightningElement() {
|
|
2373
|
+
// If ARIA reflection is not applied globally to Element.prototype, or if we are running server-side,
|
|
2374
|
+
// apply it to LightningElement.prototype.
|
|
2375
|
+
// This allows `this.aria*` property accessors to work from inside a component, and to reflect `aria-*` attrs.
|
|
2376
|
+
applyAriaReflection(LightningElement.prototype);
|
|
2377
|
+
}
|
|
2378
|
+
// The reason for this odd if/else branching is limitations in @lwc/features:
|
|
2379
|
+
// https://github.com/salesforce/lwc/blob/master/packages/%40lwc/features/README.md#only-works-with-if-statements
|
|
2380
|
+
if (lwcRuntimeFlags.DISABLE_ARIA_REFLECTION_POLYFILL) {
|
|
2381
|
+
applyAriaReflectionToLightningElement();
|
|
2382
|
+
} else {
|
|
2383
|
+
applyAriaReflectionToLightningElement();
|
|
2384
|
+
}
|
|
2213
2385
|
defineProperty(LightningElement, 'CustomElementConstructor', {
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2386
|
+
get() {
|
|
2387
|
+
// If required, a runtime-specific implementation must be defined.
|
|
2388
|
+
throw new ReferenceError('The current runtime does not support CustomElementConstructor.');
|
|
2389
|
+
},
|
|
2390
|
+
configurable: true
|
|
2219
2391
|
});
|
|
2220
2392
|
if (process.env.NODE_ENV !== 'production') {
|
|
2221
|
-
|
|
2393
|
+
patchLightningElementPrototypeWithRestrictions(LightningElement.prototype);
|
|
2222
2394
|
}
|
|
2223
2395
|
|
|
2224
2396
|
function createObservedFieldPropertyDescriptor(key) {
|
|
@@ -2673,136 +2845,145 @@ function sanitizeAttribute(tagName, namespaceUri, attrName, attrValue) {
|
|
|
2673
2845
|
const cachedGetterByKey = create(null);
|
|
2674
2846
|
const cachedSetterByKey = create(null);
|
|
2675
2847
|
function createGetter(key) {
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2848
|
+
let fn = cachedGetterByKey[key];
|
|
2849
|
+
if (isUndefined$1(fn)) {
|
|
2850
|
+
fn = cachedGetterByKey[key] = function () {
|
|
2851
|
+
const vm = getAssociatedVM(this);
|
|
2852
|
+
const {
|
|
2853
|
+
getHook
|
|
2854
|
+
} = vm;
|
|
2855
|
+
return getHook(vm.component, key);
|
|
2856
|
+
};
|
|
2857
|
+
}
|
|
2858
|
+
return fn;
|
|
2685
2859
|
}
|
|
2686
2860
|
function createSetter(key) {
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2861
|
+
let fn = cachedSetterByKey[key];
|
|
2862
|
+
if (isUndefined$1(fn)) {
|
|
2863
|
+
fn = cachedSetterByKey[key] = function (newValue) {
|
|
2864
|
+
const vm = getAssociatedVM(this);
|
|
2865
|
+
const {
|
|
2866
|
+
setHook
|
|
2867
|
+
} = vm;
|
|
2868
|
+
newValue = getReadOnlyProxy(newValue);
|
|
2869
|
+
setHook(vm.component, key, newValue);
|
|
2870
|
+
};
|
|
2871
|
+
}
|
|
2872
|
+
return fn;
|
|
2697
2873
|
}
|
|
2698
2874
|
function createMethodCaller(methodName) {
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
};
|
|
2875
|
+
return function () {
|
|
2876
|
+
const vm = getAssociatedVM(this);
|
|
2877
|
+
const {
|
|
2878
|
+
callHook,
|
|
2879
|
+
component
|
|
2880
|
+
} = vm;
|
|
2881
|
+
const fn = component[methodName];
|
|
2882
|
+
return callHook(vm.component, fn, ArraySlice.call(arguments));
|
|
2883
|
+
};
|
|
2705
2884
|
}
|
|
2706
2885
|
function createAttributeChangedCallback(attributeToPropMap, superAttributeChangedCallback) {
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
}
|
|
2712
|
-
const propName = attributeToPropMap[attrName];
|
|
2713
|
-
if (isUndefined$1(propName)) {
|
|
2714
|
-
if (!isUndefined$1(superAttributeChangedCallback)) {
|
|
2715
|
-
// delegate unknown attributes to the super.
|
|
2716
|
-
// Typescript does not like it when you treat the `arguments` object as an array
|
|
2717
|
-
// @ts-ignore type-mismatch
|
|
2718
|
-
superAttributeChangedCallback.apply(this, arguments);
|
|
2719
|
-
}
|
|
2720
|
-
return;
|
|
2721
|
-
}
|
|
2722
|
-
if (!isAttributeLocked(this, attrName)) {
|
|
2723
|
-
// Ignore changes triggered by the engine itself during:
|
|
2724
|
-
// * diffing when public props are attempting to reflect to the DOM
|
|
2725
|
-
// * component via `this.setAttribute()`, should never update the prop
|
|
2726
|
-
// Both cases, the setAttribute call is always wrapped by the unlocking of the
|
|
2727
|
-
// attribute to be changed
|
|
2728
|
-
return;
|
|
2729
|
-
}
|
|
2730
|
-
// Reflect attribute change to the corresponding property when changed from outside.
|
|
2731
|
-
this[propName] = newValue;
|
|
2732
|
-
};
|
|
2733
|
-
}
|
|
2734
|
-
function HTMLBridgeElementFactory(SuperClass, props, methods) {
|
|
2735
|
-
let HTMLBridgeElement;
|
|
2736
|
-
/**
|
|
2737
|
-
* Modern browsers will have all Native Constructors as regular Classes
|
|
2738
|
-
* and must be instantiated with the new keyword. In older browsers,
|
|
2739
|
-
* specifically IE11, those are objects with a prototype property defined,
|
|
2740
|
-
* since they are not supposed to be extended or instantiated with the
|
|
2741
|
-
* new keyword. This forking logic supports both cases, specifically because
|
|
2742
|
-
* wc.ts relies on the construction path of the bridges to create new
|
|
2743
|
-
* fully qualifying web components.
|
|
2744
|
-
*/
|
|
2745
|
-
if (isFunction$1(SuperClass)) {
|
|
2746
|
-
HTMLBridgeElement = class extends SuperClass {
|
|
2747
|
-
};
|
|
2748
|
-
}
|
|
2749
|
-
else {
|
|
2750
|
-
HTMLBridgeElement = function () {
|
|
2751
|
-
// Bridge classes are not supposed to be instantiated directly in
|
|
2752
|
-
// browsers that do not support web components.
|
|
2753
|
-
throw new TypeError('Illegal constructor');
|
|
2754
|
-
};
|
|
2755
|
-
// prototype inheritance dance
|
|
2756
|
-
setPrototypeOf(HTMLBridgeElement, SuperClass);
|
|
2757
|
-
setPrototypeOf(HTMLBridgeElement.prototype, SuperClass.prototype);
|
|
2758
|
-
defineProperty(HTMLBridgeElement.prototype, 'constructor', {
|
|
2759
|
-
writable: true,
|
|
2760
|
-
configurable: true,
|
|
2761
|
-
value: HTMLBridgeElement,
|
|
2762
|
-
});
|
|
2886
|
+
return function attributeChangedCallback(attrName, oldValue, newValue) {
|
|
2887
|
+
if (oldValue === newValue) {
|
|
2888
|
+
// Ignore same values.
|
|
2889
|
+
return;
|
|
2763
2890
|
}
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
attributeToPropMap[htmlPropertyToAttribute(propName)] = propName;
|
|
2774
|
-
descriptors[propName] = {
|
|
2775
|
-
get: createGetter(propName),
|
|
2776
|
-
set: createSetter(propName),
|
|
2777
|
-
enumerable: true,
|
|
2778
|
-
configurable: true,
|
|
2779
|
-
};
|
|
2891
|
+
const propName = attributeToPropMap[attrName];
|
|
2892
|
+
if (isUndefined$1(propName)) {
|
|
2893
|
+
if (!isUndefined$1(superAttributeChangedCallback)) {
|
|
2894
|
+
// delegate unknown attributes to the super.
|
|
2895
|
+
// Typescript does not like it when you treat the `arguments` object as an array
|
|
2896
|
+
// @ts-ignore type-mismatch
|
|
2897
|
+
superAttributeChangedCallback.apply(this, arguments);
|
|
2898
|
+
}
|
|
2899
|
+
return;
|
|
2780
2900
|
}
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
};
|
|
2901
|
+
if (!isAttributeLocked(this, attrName)) {
|
|
2902
|
+
// Ignore changes triggered by the engine itself during:
|
|
2903
|
+
// * diffing when public props are attempting to reflect to the DOM
|
|
2904
|
+
// * component via `this.setAttribute()`, should never update the prop
|
|
2905
|
+
// Both cases, the setAttribute call is always wrapped by the unlocking of the
|
|
2906
|
+
// attribute to be changed
|
|
2907
|
+
return;
|
|
2789
2908
|
}
|
|
2790
|
-
//
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2909
|
+
// Reflect attribute change to the corresponding property when changed from outside.
|
|
2910
|
+
this[propName] = newValue;
|
|
2911
|
+
};
|
|
2912
|
+
}
|
|
2913
|
+
function HTMLBridgeElementFactory(SuperClass, props, methods) {
|
|
2914
|
+
let HTMLBridgeElement;
|
|
2915
|
+
/**
|
|
2916
|
+
* Modern browsers will have all Native Constructors as regular Classes
|
|
2917
|
+
* and must be instantiated with the new keyword. In older browsers,
|
|
2918
|
+
* specifically IE11, those are objects with a prototype property defined,
|
|
2919
|
+
* since they are not supposed to be extended or instantiated with the
|
|
2920
|
+
* new keyword. This forking logic supports both cases, specifically because
|
|
2921
|
+
* wc.ts relies on the construction path of the bridges to create new
|
|
2922
|
+
* fully qualifying web components.
|
|
2923
|
+
*/
|
|
2924
|
+
if (isFunction$1(SuperClass)) {
|
|
2925
|
+
HTMLBridgeElement = class extends SuperClass {};
|
|
2926
|
+
} else {
|
|
2927
|
+
HTMLBridgeElement = function () {
|
|
2928
|
+
// Bridge classes are not supposed to be instantiated directly in
|
|
2929
|
+
// browsers that do not support web components.
|
|
2930
|
+
throw new TypeError('Illegal constructor');
|
|
2796
2931
|
};
|
|
2797
|
-
//
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2932
|
+
// prototype inheritance dance
|
|
2933
|
+
setPrototypeOf(HTMLBridgeElement, SuperClass);
|
|
2934
|
+
setPrototypeOf(HTMLBridgeElement.prototype, SuperClass.prototype);
|
|
2935
|
+
defineProperty(HTMLBridgeElement.prototype, 'constructor', {
|
|
2936
|
+
writable: true,
|
|
2937
|
+
configurable: true,
|
|
2938
|
+
value: HTMLBridgeElement
|
|
2803
2939
|
});
|
|
2804
|
-
|
|
2805
|
-
|
|
2940
|
+
}
|
|
2941
|
+
// generating the hash table for attributes to avoid duplicate fields and facilitate validation
|
|
2942
|
+
// and false positives in case of inheritance.
|
|
2943
|
+
const attributeToPropMap = create(null);
|
|
2944
|
+
const {
|
|
2945
|
+
attributeChangedCallback: superAttributeChangedCallback
|
|
2946
|
+
} = SuperClass.prototype;
|
|
2947
|
+
const {
|
|
2948
|
+
observedAttributes: superObservedAttributes = []
|
|
2949
|
+
} = SuperClass;
|
|
2950
|
+
const descriptors = create(null);
|
|
2951
|
+
// expose getters and setters for each public props on the new Element Bridge
|
|
2952
|
+
for (let i = 0, len = props.length; i < len; i += 1) {
|
|
2953
|
+
const propName = props[i];
|
|
2954
|
+
attributeToPropMap[htmlPropertyToAttribute(propName)] = propName;
|
|
2955
|
+
descriptors[propName] = {
|
|
2956
|
+
get: createGetter(propName),
|
|
2957
|
+
set: createSetter(propName),
|
|
2958
|
+
enumerable: true,
|
|
2959
|
+
configurable: true
|
|
2960
|
+
};
|
|
2961
|
+
}
|
|
2962
|
+
// expose public methods as props on the new Element Bridge
|
|
2963
|
+
for (let i = 0, len = methods.length; i < len; i += 1) {
|
|
2964
|
+
const methodName = methods[i];
|
|
2965
|
+
descriptors[methodName] = {
|
|
2966
|
+
value: createMethodCaller(methodName),
|
|
2967
|
+
writable: true,
|
|
2968
|
+
configurable: true
|
|
2969
|
+
};
|
|
2970
|
+
}
|
|
2971
|
+
// creating a new attributeChangedCallback per bridge because they are bound to the corresponding
|
|
2972
|
+
// map of attributes to props. We do this after all other props and methods to avoid the possibility
|
|
2973
|
+
// of getting overrule by a class declaration in user-land, and we make it non-writable, non-configurable
|
|
2974
|
+
// to preserve this definition.
|
|
2975
|
+
descriptors.attributeChangedCallback = {
|
|
2976
|
+
value: createAttributeChangedCallback(attributeToPropMap, superAttributeChangedCallback)
|
|
2977
|
+
};
|
|
2978
|
+
// Specify attributes for which we want to reflect changes back to their corresponding
|
|
2979
|
+
// properties via attributeChangedCallback.
|
|
2980
|
+
defineProperty(HTMLBridgeElement, 'observedAttributes', {
|
|
2981
|
+
get() {
|
|
2982
|
+
return [...superObservedAttributes, ...keys(attributeToPropMap)];
|
|
2983
|
+
}
|
|
2984
|
+
});
|
|
2985
|
+
defineProperties(HTMLBridgeElement.prototype, descriptors);
|
|
2986
|
+
return HTMLBridgeElement;
|
|
2806
2987
|
}
|
|
2807
2988
|
const BaseBridgeElement = HTMLBridgeElementFactory(HTMLElementConstructor, getOwnPropertyNames$1(HTMLElementOriginalDescriptors), []);
|
|
2808
2989
|
freeze(BaseBridgeElement);
|
|
@@ -6196,7 +6377,7 @@ function freezeTemplate(tmpl) {
|
|
|
6196
6377
|
}
|
|
6197
6378
|
}
|
|
6198
6379
|
}
|
|
6199
|
-
/* version: 2.
|
|
6380
|
+
/* version: 2.33.0 */
|
|
6200
6381
|
|
|
6201
6382
|
/*
|
|
6202
6383
|
* Copyright (c) 2020, salesforce.com, inc.
|
|
@@ -6667,6 +6848,6 @@ function renderComponent(tagName, Ctor, props = {}) {
|
|
|
6667
6848
|
*/
|
|
6668
6849
|
freeze(LightningElement);
|
|
6669
6850
|
seal(LightningElement.prototype);
|
|
6670
|
-
/* version: 2.
|
|
6851
|
+
/* version: 2.33.0 */
|
|
6671
6852
|
|
|
6672
6853
|
export { LightningElement, api$1 as api, createContextProvider, freezeTemplate, getComponentDef, isComponentConstructor, parseFragment, parseFragment as parseSVGFragment, readonly, register, registerComponent, registerDecorators, registerTemplate, renderComponent, renderer, sanitizeAttribute, setFeatureFlag, setFeatureFlagForTest, setHooks, track, unwrap, wire };
|