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