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