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
@@ -121,6 +121,9 @@ var LWC = (function (exports) {
121
121
  * The above list of 46 aria attributes is consistent with the following resources:
122
122
  * https://github.com/w3c/aria/pull/708/files#diff-eacf331f0ffc35d4b482f1d15a887d3bR11060
123
123
  * https://wicg.github.io/aom/spec/aria-reflection.html
124
+ *
125
+ * NOTE: If you update this list, please update test files that implicitly reference this list!
126
+ * Searching the codebase for `aria-flowto` and `ariaFlowTo` should be good enough to find all usages.
124
127
  */
125
128
  const AriaPropertyNames = [
126
129
  'ariaActiveDescendant',
@@ -344,91 +347,9 @@ var LWC = (function (exports) {
344
347
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
345
348
  */
346
349
  // Increment whenever the LWC template compiler changes
347
- const LWC_VERSION = "2.32.1";
350
+ const LWC_VERSION = "2.33.0";
348
351
  const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
349
- /** version: 2.32.1 */
350
-
351
- /**
352
- * Copyright (C) 2018 salesforce.com, inc.
353
- */
354
-
355
- /*
356
- * Copyright (c) 2018, salesforce.com, inc.
357
- * All rights reserved.
358
- * SPDX-License-Identifier: MIT
359
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
360
- */
361
- function detect(propName) {
362
- return getOwnPropertyDescriptor$1(Element.prototype, propName) === undefined;
363
- }
364
-
365
- /*
366
- * Copyright (c) 2018, salesforce.com, inc.
367
- * All rights reserved.
368
- * SPDX-License-Identifier: MIT
369
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
370
- */
371
- const nodeToAriaPropertyValuesMap = new WeakMap();
372
- function getAriaPropertyMap(elm) {
373
- let map = nodeToAriaPropertyValuesMap.get(elm);
374
- if (map === undefined) {
375
- map = {};
376
- nodeToAriaPropertyValuesMap.set(elm, map);
377
- }
378
- return map;
379
- }
380
- function getNormalizedAriaPropertyValue(value) {
381
- return value == null ? null : String(value);
382
- }
383
- function createAriaPropertyPropertyDescriptor(propName, attrName) {
384
- return {
385
- get() {
386
- const map = getAriaPropertyMap(this);
387
- if (hasOwnProperty$1.call(map, propName)) {
388
- return map[propName];
389
- }
390
- // otherwise just reflect what's in the attribute
391
- return this.hasAttribute(attrName) ? this.getAttribute(attrName) : null;
392
- },
393
- set(newValue) {
394
- const normalizedValue = getNormalizedAriaPropertyValue(newValue);
395
- const map = getAriaPropertyMap(this);
396
- map[propName] = normalizedValue;
397
- // reflect into the corresponding attribute
398
- if (newValue === null) {
399
- this.removeAttribute(attrName);
400
- }
401
- else {
402
- this.setAttribute(attrName, newValue);
403
- }
404
- },
405
- configurable: true,
406
- enumerable: true,
407
- };
408
- }
409
- function patch$1(propName) {
410
- // Typescript is inferring the wrong function type for this particular
411
- // overloaded method: https://github.com/Microsoft/TypeScript/issues/27972
412
- // @ts-ignore type-mismatch
413
- const attrName = AriaPropNameToAttrNameMap[propName];
414
- const descriptor = createAriaPropertyPropertyDescriptor(propName, attrName);
415
- Object.defineProperty(Element.prototype, propName, descriptor);
416
- }
417
-
418
- /*
419
- * Copyright (c) 2018, salesforce.com, inc.
420
- * All rights reserved.
421
- * SPDX-License-Identifier: MIT
422
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
423
- */
424
- const ElementPrototypeAriaPropertyNames = keys(AriaPropNameToAttrNameMap);
425
- for (let i = 0, len = ElementPrototypeAriaPropertyNames.length; i < len; i += 1) {
426
- const propName = ElementPrototypeAriaPropertyNames[i];
427
- if (detect(propName)) {
428
- patch$1(propName);
429
- }
430
- }
431
- /** version: 2.32.1 */
352
+ /** version: 2.33.0 */
432
353
 
433
354
  /**
434
355
  * Copyright (C) 2018 salesforce.com, inc.
@@ -450,6 +371,7 @@ var LWC = (function (exports) {
450
371
  DISABLE_LIGHT_DOM_UNSCOPED_CSS: null,
451
372
  ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY: null,
452
373
  ENABLE_FROZEN_TEMPLATE: null,
374
+ DISABLE_ARIA_REFLECTION_POLYFILL: null,
453
375
  };
454
376
  if (!_globalThis.lwcRuntimeFlags) {
455
377
  Object.defineProperty(_globalThis, 'lwcRuntimeFlags', { value: create(null) });
@@ -503,7 +425,83 @@ var LWC = (function (exports) {
503
425
  setFeatureFlag(name, value);
504
426
  }
505
427
  }
506
- /** version: 2.32.1 */
428
+ /** version: 2.33.0 */
429
+
430
+ /**
431
+ * Copyright (C) 2018 salesforce.com, inc.
432
+ */
433
+
434
+ /*
435
+ * Copyright (c) 2018, salesforce.com, inc.
436
+ * All rights reserved.
437
+ * SPDX-License-Identifier: MIT
438
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
439
+ */
440
+ function detect(propName, prototype) {
441
+ return isUndefined$1(getOwnPropertyDescriptor$1(prototype, propName));
442
+ }
443
+
444
+ /*
445
+ * Copyright (c) 2018, salesforce.com, inc.
446
+ * All rights reserved.
447
+ * SPDX-License-Identifier: MIT
448
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
449
+ */
450
+ function createAriaPropertyPropertyDescriptor(attrName) {
451
+ // Note that we need to call this.{get,set,has,remove}Attribute rather than dereferencing
452
+ // from Element.prototype, because these methods are overridden in LightningElement.
453
+ return {
454
+ get() {
455
+ // reflect what's in the attribute
456
+ return this.hasAttribute(attrName) ? this.getAttribute(attrName) : null;
457
+ },
458
+ set(newValue) {
459
+ // reflect into the corresponding attribute
460
+ if (isNull(newValue)) {
461
+ this.removeAttribute(attrName);
462
+ }
463
+ else {
464
+ this.setAttribute(attrName, newValue);
465
+ }
466
+ },
467
+ configurable: true,
468
+ enumerable: true,
469
+ };
470
+ }
471
+ function patch$1(propName, prototype) {
472
+ const attrName = AriaPropNameToAttrNameMap[propName];
473
+ const descriptor = createAriaPropertyPropertyDescriptor(attrName);
474
+ defineProperty(prototype, propName, descriptor);
475
+ }
476
+
477
+ /*
478
+ * Copyright (c) 2018, salesforce.com, inc.
479
+ * All rights reserved.
480
+ * SPDX-License-Identifier: MIT
481
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
482
+ */
483
+ function applyAriaReflection(prototype = Element.prototype) {
484
+ const ElementPrototypeAriaPropertyNames = keys(AriaPropNameToAttrNameMap);
485
+ for (let i = 0, len = ElementPrototypeAriaPropertyNames.length; i < len; i += 1) {
486
+ const propName = ElementPrototypeAriaPropertyNames[i];
487
+ if (detect(propName, prototype)) {
488
+ patch$1(propName, prototype);
489
+ }
490
+ }
491
+ }
492
+ /** version: 2.33.0 */
493
+
494
+ /*
495
+ * Copyright (c) 2018, salesforce.com, inc.
496
+ * All rights reserved.
497
+ * SPDX-License-Identifier: MIT
498
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
499
+ */
500
+ if (!lwcRuntimeFlags.DISABLE_ARIA_REFLECTION_POLYFILL) {
501
+ // If DISABLE_ARIA_REFLECTION_POLYFILL is false, then we need to apply the ARIA reflection polyfill globally,
502
+ // i.e. to the global Element.prototype
503
+ applyAriaReflection();
504
+ }
507
505
 
508
506
  /*
509
507
  * Copyright (c) 2018, salesforce.com, inc.
@@ -1922,46 +1920,51 @@ var LWC = (function (exports) {
1922
1920
  * for the Base Lightning Element, it also include the reactivity bit, so the standard property is reactive.
1923
1921
  */
1924
1922
  function createBridgeToElementDescriptor(propName, descriptor) {
1925
- const { get, set, enumerable, configurable } = descriptor;
1926
- if (!isFunction$1(get)) {
1927
- if (process.env.NODE_ENV !== 'production') {
1928
- assert.fail(`Detected invalid public property descriptor for HTMLElement.prototype.${propName} definition. Missing the standard getter.`);
1929
- }
1930
- throw new TypeError();
1923
+ const {
1924
+ get,
1925
+ set,
1926
+ enumerable,
1927
+ configurable
1928
+ } = descriptor;
1929
+ if (!isFunction$1(get)) {
1930
+ if (process.env.NODE_ENV !== 'production') {
1931
+ assert.fail(`Detected invalid public property descriptor for HTMLElement.prototype.${propName} definition. Missing the standard getter.`);
1932
+ }
1933
+ throw new TypeError();
1934
+ }
1935
+ if (!isFunction$1(set)) {
1936
+ if (process.env.NODE_ENV !== 'production') {
1937
+ assert.fail(`Detected invalid public property descriptor for HTMLElement.prototype.${propName} definition. Missing the standard setter.`);
1931
1938
  }
1932
- if (!isFunction$1(set)) {
1939
+ throw new TypeError();
1940
+ }
1941
+ return {
1942
+ enumerable,
1943
+ configurable,
1944
+ get() {
1945
+ const vm = getAssociatedVM(this);
1946
+ if (isBeingConstructed(vm)) {
1933
1947
  if (process.env.NODE_ENV !== 'production') {
1934
- assert.fail(`Detected invalid public property descriptor for HTMLElement.prototype.${propName} definition. Missing the standard setter.`);
1948
+ 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);
1935
1949
  }
1936
- throw new TypeError();
1950
+ return;
1951
+ }
1952
+ componentValueObserved(vm, propName);
1953
+ return get.call(vm.elm);
1954
+ },
1955
+ set(newValue) {
1956
+ const vm = getAssociatedVM(this);
1957
+ if (process.env.NODE_ENV !== 'production') {
1958
+ const vmBeingRendered = getVMBeingRendered();
1959
+ assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${propName}`);
1960
+ 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}`);
1961
+ assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
1962
+ assert.invariant(!isObject(newValue) || isNull(newValue), `Invalid value "${newValue}" for "${propName}" of ${vm}. Value cannot be an object, must be a primitive value.`);
1963
+ }
1964
+ updateComponentValue(vm, propName, newValue);
1965
+ return set.call(vm.elm, newValue);
1937
1966
  }
1938
- return {
1939
- enumerable,
1940
- configurable,
1941
- get() {
1942
- const vm = getAssociatedVM(this);
1943
- if (isBeingConstructed(vm)) {
1944
- if (process.env.NODE_ENV !== 'production') {
1945
- 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);
1946
- }
1947
- return;
1948
- }
1949
- componentValueObserved(vm, propName);
1950
- return get.call(vm.elm);
1951
- },
1952
- set(newValue) {
1953
- const vm = getAssociatedVM(this);
1954
- if (process.env.NODE_ENV !== 'production') {
1955
- const vmBeingRendered = getVMBeingRendered();
1956
- assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${propName}`);
1957
- 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}`);
1958
- assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
1959
- assert.invariant(!isObject(newValue) || isNull(newValue), `Invalid value "${newValue}" for "${propName}" of ${vm}. Value cannot be an object, must be a primitive value.`);
1960
- }
1961
- updateComponentValue(vm, propName, newValue);
1962
- return set.call(vm.elm, newValue);
1963
- },
1964
- };
1967
+ };
1965
1968
  }
1966
1969
  const EMPTY_REFS = freeze(create(null));
1967
1970
  const refsCache = new WeakMap();
@@ -1971,345 +1974,442 @@ var LWC = (function (exports) {
1971
1974
  **/
1972
1975
  // @ts-ignore
1973
1976
  const LightningElement = function () {
1974
- // This should be as performant as possible, while any initialization should be done lazily
1975
- if (isNull(vmBeingConstructed)) {
1976
- // Thrown when doing something like `new LightningElement()` or
1977
- // `class Foo extends LightningElement {}; new Foo()`
1978
- throw new TypeError('Illegal constructor');
1979
- }
1980
- const vm = vmBeingConstructed;
1981
- const { def, elm } = vm;
1982
- const { bridge } = def;
1977
+ // This should be as performant as possible, while any initialization should be done lazily
1978
+ if (isNull(vmBeingConstructed)) {
1979
+ // Thrown when doing something like `new LightningElement()` or
1980
+ // `class Foo extends LightningElement {}; new Foo()`
1981
+ throw new TypeError('Illegal constructor');
1982
+ }
1983
+ const vm = vmBeingConstructed;
1984
+ const {
1985
+ def,
1986
+ elm
1987
+ } = vm;
1988
+ const {
1989
+ bridge
1990
+ } = def;
1991
+ if (process.env.NODE_ENV !== 'production') {
1992
+ const {
1993
+ assertInstanceOfHTMLElement
1994
+ } = vm.renderer;
1995
+ assertInstanceOfHTMLElement(vm.elm, `Component creation requires a DOM element to be associated to ${vm}.`);
1996
+ }
1997
+ const component = this;
1998
+ setPrototypeOf(elm, bridge.prototype);
1999
+ vm.component = this;
2000
+ // Locker hooks assignment. When the LWC engine run with Locker, Locker intercepts all the new
2001
+ // component creation and passes hooks to instrument all the component interactions with the
2002
+ // engine. We are intentionally hiding this argument from the formal API of LightningElement
2003
+ // because we don't want folks to know about it just yet.
2004
+ if (arguments.length === 1) {
2005
+ const {
2006
+ callHook,
2007
+ setHook,
2008
+ getHook
2009
+ } = arguments[0];
2010
+ vm.callHook = callHook;
2011
+ vm.setHook = setHook;
2012
+ vm.getHook = getHook;
2013
+ }
2014
+ markLockerLiveObject(this);
2015
+ // Linking elm, shadow root and component with the VM.
2016
+ associateVM(component, vm);
2017
+ associateVM(elm, vm);
2018
+ if (vm.renderMode === 1 /* RenderMode.Shadow */) {
2019
+ vm.renderRoot = doAttachShadow(vm);
2020
+ } else {
2021
+ vm.renderRoot = elm;
2022
+ }
2023
+ // Adding extra guard rails in DEV mode.
2024
+ if (process.env.NODE_ENV !== 'production') {
2025
+ patchCustomElementWithRestrictions(elm);
2026
+ patchComponentWithRestrictions(component);
2027
+ }
2028
+ return this;
2029
+ };
2030
+ function doAttachShadow(vm) {
2031
+ const {
2032
+ elm,
2033
+ mode,
2034
+ shadowMode,
2035
+ def: {
2036
+ ctor
2037
+ },
2038
+ renderer: {
2039
+ attachShadow
2040
+ }
2041
+ } = vm;
2042
+ const shadowRoot = attachShadow(elm, {
2043
+ [KEY__SYNTHETIC_MODE]: shadowMode === 1 /* ShadowMode.Synthetic */,
2044
+ delegatesFocus: Boolean(ctor.delegatesFocus),
2045
+ mode
2046
+ });
2047
+ vm.shadowRoot = shadowRoot;
2048
+ associateVM(shadowRoot, vm);
2049
+ if (process.env.NODE_ENV !== 'production') {
2050
+ patchShadowRootWithRestrictions(shadowRoot);
2051
+ }
2052
+ return shadowRoot;
2053
+ }
2054
+ function warnIfInvokedDuringConstruction(vm, methodOrPropName) {
2055
+ if (isBeingConstructed(vm)) {
2056
+ 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.`);
2057
+ }
2058
+ }
2059
+ // @ts-ignore
2060
+ LightningElement.prototype = {
2061
+ constructor: LightningElement,
2062
+ dispatchEvent(event) {
2063
+ const vm = getAssociatedVM(this);
2064
+ const {
2065
+ elm,
2066
+ renderer: {
2067
+ dispatchEvent
2068
+ }
2069
+ } = vm;
2070
+ return dispatchEvent(elm, event);
2071
+ },
2072
+ addEventListener(type, listener, options) {
2073
+ const vm = getAssociatedVM(this);
2074
+ const {
2075
+ elm,
2076
+ renderer: {
2077
+ addEventListener
2078
+ }
2079
+ } = vm;
1983
2080
  if (process.env.NODE_ENV !== 'production') {
1984
- const { assertInstanceOfHTMLElement } = vm.renderer;
1985
- assertInstanceOfHTMLElement(vm.elm, `Component creation requires a DOM element to be associated to ${vm}.`);
1986
- }
1987
- const component = this;
1988
- setPrototypeOf(elm, bridge.prototype);
1989
- vm.component = this;
1990
- // Locker hooks assignment. When the LWC engine run with Locker, Locker intercepts all the new
1991
- // component creation and passes hooks to instrument all the component interactions with the
1992
- // engine. We are intentionally hiding this argument from the formal API of LightningElement
1993
- // because we don't want folks to know about it just yet.
1994
- if (arguments.length === 1) {
1995
- const { callHook, setHook, getHook } = arguments[0];
1996
- vm.callHook = callHook;
1997
- vm.setHook = setHook;
1998
- vm.getHook = getHook;
1999
- }
2000
- markLockerLiveObject(this);
2001
- // Linking elm, shadow root and component with the VM.
2002
- associateVM(component, vm);
2003
- associateVM(elm, vm);
2004
- if (vm.renderMode === 1 /* RenderMode.Shadow */) {
2005
- vm.renderRoot = doAttachShadow(vm);
2081
+ const vmBeingRendered = getVMBeingRendered();
2082
+ assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm} by adding an event listener for "${type}".`);
2083
+ assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm} by adding an event listener for "${type}".`);
2084
+ assert.invariant(isFunction$1(listener), `Invalid second argument for this.addEventListener() in ${vm} for event "${type}". Expected an EventListener but received ${listener}.`);
2085
+ }
2086
+ const wrappedListener = getWrappedComponentsListener(vm, listener);
2087
+ addEventListener(elm, type, wrappedListener, options);
2088
+ },
2089
+ removeEventListener(type, listener, options) {
2090
+ const vm = getAssociatedVM(this);
2091
+ const {
2092
+ elm,
2093
+ renderer: {
2094
+ removeEventListener
2095
+ }
2096
+ } = vm;
2097
+ const wrappedListener = getWrappedComponentsListener(vm, listener);
2098
+ removeEventListener(elm, type, wrappedListener, options);
2099
+ },
2100
+ hasAttribute(name) {
2101
+ const vm = getAssociatedVM(this);
2102
+ const {
2103
+ elm,
2104
+ renderer: {
2105
+ getAttribute
2106
+ }
2107
+ } = vm;
2108
+ return !isNull(getAttribute(elm, name));
2109
+ },
2110
+ hasAttributeNS(namespace, name) {
2111
+ const vm = getAssociatedVM(this);
2112
+ const {
2113
+ elm,
2114
+ renderer: {
2115
+ getAttribute
2116
+ }
2117
+ } = vm;
2118
+ return !isNull(getAttribute(elm, name, namespace));
2119
+ },
2120
+ removeAttribute(name) {
2121
+ const vm = getAssociatedVM(this);
2122
+ const {
2123
+ elm,
2124
+ renderer: {
2125
+ removeAttribute
2126
+ }
2127
+ } = vm;
2128
+ unlockAttribute(elm, name);
2129
+ removeAttribute(elm, name);
2130
+ lockAttribute();
2131
+ },
2132
+ removeAttributeNS(namespace, name) {
2133
+ const {
2134
+ elm,
2135
+ renderer: {
2136
+ removeAttribute
2137
+ }
2138
+ } = getAssociatedVM(this);
2139
+ unlockAttribute(elm, name);
2140
+ removeAttribute(elm, name, namespace);
2141
+ lockAttribute();
2142
+ },
2143
+ getAttribute(name) {
2144
+ const vm = getAssociatedVM(this);
2145
+ const {
2146
+ elm
2147
+ } = vm;
2148
+ const {
2149
+ getAttribute
2150
+ } = vm.renderer;
2151
+ return getAttribute(elm, name);
2152
+ },
2153
+ getAttributeNS(namespace, name) {
2154
+ const vm = getAssociatedVM(this);
2155
+ const {
2156
+ elm
2157
+ } = vm;
2158
+ const {
2159
+ getAttribute
2160
+ } = vm.renderer;
2161
+ return getAttribute(elm, name, namespace);
2162
+ },
2163
+ setAttribute(name, value) {
2164
+ const vm = getAssociatedVM(this);
2165
+ const {
2166
+ elm,
2167
+ renderer: {
2168
+ setAttribute
2169
+ }
2170
+ } = vm;
2171
+ if (process.env.NODE_ENV !== 'production') {
2172
+ assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
2173
+ }
2174
+ unlockAttribute(elm, name);
2175
+ setAttribute(elm, name, value);
2176
+ lockAttribute();
2177
+ },
2178
+ setAttributeNS(namespace, name, value) {
2179
+ const vm = getAssociatedVM(this);
2180
+ const {
2181
+ elm,
2182
+ renderer: {
2183
+ setAttribute
2184
+ }
2185
+ } = vm;
2186
+ if (process.env.NODE_ENV !== 'production') {
2187
+ assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
2188
+ }
2189
+ unlockAttribute(elm, name);
2190
+ setAttribute(elm, name, value, namespace);
2191
+ lockAttribute();
2192
+ },
2193
+ getBoundingClientRect() {
2194
+ const vm = getAssociatedVM(this);
2195
+ const {
2196
+ elm,
2197
+ renderer: {
2198
+ getBoundingClientRect
2199
+ }
2200
+ } = vm;
2201
+ if (process.env.NODE_ENV !== 'production') {
2202
+ warnIfInvokedDuringConstruction(vm, 'getBoundingClientRect()');
2006
2203
  }
2007
- else {
2008
- vm.renderRoot = elm;
2204
+ return getBoundingClientRect(elm);
2205
+ },
2206
+ get isConnected() {
2207
+ const vm = getAssociatedVM(this);
2208
+ const {
2209
+ elm,
2210
+ renderer: {
2211
+ isConnected
2212
+ }
2213
+ } = vm;
2214
+ return isConnected(elm);
2215
+ },
2216
+ get classList() {
2217
+ const vm = getAssociatedVM(this);
2218
+ const {
2219
+ elm,
2220
+ renderer: {
2221
+ getClassList
2222
+ }
2223
+ } = vm;
2224
+ if (process.env.NODE_ENV !== 'production') {
2225
+ // TODO [#1290]: this still fails in dev but works in production, eventually, we should
2226
+ // just throw in all modes
2227
+ 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.`);
2228
+ }
2229
+ return getClassList(elm);
2230
+ },
2231
+ get template() {
2232
+ const vm = getAssociatedVM(this);
2233
+ if (process.env.NODE_ENV !== 'production') {
2234
+ if (vm.renderMode === 0 /* RenderMode.Light */) {
2235
+ 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`.');
2236
+ }
2237
+ }
2238
+ return vm.shadowRoot;
2239
+ },
2240
+ get refs() {
2241
+ const vm = getAssociatedVM(this);
2242
+ if (isUpdatingTemplate) {
2243
+ if (process.env.NODE_ENV !== 'production') {
2244
+ 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().`);
2245
+ }
2246
+ // If the template is in the process of being updated, then we don't want to go through the normal
2247
+ // process of returning the refs and caching them, because the state of the refs is unstable.
2248
+ // This can happen if e.g. a template contains `<div class={foo}></div>` and `foo` is computed
2249
+ // based on `this.refs.bar`.
2250
+ return;
2009
2251
  }
2010
- // Adding extra guard rails in DEV mode.
2011
2252
  if (process.env.NODE_ENV !== 'production') {
2012
- patchCustomElementWithRestrictions(elm);
2013
- patchComponentWithRestrictions(component);
2253
+ warnIfInvokedDuringConstruction(vm, 'refs');
2014
2254
  }
2015
- return this;
2016
- };
2017
- function doAttachShadow(vm) {
2018
- const { elm, mode, shadowMode, def: { ctor }, renderer: { attachShadow }, } = vm;
2019
- const shadowRoot = attachShadow(elm, {
2020
- [KEY__SYNTHETIC_MODE]: shadowMode === 1 /* ShadowMode.Synthetic */,
2021
- delegatesFocus: Boolean(ctor.delegatesFocus),
2022
- mode,
2255
+ const {
2256
+ refVNodes,
2257
+ hasRefVNodes,
2258
+ cmpTemplate
2259
+ } = vm;
2260
+ // If the `cmpTemplate` is null, that means that the template has not been rendered yet. Most likely this occurs
2261
+ // if `this.refs` is called during the `connectedCallback` phase. The DOM elements have not been rendered yet,
2262
+ // so log a warning. Note we also check `isBeingConstructed()` to avoid a double warning (due to
2263
+ // `warnIfInvokedDuringConstruction` above).
2264
+ if (process.env.NODE_ENV !== 'production' && isNull(cmpTemplate) && !isBeingConstructed(vm)) {
2265
+ 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().`);
2266
+ }
2267
+ // For backwards compatibility with component written before template refs
2268
+ // were introduced, we return undefined if the template has no refs defined
2269
+ // anywhere. This fixes components that may want to add an expando called `refs`
2270
+ // and are checking if it exists with `if (this.refs)` before adding it.
2271
+ // Note it is not sufficient to just check if `refVNodes` is null or empty,
2272
+ // because a template may have `lwc:ref` defined within a falsy `if:true` block.
2273
+ if (!hasRefVNodes) {
2274
+ return;
2275
+ }
2276
+ // For templates that are using `lwc:ref`, if there are no refs currently available
2277
+ // (e.g. refs inside of a falsy `if:true` block), we return an empty object.
2278
+ if (isNull(refVNodes)) {
2279
+ return EMPTY_REFS;
2280
+ }
2281
+ // The refNodes can be cached based on the refVNodes, since the refVNodes
2282
+ // are recreated from scratch every time the template is rendered.
2283
+ // This happens with `vm.refVNodes = null` in `template.ts` in `@lwc/engine-core`.
2284
+ let refs = refsCache.get(refVNodes);
2285
+ if (isUndefined$1(refs)) {
2286
+ refs = create(null);
2287
+ for (const key of keys(refVNodes)) {
2288
+ refs[key] = refVNodes[key].elm;
2289
+ }
2290
+ freeze(refs);
2291
+ refsCache.set(refVNodes, refs);
2292
+ }
2293
+ return refs;
2294
+ },
2295
+ // For backwards compat, we allow component authors to set `refs` as an expando
2296
+ set refs(value) {
2297
+ defineProperty(this, 'refs', {
2298
+ configurable: true,
2299
+ enumerable: true,
2300
+ writable: true,
2301
+ value
2023
2302
  });
2024
- vm.shadowRoot = shadowRoot;
2025
- associateVM(shadowRoot, vm);
2303
+ },
2304
+ get shadowRoot() {
2305
+ // From within the component instance, the shadowRoot is always reported as "closed".
2306
+ // Authors should rely on this.template instead.
2307
+ return null;
2308
+ },
2309
+ get children() {
2310
+ const vm = getAssociatedVM(this);
2311
+ const renderer = vm.renderer;
2026
2312
  if (process.env.NODE_ENV !== 'production') {
2027
- patchShadowRootWithRestrictions(shadowRoot);
2313
+ warnIfInvokedDuringConstruction(vm, 'children');
2028
2314
  }
2029
- return shadowRoot;
2030
- }
2031
- function warnIfInvokedDuringConstruction(vm, methodOrPropName) {
2032
- if (isBeingConstructed(vm)) {
2033
- 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.`);
2315
+ return renderer.getChildren(vm.elm);
2316
+ },
2317
+ get childNodes() {
2318
+ const vm = getAssociatedVM(this);
2319
+ const renderer = vm.renderer;
2320
+ if (process.env.NODE_ENV !== 'production') {
2321
+ warnIfInvokedDuringConstruction(vm, 'childNodes');
2034
2322
  }
2035
- }
2036
- // @ts-ignore
2037
- LightningElement.prototype = {
2038
- constructor: LightningElement,
2039
- dispatchEvent(event) {
2040
- const vm = getAssociatedVM(this);
2041
- const { elm, renderer: { dispatchEvent }, } = vm;
2042
- return dispatchEvent(elm, event);
2043
- },
2044
- addEventListener(type, listener, options) {
2045
- const vm = getAssociatedVM(this);
2046
- const { elm, renderer: { addEventListener }, } = vm;
2047
- if (process.env.NODE_ENV !== 'production') {
2048
- const vmBeingRendered = getVMBeingRendered();
2049
- assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm} by adding an event listener for "${type}".`);
2050
- assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm} by adding an event listener for "${type}".`);
2051
- assert.invariant(isFunction$1(listener), `Invalid second argument for this.addEventListener() in ${vm} for event "${type}". Expected an EventListener but received ${listener}.`);
2052
- }
2053
- const wrappedListener = getWrappedComponentsListener(vm, listener);
2054
- addEventListener(elm, type, wrappedListener, options);
2055
- },
2056
- removeEventListener(type, listener, options) {
2057
- const vm = getAssociatedVM(this);
2058
- const { elm, renderer: { removeEventListener }, } = vm;
2059
- const wrappedListener = getWrappedComponentsListener(vm, listener);
2060
- removeEventListener(elm, type, wrappedListener, options);
2061
- },
2062
- hasAttribute(name) {
2063
- const vm = getAssociatedVM(this);
2064
- const { elm, renderer: { getAttribute }, } = vm;
2065
- return !isNull(getAttribute(elm, name));
2066
- },
2067
- hasAttributeNS(namespace, name) {
2068
- const vm = getAssociatedVM(this);
2069
- const { elm, renderer: { getAttribute }, } = vm;
2070
- return !isNull(getAttribute(elm, name, namespace));
2071
- },
2072
- removeAttribute(name) {
2073
- const vm = getAssociatedVM(this);
2074
- const { elm, renderer: { removeAttribute }, } = vm;
2075
- unlockAttribute(elm, name);
2076
- removeAttribute(elm, name);
2077
- lockAttribute();
2078
- },
2079
- removeAttributeNS(namespace, name) {
2080
- const { elm, renderer: { removeAttribute }, } = getAssociatedVM(this);
2081
- unlockAttribute(elm, name);
2082
- removeAttribute(elm, name, namespace);
2083
- lockAttribute();
2084
- },
2085
- getAttribute(name) {
2086
- const vm = getAssociatedVM(this);
2087
- const { elm } = vm;
2088
- const { getAttribute } = vm.renderer;
2089
- return getAttribute(elm, name);
2090
- },
2091
- getAttributeNS(namespace, name) {
2092
- const vm = getAssociatedVM(this);
2093
- const { elm } = vm;
2094
- const { getAttribute } = vm.renderer;
2095
- return getAttribute(elm, name, namespace);
2096
- },
2097
- setAttribute(name, value) {
2098
- const vm = getAssociatedVM(this);
2099
- const { elm, renderer: { setAttribute }, } = vm;
2100
- if (process.env.NODE_ENV !== 'production') {
2101
- assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
2102
- }
2103
- unlockAttribute(elm, name);
2104
- setAttribute(elm, name, value);
2105
- lockAttribute();
2106
- },
2107
- setAttributeNS(namespace, name, value) {
2108
- const vm = getAssociatedVM(this);
2109
- const { elm, renderer: { setAttribute }, } = vm;
2110
- if (process.env.NODE_ENV !== 'production') {
2111
- assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
2112
- }
2113
- unlockAttribute(elm, name);
2114
- setAttribute(elm, name, value, namespace);
2115
- lockAttribute();
2116
- },
2117
- getBoundingClientRect() {
2118
- const vm = getAssociatedVM(this);
2119
- const { elm, renderer: { getBoundingClientRect }, } = vm;
2120
- if (process.env.NODE_ENV !== 'production') {
2121
- warnIfInvokedDuringConstruction(vm, 'getBoundingClientRect()');
2122
- }
2123
- return getBoundingClientRect(elm);
2124
- },
2125
- get isConnected() {
2126
- const vm = getAssociatedVM(this);
2127
- const { elm, renderer: { isConnected }, } = vm;
2128
- return isConnected(elm);
2129
- },
2130
- get classList() {
2131
- const vm = getAssociatedVM(this);
2132
- const { elm, renderer: { getClassList }, } = vm;
2133
- if (process.env.NODE_ENV !== 'production') {
2134
- // TODO [#1290]: this still fails in dev but works in production, eventually, we should
2135
- // just throw in all modes
2136
- 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.`);
2137
- }
2138
- return getClassList(elm);
2139
- },
2140
- get template() {
2141
- const vm = getAssociatedVM(this);
2142
- if (process.env.NODE_ENV !== 'production') {
2143
- if (vm.renderMode === 0 /* RenderMode.Light */) {
2144
- 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`.');
2145
- }
2146
- }
2147
- return vm.shadowRoot;
2148
- },
2149
- get refs() {
2150
- const vm = getAssociatedVM(this);
2151
- if (isUpdatingTemplate) {
2152
- if (process.env.NODE_ENV !== 'production') {
2153
- 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().`);
2154
- }
2155
- // If the template is in the process of being updated, then we don't want to go through the normal
2156
- // process of returning the refs and caching them, because the state of the refs is unstable.
2157
- // This can happen if e.g. a template contains `<div class={foo}></div>` and `foo` is computed
2158
- // based on `this.refs.bar`.
2159
- return;
2160
- }
2161
- if (process.env.NODE_ENV !== 'production') {
2162
- warnIfInvokedDuringConstruction(vm, 'refs');
2163
- }
2164
- const { refVNodes, hasRefVNodes, cmpTemplate } = vm;
2165
- // If the `cmpTemplate` is null, that means that the template has not been rendered yet. Most likely this occurs
2166
- // if `this.refs` is called during the `connectedCallback` phase. The DOM elements have not been rendered yet,
2167
- // so log a warning. Note we also check `isBeingConstructed()` to avoid a double warning (due to
2168
- // `warnIfInvokedDuringConstruction` above).
2169
- if (process.env.NODE_ENV !== 'production' &&
2170
- isNull(cmpTemplate) &&
2171
- !isBeingConstructed(vm)) {
2172
- logError(`this.refs is undefined for ${getComponentTag(vm)}. This is either because the attached template has no "lwc:ref" directive, or this.refs was ` +
2173
- `invoked before renderedCallback(). Use this.refs only when the referenced HTML elements have ` +
2174
- `been rendered to the DOM, such as within renderedCallback() or disconnectedCallback().`);
2175
- }
2176
- // For backwards compatibility with component written before template refs
2177
- // were introduced, we return undefined if the template has no refs defined
2178
- // anywhere. This fixes components that may want to add an expando called `refs`
2179
- // and are checking if it exists with `if (this.refs)` before adding it.
2180
- // Note it is not sufficient to just check if `refVNodes` is null or empty,
2181
- // because a template may have `lwc:ref` defined within a falsy `if:true` block.
2182
- if (!hasRefVNodes) {
2183
- return;
2184
- }
2185
- // For templates that are using `lwc:ref`, if there are no refs currently available
2186
- // (e.g. refs inside of a falsy `if:true` block), we return an empty object.
2187
- if (isNull(refVNodes)) {
2188
- return EMPTY_REFS;
2189
- }
2190
- // The refNodes can be cached based on the refVNodes, since the refVNodes
2191
- // are recreated from scratch every time the template is rendered.
2192
- // This happens with `vm.refVNodes = null` in `template.ts` in `@lwc/engine-core`.
2193
- let refs = refsCache.get(refVNodes);
2194
- if (isUndefined$1(refs)) {
2195
- refs = create(null);
2196
- for (const key of keys(refVNodes)) {
2197
- refs[key] = refVNodes[key].elm;
2198
- }
2199
- freeze(refs);
2200
- refsCache.set(refVNodes, refs);
2201
- }
2202
- return refs;
2203
- },
2204
- // For backwards compat, we allow component authors to set `refs` as an expando
2205
- set refs(value) {
2206
- defineProperty(this, 'refs', {
2207
- configurable: true,
2208
- enumerable: true,
2209
- writable: true,
2210
- value,
2211
- });
2212
- },
2213
- get shadowRoot() {
2214
- // From within the component instance, the shadowRoot is always reported as "closed".
2215
- // Authors should rely on this.template instead.
2216
- return null;
2217
- },
2218
- get children() {
2219
- const vm = getAssociatedVM(this);
2220
- const renderer = vm.renderer;
2221
- if (process.env.NODE_ENV !== 'production') {
2222
- warnIfInvokedDuringConstruction(vm, 'children');
2223
- }
2224
- return renderer.getChildren(vm.elm);
2225
- },
2226
- get childNodes() {
2227
- const vm = getAssociatedVM(this);
2228
- const renderer = vm.renderer;
2229
- if (process.env.NODE_ENV !== 'production') {
2230
- warnIfInvokedDuringConstruction(vm, 'childNodes');
2231
- }
2232
- return renderer.getChildNodes(vm.elm);
2233
- },
2234
- get firstChild() {
2235
- const vm = getAssociatedVM(this);
2236
- const renderer = vm.renderer;
2237
- if (process.env.NODE_ENV !== 'production') {
2238
- warnIfInvokedDuringConstruction(vm, 'firstChild');
2239
- }
2240
- return renderer.getFirstChild(vm.elm);
2241
- },
2242
- get firstElementChild() {
2243
- const vm = getAssociatedVM(this);
2244
- const renderer = vm.renderer;
2245
- if (process.env.NODE_ENV !== 'production') {
2246
- warnIfInvokedDuringConstruction(vm, 'firstElementChild');
2247
- }
2248
- return renderer.getFirstElementChild(vm.elm);
2249
- },
2250
- get lastChild() {
2251
- const vm = getAssociatedVM(this);
2252
- const renderer = vm.renderer;
2253
- if (process.env.NODE_ENV !== 'production') {
2254
- warnIfInvokedDuringConstruction(vm, 'lastChild');
2255
- }
2256
- return renderer.getLastChild(vm.elm);
2257
- },
2258
- get lastElementChild() {
2259
- const vm = getAssociatedVM(this);
2260
- const renderer = vm.renderer;
2261
- if (process.env.NODE_ENV !== 'production') {
2262
- warnIfInvokedDuringConstruction(vm, 'lastElementChild');
2263
- }
2264
- return renderer.getLastElementChild(vm.elm);
2265
- },
2266
- render() {
2267
- const vm = getAssociatedVM(this);
2268
- return vm.def.template;
2269
- },
2270
- toString() {
2271
- const vm = getAssociatedVM(this);
2272
- return `[object ${vm.def.name}]`;
2273
- },
2323
+ return renderer.getChildNodes(vm.elm);
2324
+ },
2325
+ get firstChild() {
2326
+ const vm = getAssociatedVM(this);
2327
+ const renderer = vm.renderer;
2328
+ if (process.env.NODE_ENV !== 'production') {
2329
+ warnIfInvokedDuringConstruction(vm, 'firstChild');
2330
+ }
2331
+ return renderer.getFirstChild(vm.elm);
2332
+ },
2333
+ get firstElementChild() {
2334
+ const vm = getAssociatedVM(this);
2335
+ const renderer = vm.renderer;
2336
+ if (process.env.NODE_ENV !== 'production') {
2337
+ warnIfInvokedDuringConstruction(vm, 'firstElementChild');
2338
+ }
2339
+ return renderer.getFirstElementChild(vm.elm);
2340
+ },
2341
+ get lastChild() {
2342
+ const vm = getAssociatedVM(this);
2343
+ const renderer = vm.renderer;
2344
+ if (process.env.NODE_ENV !== 'production') {
2345
+ warnIfInvokedDuringConstruction(vm, 'lastChild');
2346
+ }
2347
+ return renderer.getLastChild(vm.elm);
2348
+ },
2349
+ get lastElementChild() {
2350
+ const vm = getAssociatedVM(this);
2351
+ const renderer = vm.renderer;
2352
+ if (process.env.NODE_ENV !== 'production') {
2353
+ warnIfInvokedDuringConstruction(vm, 'lastElementChild');
2354
+ }
2355
+ return renderer.getLastElementChild(vm.elm);
2356
+ },
2357
+ render() {
2358
+ const vm = getAssociatedVM(this);
2359
+ return vm.def.template;
2360
+ },
2361
+ toString() {
2362
+ const vm = getAssociatedVM(this);
2363
+ return `[object ${vm.def.name}]`;
2364
+ }
2274
2365
  };
2275
2366
  const queryAndChildGetterDescriptors = create(null);
2276
- const queryMethods = [
2277
- 'getElementsByClassName',
2278
- 'getElementsByTagName',
2279
- 'querySelector',
2280
- 'querySelectorAll',
2281
- ];
2367
+ const queryMethods = ['getElementsByClassName', 'getElementsByTagName', 'querySelector', 'querySelectorAll'];
2282
2368
  // Generic passthrough for query APIs on HTMLElement to the relevant Renderer APIs
2283
2369
  for (const queryMethod of queryMethods) {
2284
- queryAndChildGetterDescriptors[queryMethod] = {
2285
- value(arg) {
2286
- const vm = getAssociatedVM(this);
2287
- const { elm, renderer } = vm;
2288
- if (process.env.NODE_ENV !== 'production') {
2289
- warnIfInvokedDuringConstruction(vm, `${queryMethod}()`);
2290
- }
2291
- return renderer[queryMethod](elm, arg);
2292
- },
2293
- configurable: true,
2294
- enumerable: true,
2295
- writable: true,
2296
- };
2370
+ queryAndChildGetterDescriptors[queryMethod] = {
2371
+ value(arg) {
2372
+ const vm = getAssociatedVM(this);
2373
+ const {
2374
+ elm,
2375
+ renderer
2376
+ } = vm;
2377
+ if (process.env.NODE_ENV !== 'production') {
2378
+ warnIfInvokedDuringConstruction(vm, `${queryMethod}()`);
2379
+ }
2380
+ return renderer[queryMethod](elm, arg);
2381
+ },
2382
+ configurable: true,
2383
+ enumerable: true,
2384
+ writable: true
2385
+ };
2297
2386
  }
2298
2387
  defineProperties(LightningElement.prototype, queryAndChildGetterDescriptors);
2299
2388
  const lightningBasedDescriptors = create(null);
2300
2389
  for (const propName in HTMLElementOriginalDescriptors) {
2301
- lightningBasedDescriptors[propName] = createBridgeToElementDescriptor(propName, HTMLElementOriginalDescriptors[propName]);
2390
+ lightningBasedDescriptors[propName] = createBridgeToElementDescriptor(propName, HTMLElementOriginalDescriptors[propName]);
2302
2391
  }
2303
2392
  defineProperties(LightningElement.prototype, lightningBasedDescriptors);
2393
+ function applyAriaReflectionToLightningElement() {
2394
+ // If ARIA reflection is not applied globally to Element.prototype, or if we are running server-side,
2395
+ // apply it to LightningElement.prototype.
2396
+ // This allows `this.aria*` property accessors to work from inside a component, and to reflect `aria-*` attrs.
2397
+ applyAriaReflection(LightningElement.prototype);
2398
+ }
2399
+ // The reason for this odd if/else branching is limitations in @lwc/features:
2400
+ // https://github.com/salesforce/lwc/blob/master/packages/%40lwc/features/README.md#only-works-with-if-statements
2401
+ if (lwcRuntimeFlags.DISABLE_ARIA_REFLECTION_POLYFILL) {
2402
+ applyAriaReflectionToLightningElement();
2403
+ }
2304
2404
  defineProperty(LightningElement, 'CustomElementConstructor', {
2305
- get() {
2306
- // If required, a runtime-specific implementation must be defined.
2307
- throw new ReferenceError('The current runtime does not support CustomElementConstructor.');
2308
- },
2309
- configurable: true,
2405
+ get() {
2406
+ // If required, a runtime-specific implementation must be defined.
2407
+ throw new ReferenceError('The current runtime does not support CustomElementConstructor.');
2408
+ },
2409
+ configurable: true
2310
2410
  });
2311
2411
  if (process.env.NODE_ENV !== 'production') {
2312
- patchLightningElementPrototypeWithRestrictions(LightningElement.prototype);
2412
+ patchLightningElementPrototypeWithRestrictions(LightningElement.prototype);
2313
2413
  }
2314
2414
 
2315
2415
  function createObservedFieldPropertyDescriptor(key) {
@@ -2769,138 +2869,161 @@ var LWC = (function (exports) {
2769
2869
  const cachedGetterByKey = create(null);
2770
2870
  const cachedSetterByKey = create(null);
2771
2871
  function createGetter(key) {
2772
- let fn = cachedGetterByKey[key];
2773
- if (isUndefined$1(fn)) {
2774
- fn = cachedGetterByKey[key] = function () {
2775
- const vm = getAssociatedVM(this);
2776
- const { getHook } = vm;
2777
- return getHook(vm.component, key);
2778
- };
2779
- }
2780
- return fn;
2872
+ let fn = cachedGetterByKey[key];
2873
+ if (isUndefined$1(fn)) {
2874
+ fn = cachedGetterByKey[key] = function () {
2875
+ const vm = getAssociatedVM(this);
2876
+ const {
2877
+ getHook
2878
+ } = vm;
2879
+ return getHook(vm.component, key);
2880
+ };
2881
+ }
2882
+ return fn;
2781
2883
  }
2782
2884
  function createSetter(key) {
2783
- let fn = cachedSetterByKey[key];
2784
- if (isUndefined$1(fn)) {
2785
- fn = cachedSetterByKey[key] = function (newValue) {
2786
- const vm = getAssociatedVM(this);
2787
- const { setHook } = vm;
2788
- newValue = getReadOnlyProxy(newValue);
2789
- setHook(vm.component, key, newValue);
2790
- };
2791
- }
2792
- return fn;
2885
+ let fn = cachedSetterByKey[key];
2886
+ if (isUndefined$1(fn)) {
2887
+ fn = cachedSetterByKey[key] = function (newValue) {
2888
+ const vm = getAssociatedVM(this);
2889
+ const {
2890
+ setHook
2891
+ } = vm;
2892
+ newValue = getReadOnlyProxy(newValue);
2893
+ setHook(vm.component, key, newValue);
2894
+ };
2895
+ }
2896
+ return fn;
2793
2897
  }
2794
2898
  function createMethodCaller(methodName) {
2795
- return function () {
2796
- const vm = getAssociatedVM(this);
2797
- const { callHook, component } = vm;
2798
- const fn = component[methodName];
2799
- return callHook(vm.component, fn, ArraySlice.call(arguments));
2800
- };
2899
+ return function () {
2900
+ const vm = getAssociatedVM(this);
2901
+ const {
2902
+ callHook,
2903
+ component
2904
+ } = vm;
2905
+ const fn = component[methodName];
2906
+ return callHook(vm.component, fn, ArraySlice.call(arguments));
2907
+ };
2801
2908
  }
2802
2909
  function createAttributeChangedCallback(attributeToPropMap, superAttributeChangedCallback) {
2803
- return function attributeChangedCallback(attrName, oldValue, newValue) {
2804
- if (oldValue === newValue) {
2805
- // Ignore same values.
2806
- return;
2807
- }
2808
- const propName = attributeToPropMap[attrName];
2809
- if (isUndefined$1(propName)) {
2810
- if (!isUndefined$1(superAttributeChangedCallback)) {
2811
- // delegate unknown attributes to the super.
2812
- // Typescript does not like it when you treat the `arguments` object as an array
2813
- // @ts-ignore type-mismatch
2814
- superAttributeChangedCallback.apply(this, arguments);
2815
- }
2816
- return;
2817
- }
2818
- if (!isAttributeLocked(this, attrName)) {
2819
- // Ignore changes triggered by the engine itself during:
2820
- // * diffing when public props are attempting to reflect to the DOM
2821
- // * component via `this.setAttribute()`, should never update the prop
2822
- // Both cases, the setAttribute call is always wrapped by the unlocking of the
2823
- // attribute to be changed
2824
- return;
2825
- }
2826
- // Reflect attribute change to the corresponding property when changed from outside.
2827
- this[propName] = newValue;
2828
- };
2829
- }
2830
- function HTMLBridgeElementFactory(SuperClass, props, methods) {
2831
- let HTMLBridgeElement;
2832
- /**
2833
- * Modern browsers will have all Native Constructors as regular Classes
2834
- * and must be instantiated with the new keyword. In older browsers,
2835
- * specifically IE11, those are objects with a prototype property defined,
2836
- * since they are not supposed to be extended or instantiated with the
2837
- * new keyword. This forking logic supports both cases, specifically because
2838
- * wc.ts relies on the construction path of the bridges to create new
2839
- * fully qualifying web components.
2840
- */
2841
- if (isFunction$1(SuperClass)) {
2842
- HTMLBridgeElement = class extends SuperClass {
2843
- };
2844
- }
2845
- else {
2846
- HTMLBridgeElement = function () {
2847
- // Bridge classes are not supposed to be instantiated directly in
2848
- // browsers that do not support web components.
2849
- throw new TypeError('Illegal constructor');
2850
- };
2851
- // prototype inheritance dance
2852
- setPrototypeOf(HTMLBridgeElement, SuperClass);
2853
- setPrototypeOf(HTMLBridgeElement.prototype, SuperClass.prototype);
2854
- defineProperty(HTMLBridgeElement.prototype, 'constructor', {
2855
- writable: true,
2856
- configurable: true,
2857
- value: HTMLBridgeElement,
2858
- });
2910
+ return function attributeChangedCallback(attrName, oldValue, newValue) {
2911
+ if (oldValue === newValue) {
2912
+ // Ignore same values.
2913
+ return;
2859
2914
  }
2860
- // generating the hash table for attributes to avoid duplicate fields and facilitate validation
2861
- // and false positives in case of inheritance.
2862
- const attributeToPropMap = create(null);
2863
- const { attributeChangedCallback: superAttributeChangedCallback } = SuperClass.prototype;
2864
- const { observedAttributes: superObservedAttributes = [] } = SuperClass;
2865
- const descriptors = create(null);
2866
- // expose getters and setters for each public props on the new Element Bridge
2867
- for (let i = 0, len = props.length; i < len; i += 1) {
2868
- const propName = props[i];
2869
- attributeToPropMap[htmlPropertyToAttribute(propName)] = propName;
2870
- descriptors[propName] = {
2871
- get: createGetter(propName),
2872
- set: createSetter(propName),
2873
- enumerable: true,
2874
- configurable: true,
2875
- };
2915
+ const propName = attributeToPropMap[attrName];
2916
+ if (isUndefined$1(propName)) {
2917
+ if (!isUndefined$1(superAttributeChangedCallback)) {
2918
+ // delegate unknown attributes to the super.
2919
+ // Typescript does not like it when you treat the `arguments` object as an array
2920
+ // @ts-ignore type-mismatch
2921
+ superAttributeChangedCallback.apply(this, arguments);
2922
+ }
2923
+ return;
2876
2924
  }
2877
- // expose public methods as props on the new Element Bridge
2878
- for (let i = 0, len = methods.length; i < len; i += 1) {
2879
- const methodName = methods[i];
2880
- descriptors[methodName] = {
2881
- value: createMethodCaller(methodName),
2882
- writable: true,
2883
- configurable: true,
2884
- };
2925
+ if (!isAttributeLocked(this, attrName)) {
2926
+ // Ignore changes triggered by the engine itself during:
2927
+ // * diffing when public props are attempting to reflect to the DOM
2928
+ // * component via `this.setAttribute()`, should never update the prop
2929
+ // Both cases, the setAttribute call is always wrapped by the unlocking of the
2930
+ // attribute to be changed
2931
+ return;
2885
2932
  }
2886
- // creating a new attributeChangedCallback per bridge because they are bound to the corresponding
2887
- // map of attributes to props. We do this after all other props and methods to avoid the possibility
2888
- // of getting overrule by a class declaration in user-land, and we make it non-writable, non-configurable
2889
- // to preserve this definition.
2890
- descriptors.attributeChangedCallback = {
2891
- value: createAttributeChangedCallback(attributeToPropMap, superAttributeChangedCallback),
2933
+ // Reflect attribute change to the corresponding property when changed from outside.
2934
+ this[propName] = newValue;
2935
+ };
2936
+ }
2937
+ function HTMLBridgeElementFactory(SuperClass, props, methods) {
2938
+ let HTMLBridgeElement;
2939
+ /**
2940
+ * Modern browsers will have all Native Constructors as regular Classes
2941
+ * and must be instantiated with the new keyword. In older browsers,
2942
+ * specifically IE11, those are objects with a prototype property defined,
2943
+ * since they are not supposed to be extended or instantiated with the
2944
+ * new keyword. This forking logic supports both cases, specifically because
2945
+ * wc.ts relies on the construction path of the bridges to create new
2946
+ * fully qualifying web components.
2947
+ */
2948
+ if (isFunction$1(SuperClass)) {
2949
+ HTMLBridgeElement = class extends SuperClass {};
2950
+ } else {
2951
+ HTMLBridgeElement = function () {
2952
+ // Bridge classes are not supposed to be instantiated directly in
2953
+ // browsers that do not support web components.
2954
+ throw new TypeError('Illegal constructor');
2892
2955
  };
2893
- // Specify attributes for which we want to reflect changes back to their corresponding
2894
- // properties via attributeChangedCallback.
2895
- defineProperty(HTMLBridgeElement, 'observedAttributes', {
2896
- get() {
2897
- return [...superObservedAttributes, ...keys(attributeToPropMap)];
2898
- },
2956
+ // prototype inheritance dance
2957
+ setPrototypeOf(HTMLBridgeElement, SuperClass);
2958
+ setPrototypeOf(HTMLBridgeElement.prototype, SuperClass.prototype);
2959
+ defineProperty(HTMLBridgeElement.prototype, 'constructor', {
2960
+ writable: true,
2961
+ configurable: true,
2962
+ value: HTMLBridgeElement
2899
2963
  });
2900
- defineProperties(HTMLBridgeElement.prototype, descriptors);
2901
- return HTMLBridgeElement;
2964
+ }
2965
+ // generating the hash table for attributes to avoid duplicate fields and facilitate validation
2966
+ // and false positives in case of inheritance.
2967
+ const attributeToPropMap = create(null);
2968
+ const {
2969
+ attributeChangedCallback: superAttributeChangedCallback
2970
+ } = SuperClass.prototype;
2971
+ const {
2972
+ observedAttributes: superObservedAttributes = []
2973
+ } = SuperClass;
2974
+ const descriptors = create(null);
2975
+ // expose getters and setters for each public props on the new Element Bridge
2976
+ for (let i = 0, len = props.length; i < len; i += 1) {
2977
+ const propName = props[i];
2978
+ attributeToPropMap[htmlPropertyToAttribute(propName)] = propName;
2979
+ descriptors[propName] = {
2980
+ get: createGetter(propName),
2981
+ set: createSetter(propName),
2982
+ enumerable: true,
2983
+ configurable: true
2984
+ };
2985
+ }
2986
+ // expose public methods as props on the new Element Bridge
2987
+ for (let i = 0, len = methods.length; i < len; i += 1) {
2988
+ const methodName = methods[i];
2989
+ descriptors[methodName] = {
2990
+ value: createMethodCaller(methodName),
2991
+ writable: true,
2992
+ configurable: true
2993
+ };
2994
+ }
2995
+ // creating a new attributeChangedCallback per bridge because they are bound to the corresponding
2996
+ // map of attributes to props. We do this after all other props and methods to avoid the possibility
2997
+ // of getting overrule by a class declaration in user-land, and we make it non-writable, non-configurable
2998
+ // to preserve this definition.
2999
+ descriptors.attributeChangedCallback = {
3000
+ value: createAttributeChangedCallback(attributeToPropMap, superAttributeChangedCallback)
3001
+ };
3002
+ // Specify attributes for which we want to reflect changes back to their corresponding
3003
+ // properties via attributeChangedCallback.
3004
+ defineProperty(HTMLBridgeElement, 'observedAttributes', {
3005
+ get() {
3006
+ return [...superObservedAttributes, ...keys(attributeToPropMap)];
3007
+ }
3008
+ });
3009
+ defineProperties(HTMLBridgeElement.prototype, descriptors);
3010
+ return HTMLBridgeElement;
2902
3011
  }
2903
3012
  const BaseBridgeElement = HTMLBridgeElementFactory(HTMLElementConstructor, getOwnPropertyNames$1(HTMLElementOriginalDescriptors), []);
3013
+ {
3014
+ // This ARIA reflection only really makes sense in the browser. On the server, there is no `renderedCallback()`,
3015
+ // so you cannot do e.g. `this.template.querySelector('x-child').ariaBusy = 'true'`. So we don't need to expose
3016
+ // ARIA props outside the LightningElement
3017
+ if (lwcRuntimeFlags.DISABLE_ARIA_REFLECTION_POLYFILL) {
3018
+ // If ARIA reflection is not applied globally to Element.prototype, apply it to HTMLBridgeElement.prototype.
3019
+ // This allows `elm.aria*` property accessors to work from outside a component, and to reflect `aria-*` attrs.
3020
+ // This is especially important because the template compiler compiles aria-* attrs on components to aria* props
3021
+ //
3022
+ // Also note that we apply this to BaseBridgeElement.prototype to avoid excessively redefining property
3023
+ // accessors inside the HTMLBridgeElementFactory.
3024
+ applyAriaReflection(BaseBridgeElement.prototype);
3025
+ }
3026
+ }
2904
3027
  freeze(BaseBridgeElement);
2905
3028
  seal(BaseBridgeElement.prototype);
2906
3029
 
@@ -7000,7 +7123,7 @@ var LWC = (function (exports) {
7000
7123
  }
7001
7124
  return ctor;
7002
7125
  }
7003
- /* version: 2.32.1 */
7126
+ /* version: 2.33.0 */
7004
7127
 
7005
7128
  /*
7006
7129
  * Copyright (c) 2018, salesforce.com, inc.
@@ -7973,7 +8096,7 @@ var LWC = (function (exports) {
7973
8096
  function isNull(obj) {
7974
8097
  return obj === null;
7975
8098
  }
7976
- /** version: 2.32.1 */
8099
+ /** version: 2.33.0 */
7977
8100
 
7978
8101
  /*
7979
8102
  * Copyright (c) 2018, salesforce.com, inc.
@@ -8534,7 +8657,7 @@ var LWC = (function (exports) {
8534
8657
  });
8535
8658
  freeze(LightningElement);
8536
8659
  seal(LightningElement.prototype);
8537
- /* version: 2.32.1 */
8660
+ /* version: 2.33.0 */
8538
8661
 
8539
8662
  exports.LightningElement = LightningElement;
8540
8663
  exports.__unstable__ProfilerControl = profilerControl;