lwc 2.32.0 → 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 +898 -802
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +898 -802
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +683 -608
  5. package/dist/engine-dom/iife/es5/engine-dom.js +324 -313
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +234 -270
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +898 -802
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +683 -608
  11. package/dist/engine-dom/umd/es5/engine-dom.js +324 -313
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +234 -270
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +871 -696
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +871 -696
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +676 -909
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +676 -909
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.min.js +2 -2
  20. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +644 -882
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +89 -347
  22. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.min.js +2 -2
  23. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +89 -347
  24. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +676 -909
  25. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.min.js +2 -2
  26. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +644 -882
  27. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +89 -347
  28. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.min.js +2 -2
  29. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +89 -347
  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 @@
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',
@@ -336,89 +339,7 @@
336
339
  CACHED_ATTRIBUTE_PROPERTY_MAPPING.set(attrName, propertyName);
337
340
  return propertyName;
338
341
  }
339
- /** version: 2.32.0 */
340
-
341
- /**
342
- * Copyright (C) 2018 salesforce.com, inc.
343
- */
344
-
345
- /*
346
- * Copyright (c) 2018, salesforce.com, inc.
347
- * All rights reserved.
348
- * SPDX-License-Identifier: MIT
349
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
350
- */
351
- function detect(propName) {
352
- return getOwnPropertyDescriptor$1(Element.prototype, propName) === undefined;
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
- const nodeToAriaPropertyValuesMap = new WeakMap();
362
- function getAriaPropertyMap(elm) {
363
- let map = nodeToAriaPropertyValuesMap.get(elm);
364
- if (map === undefined) {
365
- map = {};
366
- nodeToAriaPropertyValuesMap.set(elm, map);
367
- }
368
- return map;
369
- }
370
- function getNormalizedAriaPropertyValue(value) {
371
- return value == null ? null : String(value);
372
- }
373
- function createAriaPropertyPropertyDescriptor(propName, attrName) {
374
- return {
375
- get() {
376
- const map = getAriaPropertyMap(this);
377
- if (hasOwnProperty$1.call(map, propName)) {
378
- return map[propName];
379
- }
380
- // otherwise just reflect what's in the attribute
381
- return this.hasAttribute(attrName) ? this.getAttribute(attrName) : null;
382
- },
383
- set(newValue) {
384
- const normalizedValue = getNormalizedAriaPropertyValue(newValue);
385
- const map = getAriaPropertyMap(this);
386
- map[propName] = normalizedValue;
387
- // reflect into the corresponding attribute
388
- if (newValue === null) {
389
- this.removeAttribute(attrName);
390
- }
391
- else {
392
- this.setAttribute(attrName, newValue);
393
- }
394
- },
395
- configurable: true,
396
- enumerable: true,
397
- };
398
- }
399
- function patch$1(propName) {
400
- // Typescript is inferring the wrong function type for this particular
401
- // overloaded method: https://github.com/Microsoft/TypeScript/issues/27972
402
- // @ts-ignore type-mismatch
403
- const attrName = AriaPropNameToAttrNameMap[propName];
404
- const descriptor = createAriaPropertyPropertyDescriptor(propName, attrName);
405
- Object.defineProperty(Element.prototype, propName, descriptor);
406
- }
407
-
408
- /*
409
- * Copyright (c) 2018, salesforce.com, inc.
410
- * All rights reserved.
411
- * SPDX-License-Identifier: MIT
412
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
413
- */
414
- const ElementPrototypeAriaPropertyNames = keys(AriaPropNameToAttrNameMap);
415
- for (let i = 0, len = ElementPrototypeAriaPropertyNames.length; i < len; i += 1) {
416
- const propName = ElementPrototypeAriaPropertyNames[i];
417
- if (detect(propName)) {
418
- patch$1(propName);
419
- }
420
- }
421
- /** version: 2.32.0 */
342
+ /** version: 2.33.0 */
422
343
 
423
344
  /**
424
345
  * Copyright (C) 2018 salesforce.com, inc.
@@ -432,19 +353,15 @@
432
353
  */
433
354
  const features = {
434
355
  DUMMY_TEST_FLAG: null,
435
- ENABLE_ELEMENT_PATCH: null,
436
356
  ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST: null,
437
- ENABLE_HTML_COLLECTIONS_PATCH: null,
438
- ENABLE_INNER_OUTER_TEXT_PATCH: null,
439
357
  ENABLE_MIXED_SHADOW_MODE: null,
440
358
  ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE: null,
441
- ENABLE_NODE_LIST_PATCH: null,
442
- ENABLE_NODE_PATCH: null,
443
- ENABLE_REACTIVE_SETTER: null,
444
359
  ENABLE_WIRE_SYNC_EMIT: null,
445
360
  ENABLE_LIGHT_GET_ROOT_NODE_PATCH: null,
446
361
  DISABLE_LIGHT_DOM_UNSCOPED_CSS: null,
447
362
  ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY: null,
363
+ ENABLE_FROZEN_TEMPLATE: null,
364
+ DISABLE_ARIA_REFLECTION_POLYFILL: null,
448
365
  };
449
366
  if (!_globalThis.lwcRuntimeFlags) {
450
367
  Object.defineProperty(_globalThis, 'lwcRuntimeFlags', { value: create(null) });
@@ -488,6 +405,83 @@
488
405
  */
489
406
  function setFeatureFlagForTest(name, value) {
490
407
  }
408
+ /** version: 2.33.0 */
409
+
410
+ /**
411
+ * Copyright (C) 2018 salesforce.com, inc.
412
+ */
413
+
414
+ /*
415
+ * Copyright (c) 2018, salesforce.com, inc.
416
+ * All rights reserved.
417
+ * SPDX-License-Identifier: MIT
418
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
419
+ */
420
+ function detect(propName, prototype) {
421
+ return isUndefined$1(getOwnPropertyDescriptor$1(prototype, propName));
422
+ }
423
+
424
+ /*
425
+ * Copyright (c) 2018, salesforce.com, inc.
426
+ * All rights reserved.
427
+ * SPDX-License-Identifier: MIT
428
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
429
+ */
430
+ function createAriaPropertyPropertyDescriptor(attrName) {
431
+ // Note that we need to call this.{get,set,has,remove}Attribute rather than dereferencing
432
+ // from Element.prototype, because these methods are overridden in LightningElement.
433
+ return {
434
+ get() {
435
+ // reflect what's in the attribute
436
+ return this.hasAttribute(attrName) ? this.getAttribute(attrName) : null;
437
+ },
438
+ set(newValue) {
439
+ // reflect into the corresponding attribute
440
+ if (isNull(newValue)) {
441
+ this.removeAttribute(attrName);
442
+ }
443
+ else {
444
+ this.setAttribute(attrName, newValue);
445
+ }
446
+ },
447
+ configurable: true,
448
+ enumerable: true,
449
+ };
450
+ }
451
+ function patch$1(propName, prototype) {
452
+ const attrName = AriaPropNameToAttrNameMap[propName];
453
+ const descriptor = createAriaPropertyPropertyDescriptor(attrName);
454
+ defineProperty(prototype, propName, descriptor);
455
+ }
456
+
457
+ /*
458
+ * Copyright (c) 2018, salesforce.com, inc.
459
+ * All rights reserved.
460
+ * SPDX-License-Identifier: MIT
461
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
462
+ */
463
+ function applyAriaReflection(prototype = Element.prototype) {
464
+ const ElementPrototypeAriaPropertyNames = keys(AriaPropNameToAttrNameMap);
465
+ for (let i = 0, len = ElementPrototypeAriaPropertyNames.length; i < len; i += 1) {
466
+ const propName = ElementPrototypeAriaPropertyNames[i];
467
+ if (detect(propName, prototype)) {
468
+ patch$1(propName, prototype);
469
+ }
470
+ }
471
+ }
472
+ /** version: 2.33.0 */
473
+
474
+ /*
475
+ * Copyright (c) 2018, salesforce.com, inc.
476
+ * All rights reserved.
477
+ * SPDX-License-Identifier: MIT
478
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
479
+ */
480
+ if (!lwcRuntimeFlags.DISABLE_ARIA_REFLECTION_POLYFILL) {
481
+ // If DISABLE_ARIA_REFLECTION_POLYFILL is false, then we need to apply the ARIA reflection polyfill globally,
482
+ // i.e. to the global Element.prototype
483
+ applyAriaReflection();
484
+ }
491
485
 
492
486
  /*
493
487
  * Copyright (c) 2018, salesforce.com, inc.
@@ -1394,30 +1388,35 @@
1394
1388
  * for the Base Lightning Element, it also include the reactivity bit, so the standard property is reactive.
1395
1389
  */
1396
1390
  function createBridgeToElementDescriptor(propName, descriptor) {
1397
- const { get, set, enumerable, configurable } = descriptor;
1398
- if (!isFunction$1(get)) {
1399
- throw new TypeError();
1400
- }
1401
- if (!isFunction$1(set)) {
1402
- throw new TypeError();
1391
+ const {
1392
+ get,
1393
+ set,
1394
+ enumerable,
1395
+ configurable
1396
+ } = descriptor;
1397
+ if (!isFunction$1(get)) {
1398
+ throw new TypeError();
1399
+ }
1400
+ if (!isFunction$1(set)) {
1401
+ throw new TypeError();
1402
+ }
1403
+ return {
1404
+ enumerable,
1405
+ configurable,
1406
+ get() {
1407
+ const vm = getAssociatedVM(this);
1408
+ if (isBeingConstructed(vm)) {
1409
+ return;
1410
+ }
1411
+ componentValueObserved(vm, propName);
1412
+ return get.call(vm.elm);
1413
+ },
1414
+ set(newValue) {
1415
+ const vm = getAssociatedVM(this);
1416
+ updateComponentValue(vm, propName, newValue);
1417
+ return set.call(vm.elm, newValue);
1403
1418
  }
1404
- return {
1405
- enumerable,
1406
- configurable,
1407
- get() {
1408
- const vm = getAssociatedVM(this);
1409
- if (isBeingConstructed(vm)) {
1410
- return;
1411
- }
1412
- componentValueObserved(vm, propName);
1413
- return get.call(vm.elm);
1414
- },
1415
- set(newValue) {
1416
- const vm = getAssociatedVM(this);
1417
- updateComponentValue(vm, propName, newValue);
1418
- return set.call(vm.elm, newValue);
1419
- },
1420
- };
1419
+ };
1421
1420
  }
1422
1421
  const EMPTY_REFS = freeze(create(null));
1423
1422
  const refsCache = new WeakMap();
@@ -1427,262 +1426,361 @@
1427
1426
  **/
1428
1427
  // @ts-ignore
1429
1428
  const LightningElement = function () {
1430
- // This should be as performant as possible, while any initialization should be done lazily
1431
- if (isNull(vmBeingConstructed)) {
1432
- // Thrown when doing something like `new LightningElement()` or
1433
- // `class Foo extends LightningElement {}; new Foo()`
1434
- throw new TypeError('Illegal constructor');
1435
- }
1436
- const vm = vmBeingConstructed;
1437
- const { def, elm } = vm;
1438
- const { bridge } = def;
1439
- const component = this;
1440
- setPrototypeOf(elm, bridge.prototype);
1441
- vm.component = this;
1442
- // Locker hooks assignment. When the LWC engine run with Locker, Locker intercepts all the new
1443
- // component creation and passes hooks to instrument all the component interactions with the
1444
- // engine. We are intentionally hiding this argument from the formal API of LightningElement
1445
- // because we don't want folks to know about it just yet.
1446
- if (arguments.length === 1) {
1447
- const { callHook, setHook, getHook } = arguments[0];
1448
- vm.callHook = callHook;
1449
- vm.setHook = setHook;
1450
- vm.getHook = getHook;
1451
- }
1452
- markLockerLiveObject(this);
1453
- // Linking elm, shadow root and component with the VM.
1454
- associateVM(component, vm);
1455
- associateVM(elm, vm);
1456
- if (vm.renderMode === 1 /* RenderMode.Shadow */) {
1457
- vm.renderRoot = doAttachShadow(vm);
1458
- }
1459
- else {
1460
- vm.renderRoot = elm;
1461
- }
1462
- return this;
1429
+ // This should be as performant as possible, while any initialization should be done lazily
1430
+ if (isNull(vmBeingConstructed)) {
1431
+ // Thrown when doing something like `new LightningElement()` or
1432
+ // `class Foo extends LightningElement {}; new Foo()`
1433
+ throw new TypeError('Illegal constructor');
1434
+ }
1435
+ const vm = vmBeingConstructed;
1436
+ const {
1437
+ def,
1438
+ elm
1439
+ } = vm;
1440
+ const {
1441
+ bridge
1442
+ } = def;
1443
+ const component = this;
1444
+ setPrototypeOf(elm, bridge.prototype);
1445
+ vm.component = this;
1446
+ // Locker hooks assignment. When the LWC engine run with Locker, Locker intercepts all the new
1447
+ // component creation and passes hooks to instrument all the component interactions with the
1448
+ // engine. We are intentionally hiding this argument from the formal API of LightningElement
1449
+ // because we don't want folks to know about it just yet.
1450
+ if (arguments.length === 1) {
1451
+ const {
1452
+ callHook,
1453
+ setHook,
1454
+ getHook
1455
+ } = arguments[0];
1456
+ vm.callHook = callHook;
1457
+ vm.setHook = setHook;
1458
+ vm.getHook = getHook;
1459
+ }
1460
+ markLockerLiveObject(this);
1461
+ // Linking elm, shadow root and component with the VM.
1462
+ associateVM(component, vm);
1463
+ associateVM(elm, vm);
1464
+ if (vm.renderMode === 1 /* RenderMode.Shadow */) {
1465
+ vm.renderRoot = doAttachShadow(vm);
1466
+ } else {
1467
+ vm.renderRoot = elm;
1468
+ }
1469
+ return this;
1463
1470
  };
1464
1471
  function doAttachShadow(vm) {
1465
- const { elm, mode, shadowMode, def: { ctor }, renderer: { attachShadow }, } = vm;
1466
- const shadowRoot = attachShadow(elm, {
1467
- [KEY__SYNTHETIC_MODE]: shadowMode === 1 /* ShadowMode.Synthetic */,
1468
- delegatesFocus: Boolean(ctor.delegatesFocus),
1469
- mode,
1470
- });
1471
- vm.shadowRoot = shadowRoot;
1472
- associateVM(shadowRoot, vm);
1473
- return shadowRoot;
1472
+ const {
1473
+ elm,
1474
+ mode,
1475
+ shadowMode,
1476
+ def: {
1477
+ ctor
1478
+ },
1479
+ renderer: {
1480
+ attachShadow
1481
+ }
1482
+ } = vm;
1483
+ const shadowRoot = attachShadow(elm, {
1484
+ [KEY__SYNTHETIC_MODE]: shadowMode === 1 /* ShadowMode.Synthetic */,
1485
+ delegatesFocus: Boolean(ctor.delegatesFocus),
1486
+ mode
1487
+ });
1488
+ vm.shadowRoot = shadowRoot;
1489
+ associateVM(shadowRoot, vm);
1490
+ return shadowRoot;
1474
1491
  }
1475
1492
  // @ts-ignore
1476
1493
  LightningElement.prototype = {
1477
- constructor: LightningElement,
1478
- dispatchEvent(event) {
1479
- const vm = getAssociatedVM(this);
1480
- const { elm, renderer: { dispatchEvent }, } = vm;
1481
- return dispatchEvent(elm, event);
1482
- },
1483
- addEventListener(type, listener, options) {
1484
- const vm = getAssociatedVM(this);
1485
- const { elm, renderer: { addEventListener }, } = vm;
1486
- const wrappedListener = getWrappedComponentsListener(vm, listener);
1487
- addEventListener(elm, type, wrappedListener, options);
1488
- },
1489
- removeEventListener(type, listener, options) {
1490
- const vm = getAssociatedVM(this);
1491
- const { elm, renderer: { removeEventListener }, } = vm;
1492
- const wrappedListener = getWrappedComponentsListener(vm, listener);
1493
- removeEventListener(elm, type, wrappedListener, options);
1494
- },
1495
- hasAttribute(name) {
1496
- const vm = getAssociatedVM(this);
1497
- const { elm, renderer: { getAttribute }, } = vm;
1498
- return !isNull(getAttribute(elm, name));
1499
- },
1500
- hasAttributeNS(namespace, name) {
1501
- const vm = getAssociatedVM(this);
1502
- const { elm, renderer: { getAttribute }, } = vm;
1503
- return !isNull(getAttribute(elm, name, namespace));
1504
- },
1505
- removeAttribute(name) {
1506
- const vm = getAssociatedVM(this);
1507
- const { elm, renderer: { removeAttribute }, } = vm;
1508
- unlockAttribute(elm, name);
1509
- removeAttribute(elm, name);
1510
- lockAttribute();
1511
- },
1512
- removeAttributeNS(namespace, name) {
1513
- const { elm, renderer: { removeAttribute }, } = getAssociatedVM(this);
1514
- unlockAttribute(elm, name);
1515
- removeAttribute(elm, name, namespace);
1516
- lockAttribute();
1517
- },
1518
- getAttribute(name) {
1519
- const vm = getAssociatedVM(this);
1520
- const { elm } = vm;
1521
- const { getAttribute } = vm.renderer;
1522
- return getAttribute(elm, name);
1523
- },
1524
- getAttributeNS(namespace, name) {
1525
- const vm = getAssociatedVM(this);
1526
- const { elm } = vm;
1527
- const { getAttribute } = vm.renderer;
1528
- return getAttribute(elm, name, namespace);
1529
- },
1530
- setAttribute(name, value) {
1531
- const vm = getAssociatedVM(this);
1532
- const { elm, renderer: { setAttribute }, } = vm;
1533
- unlockAttribute(elm, name);
1534
- setAttribute(elm, name, value);
1535
- lockAttribute();
1536
- },
1537
- setAttributeNS(namespace, name, value) {
1538
- const vm = getAssociatedVM(this);
1539
- const { elm, renderer: { setAttribute }, } = vm;
1540
- unlockAttribute(elm, name);
1541
- setAttribute(elm, name, value, namespace);
1542
- lockAttribute();
1543
- },
1544
- getBoundingClientRect() {
1545
- const vm = getAssociatedVM(this);
1546
- const { elm, renderer: { getBoundingClientRect }, } = vm;
1547
- return getBoundingClientRect(elm);
1548
- },
1549
- get isConnected() {
1550
- const vm = getAssociatedVM(this);
1551
- const { elm, renderer: { isConnected }, } = vm;
1552
- return isConnected(elm);
1553
- },
1554
- get classList() {
1555
- const vm = getAssociatedVM(this);
1556
- const { elm, renderer: { getClassList }, } = vm;
1557
- return getClassList(elm);
1558
- },
1559
- get template() {
1560
- const vm = getAssociatedVM(this);
1561
- return vm.shadowRoot;
1562
- },
1563
- get refs() {
1564
- const vm = getAssociatedVM(this);
1565
- if (isUpdatingTemplate) {
1566
- // If the template is in the process of being updated, then we don't want to go through the normal
1567
- // process of returning the refs and caching them, because the state of the refs is unstable.
1568
- // This can happen if e.g. a template contains `<div class={foo}></div>` and `foo` is computed
1569
- // based on `this.refs.bar`.
1570
- return;
1571
- }
1572
- const { refVNodes, hasRefVNodes, cmpTemplate } = vm;
1573
- // For backwards compatibility with component written before template refs
1574
- // were introduced, we return undefined if the template has no refs defined
1575
- // anywhere. This fixes components that may want to add an expando called `refs`
1576
- // and are checking if it exists with `if (this.refs)` before adding it.
1577
- // Note it is not sufficient to just check if `refVNodes` is null or empty,
1578
- // because a template may have `lwc:ref` defined within a falsy `if:true` block.
1579
- if (!hasRefVNodes) {
1580
- return;
1581
- }
1582
- // For templates that are using `lwc:ref`, if there are no refs currently available
1583
- // (e.g. refs inside of a falsy `if:true` block), we return an empty object.
1584
- if (isNull(refVNodes)) {
1585
- return EMPTY_REFS;
1586
- }
1587
- // The refNodes can be cached based on the refVNodes, since the refVNodes
1588
- // are recreated from scratch every time the template is rendered.
1589
- // This happens with `vm.refVNodes = null` in `template.ts` in `@lwc/engine-core`.
1590
- let refs = refsCache.get(refVNodes);
1591
- if (isUndefined$1(refs)) {
1592
- refs = create(null);
1593
- for (const key of keys(refVNodes)) {
1594
- refs[key] = refVNodes[key].elm;
1595
- }
1596
- freeze(refs);
1597
- refsCache.set(refVNodes, refs);
1598
- }
1599
- return refs;
1600
- },
1601
- // For backwards compat, we allow component authors to set `refs` as an expando
1602
- set refs(value) {
1603
- defineProperty(this, 'refs', {
1604
- configurable: true,
1605
- enumerable: true,
1606
- writable: true,
1607
- value,
1608
- });
1609
- },
1610
- get shadowRoot() {
1611
- // From within the component instance, the shadowRoot is always reported as "closed".
1612
- // Authors should rely on this.template instead.
1613
- return null;
1614
- },
1615
- get children() {
1616
- const vm = getAssociatedVM(this);
1617
- const renderer = vm.renderer;
1618
- return renderer.getChildren(vm.elm);
1619
- },
1620
- get childNodes() {
1621
- const vm = getAssociatedVM(this);
1622
- const renderer = vm.renderer;
1623
- return renderer.getChildNodes(vm.elm);
1624
- },
1625
- get firstChild() {
1626
- const vm = getAssociatedVM(this);
1627
- const renderer = vm.renderer;
1628
- return renderer.getFirstChild(vm.elm);
1629
- },
1630
- get firstElementChild() {
1631
- const vm = getAssociatedVM(this);
1632
- const renderer = vm.renderer;
1633
- return renderer.getFirstElementChild(vm.elm);
1634
- },
1635
- get lastChild() {
1636
- const vm = getAssociatedVM(this);
1637
- const renderer = vm.renderer;
1638
- return renderer.getLastChild(vm.elm);
1639
- },
1640
- get lastElementChild() {
1641
- const vm = getAssociatedVM(this);
1642
- const renderer = vm.renderer;
1643
- return renderer.getLastElementChild(vm.elm);
1644
- },
1645
- render() {
1646
- const vm = getAssociatedVM(this);
1647
- return vm.def.template;
1648
- },
1649
- toString() {
1650
- const vm = getAssociatedVM(this);
1651
- return `[object ${vm.def.name}]`;
1652
- },
1494
+ constructor: LightningElement,
1495
+ dispatchEvent(event) {
1496
+ const vm = getAssociatedVM(this);
1497
+ const {
1498
+ elm,
1499
+ renderer: {
1500
+ dispatchEvent
1501
+ }
1502
+ } = vm;
1503
+ return dispatchEvent(elm, event);
1504
+ },
1505
+ addEventListener(type, listener, options) {
1506
+ const vm = getAssociatedVM(this);
1507
+ const {
1508
+ elm,
1509
+ renderer: {
1510
+ addEventListener
1511
+ }
1512
+ } = vm;
1513
+ const wrappedListener = getWrappedComponentsListener(vm, listener);
1514
+ addEventListener(elm, type, wrappedListener, options);
1515
+ },
1516
+ removeEventListener(type, listener, options) {
1517
+ const vm = getAssociatedVM(this);
1518
+ const {
1519
+ elm,
1520
+ renderer: {
1521
+ removeEventListener
1522
+ }
1523
+ } = vm;
1524
+ const wrappedListener = getWrappedComponentsListener(vm, listener);
1525
+ removeEventListener(elm, type, wrappedListener, options);
1526
+ },
1527
+ hasAttribute(name) {
1528
+ const vm = getAssociatedVM(this);
1529
+ const {
1530
+ elm,
1531
+ renderer: {
1532
+ getAttribute
1533
+ }
1534
+ } = vm;
1535
+ return !isNull(getAttribute(elm, name));
1536
+ },
1537
+ hasAttributeNS(namespace, name) {
1538
+ const vm = getAssociatedVM(this);
1539
+ const {
1540
+ elm,
1541
+ renderer: {
1542
+ getAttribute
1543
+ }
1544
+ } = vm;
1545
+ return !isNull(getAttribute(elm, name, namespace));
1546
+ },
1547
+ removeAttribute(name) {
1548
+ const vm = getAssociatedVM(this);
1549
+ const {
1550
+ elm,
1551
+ renderer: {
1552
+ removeAttribute
1553
+ }
1554
+ } = vm;
1555
+ unlockAttribute(elm, name);
1556
+ removeAttribute(elm, name);
1557
+ lockAttribute();
1558
+ },
1559
+ removeAttributeNS(namespace, name) {
1560
+ const {
1561
+ elm,
1562
+ renderer: {
1563
+ removeAttribute
1564
+ }
1565
+ } = getAssociatedVM(this);
1566
+ unlockAttribute(elm, name);
1567
+ removeAttribute(elm, name, namespace);
1568
+ lockAttribute();
1569
+ },
1570
+ getAttribute(name) {
1571
+ const vm = getAssociatedVM(this);
1572
+ const {
1573
+ elm
1574
+ } = vm;
1575
+ const {
1576
+ getAttribute
1577
+ } = vm.renderer;
1578
+ return getAttribute(elm, name);
1579
+ },
1580
+ getAttributeNS(namespace, name) {
1581
+ const vm = getAssociatedVM(this);
1582
+ const {
1583
+ elm
1584
+ } = vm;
1585
+ const {
1586
+ getAttribute
1587
+ } = vm.renderer;
1588
+ return getAttribute(elm, name, namespace);
1589
+ },
1590
+ setAttribute(name, value) {
1591
+ const vm = getAssociatedVM(this);
1592
+ const {
1593
+ elm,
1594
+ renderer: {
1595
+ setAttribute
1596
+ }
1597
+ } = vm;
1598
+ unlockAttribute(elm, name);
1599
+ setAttribute(elm, name, value);
1600
+ lockAttribute();
1601
+ },
1602
+ setAttributeNS(namespace, name, value) {
1603
+ const vm = getAssociatedVM(this);
1604
+ const {
1605
+ elm,
1606
+ renderer: {
1607
+ setAttribute
1608
+ }
1609
+ } = vm;
1610
+ unlockAttribute(elm, name);
1611
+ setAttribute(elm, name, value, namespace);
1612
+ lockAttribute();
1613
+ },
1614
+ getBoundingClientRect() {
1615
+ const vm = getAssociatedVM(this);
1616
+ const {
1617
+ elm,
1618
+ renderer: {
1619
+ getBoundingClientRect
1620
+ }
1621
+ } = vm;
1622
+ return getBoundingClientRect(elm);
1623
+ },
1624
+ get isConnected() {
1625
+ const vm = getAssociatedVM(this);
1626
+ const {
1627
+ elm,
1628
+ renderer: {
1629
+ isConnected
1630
+ }
1631
+ } = vm;
1632
+ return isConnected(elm);
1633
+ },
1634
+ get classList() {
1635
+ const vm = getAssociatedVM(this);
1636
+ const {
1637
+ elm,
1638
+ renderer: {
1639
+ getClassList
1640
+ }
1641
+ } = vm;
1642
+ return getClassList(elm);
1643
+ },
1644
+ get template() {
1645
+ const vm = getAssociatedVM(this);
1646
+ return vm.shadowRoot;
1647
+ },
1648
+ get refs() {
1649
+ const vm = getAssociatedVM(this);
1650
+ if (isUpdatingTemplate) {
1651
+ // If the template is in the process of being updated, then we don't want to go through the normal
1652
+ // process of returning the refs and caching them, because the state of the refs is unstable.
1653
+ // This can happen if e.g. a template contains `<div class={foo}></div>` and `foo` is computed
1654
+ // based on `this.refs.bar`.
1655
+ return;
1656
+ }
1657
+ const {
1658
+ refVNodes,
1659
+ hasRefVNodes,
1660
+ cmpTemplate
1661
+ } = vm;
1662
+ // For backwards compatibility with component written before template refs
1663
+ // were introduced, we return undefined if the template has no refs defined
1664
+ // anywhere. This fixes components that may want to add an expando called `refs`
1665
+ // and are checking if it exists with `if (this.refs)` before adding it.
1666
+ // Note it is not sufficient to just check if `refVNodes` is null or empty,
1667
+ // because a template may have `lwc:ref` defined within a falsy `if:true` block.
1668
+ if (!hasRefVNodes) {
1669
+ return;
1670
+ }
1671
+ // For templates that are using `lwc:ref`, if there are no refs currently available
1672
+ // (e.g. refs inside of a falsy `if:true` block), we return an empty object.
1673
+ if (isNull(refVNodes)) {
1674
+ return EMPTY_REFS;
1675
+ }
1676
+ // The refNodes can be cached based on the refVNodes, since the refVNodes
1677
+ // are recreated from scratch every time the template is rendered.
1678
+ // This happens with `vm.refVNodes = null` in `template.ts` in `@lwc/engine-core`.
1679
+ let refs = refsCache.get(refVNodes);
1680
+ if (isUndefined$1(refs)) {
1681
+ refs = create(null);
1682
+ for (const key of keys(refVNodes)) {
1683
+ refs[key] = refVNodes[key].elm;
1684
+ }
1685
+ freeze(refs);
1686
+ refsCache.set(refVNodes, refs);
1687
+ }
1688
+ return refs;
1689
+ },
1690
+ // For backwards compat, we allow component authors to set `refs` as an expando
1691
+ set refs(value) {
1692
+ defineProperty(this, 'refs', {
1693
+ configurable: true,
1694
+ enumerable: true,
1695
+ writable: true,
1696
+ value
1697
+ });
1698
+ },
1699
+ get shadowRoot() {
1700
+ // From within the component instance, the shadowRoot is always reported as "closed".
1701
+ // Authors should rely on this.template instead.
1702
+ return null;
1703
+ },
1704
+ get children() {
1705
+ const vm = getAssociatedVM(this);
1706
+ const renderer = vm.renderer;
1707
+ return renderer.getChildren(vm.elm);
1708
+ },
1709
+ get childNodes() {
1710
+ const vm = getAssociatedVM(this);
1711
+ const renderer = vm.renderer;
1712
+ return renderer.getChildNodes(vm.elm);
1713
+ },
1714
+ get firstChild() {
1715
+ const vm = getAssociatedVM(this);
1716
+ const renderer = vm.renderer;
1717
+ return renderer.getFirstChild(vm.elm);
1718
+ },
1719
+ get firstElementChild() {
1720
+ const vm = getAssociatedVM(this);
1721
+ const renderer = vm.renderer;
1722
+ return renderer.getFirstElementChild(vm.elm);
1723
+ },
1724
+ get lastChild() {
1725
+ const vm = getAssociatedVM(this);
1726
+ const renderer = vm.renderer;
1727
+ return renderer.getLastChild(vm.elm);
1728
+ },
1729
+ get lastElementChild() {
1730
+ const vm = getAssociatedVM(this);
1731
+ const renderer = vm.renderer;
1732
+ return renderer.getLastElementChild(vm.elm);
1733
+ },
1734
+ render() {
1735
+ const vm = getAssociatedVM(this);
1736
+ return vm.def.template;
1737
+ },
1738
+ toString() {
1739
+ const vm = getAssociatedVM(this);
1740
+ return `[object ${vm.def.name}]`;
1741
+ }
1653
1742
  };
1654
1743
  const queryAndChildGetterDescriptors = create(null);
1655
- const queryMethods = [
1656
- 'getElementsByClassName',
1657
- 'getElementsByTagName',
1658
- 'querySelector',
1659
- 'querySelectorAll',
1660
- ];
1744
+ const queryMethods = ['getElementsByClassName', 'getElementsByTagName', 'querySelector', 'querySelectorAll'];
1661
1745
  // Generic passthrough for query APIs on HTMLElement to the relevant Renderer APIs
1662
1746
  for (const queryMethod of queryMethods) {
1663
- queryAndChildGetterDescriptors[queryMethod] = {
1664
- value(arg) {
1665
- const vm = getAssociatedVM(this);
1666
- const { elm, renderer } = vm;
1667
- return renderer[queryMethod](elm, arg);
1668
- },
1669
- configurable: true,
1670
- enumerable: true,
1671
- writable: true,
1672
- };
1747
+ queryAndChildGetterDescriptors[queryMethod] = {
1748
+ value(arg) {
1749
+ const vm = getAssociatedVM(this);
1750
+ const {
1751
+ elm,
1752
+ renderer
1753
+ } = vm;
1754
+ return renderer[queryMethod](elm, arg);
1755
+ },
1756
+ configurable: true,
1757
+ enumerable: true,
1758
+ writable: true
1759
+ };
1673
1760
  }
1674
1761
  defineProperties(LightningElement.prototype, queryAndChildGetterDescriptors);
1675
1762
  const lightningBasedDescriptors = create(null);
1676
1763
  for (const propName in HTMLElementOriginalDescriptors) {
1677
- lightningBasedDescriptors[propName] = createBridgeToElementDescriptor(propName, HTMLElementOriginalDescriptors[propName]);
1764
+ lightningBasedDescriptors[propName] = createBridgeToElementDescriptor(propName, HTMLElementOriginalDescriptors[propName]);
1678
1765
  }
1679
1766
  defineProperties(LightningElement.prototype, lightningBasedDescriptors);
1767
+ function applyAriaReflectionToLightningElement() {
1768
+ // If ARIA reflection is not applied globally to Element.prototype, or if we are running server-side,
1769
+ // apply it to LightningElement.prototype.
1770
+ // This allows `this.aria*` property accessors to work from inside a component, and to reflect `aria-*` attrs.
1771
+ applyAriaReflection(LightningElement.prototype);
1772
+ }
1773
+ // The reason for this odd if/else branching is limitations in @lwc/features:
1774
+ // https://github.com/salesforce/lwc/blob/master/packages/%40lwc/features/README.md#only-works-with-if-statements
1775
+ if (lwcRuntimeFlags.DISABLE_ARIA_REFLECTION_POLYFILL) {
1776
+ applyAriaReflectionToLightningElement();
1777
+ }
1680
1778
  defineProperty(LightningElement, 'CustomElementConstructor', {
1681
- get() {
1682
- // If required, a runtime-specific implementation must be defined.
1683
- throw new ReferenceError('The current runtime does not support CustomElementConstructor.');
1684
- },
1685
- configurable: true,
1779
+ get() {
1780
+ // If required, a runtime-specific implementation must be defined.
1781
+ throw new ReferenceError('The current runtime does not support CustomElementConstructor.');
1782
+ },
1783
+ configurable: true
1686
1784
  });
1687
1785
 
1688
1786
  function createObservedFieldPropertyDescriptor(key) {
@@ -1700,45 +1798,6 @@
1700
1798
  configurable: true,
1701
1799
  };
1702
1800
  }
1703
- class AccessorReactiveObserver extends ReactiveObserver {
1704
- constructor(vm, set) {
1705
- super(() => {
1706
- if (isFalse(this.debouncing)) {
1707
- this.debouncing = true;
1708
- addCallbackToNextTick(() => {
1709
- if (isTrue(this.debouncing)) {
1710
- const { value } = this;
1711
- const { isDirty: dirtyStateBeforeSetterCall, component, idx } = vm;
1712
- set.call(component, value);
1713
- // de-bouncing after the call to the original setter to prevent
1714
- // infinity loop if the setter itself is mutating things that
1715
- // were accessed during the previous invocation.
1716
- this.debouncing = false;
1717
- if (isTrue(vm.isDirty) && isFalse(dirtyStateBeforeSetterCall) && idx > 0) {
1718
- // immediate rehydration due to a setter driven mutation, otherwise
1719
- // the component will get rendered on the second tick, which it is not
1720
- // desirable.
1721
- rerenderVM(vm);
1722
- }
1723
- }
1724
- });
1725
- }
1726
- });
1727
- this.debouncing = false;
1728
- }
1729
- reset(value) {
1730
- super.reset();
1731
- this.debouncing = false;
1732
- if (arguments.length > 0) {
1733
- this.value = value;
1734
- }
1735
- }
1736
- }
1737
- function createAccessorReactiveObserver(vm, set) {
1738
- // On the server side, we don't need mutation tracking. Skipping it improves performance.
1739
- return new AccessorReactiveObserver(vm, set)
1740
- ;
1741
- }
1742
1801
 
1743
1802
  /*
1744
1803
  * Copyright (c) 2018, salesforce.com, inc.
@@ -1747,65 +1806,45 @@
1747
1806
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1748
1807
  */
1749
1808
  function api$1() {
1750
- throw new Error();
1809
+ throw new Error();
1751
1810
  }
1752
1811
  function createPublicPropertyDescriptor(key) {
1753
- return {
1754
- get() {
1755
- const vm = getAssociatedVM(this);
1756
- if (isBeingConstructed(vm)) {
1757
- return;
1758
- }
1759
- componentValueObserved(vm, key);
1760
- return vm.cmpProps[key];
1761
- },
1762
- set(newValue) {
1763
- const vm = getAssociatedVM(this);
1764
- vm.cmpProps[key] = newValue;
1765
- componentValueMutated(vm, key);
1766
- },
1767
- enumerable: true,
1768
- configurable: true
1769
- };
1812
+ return {
1813
+ get() {
1814
+ const vm = getAssociatedVM(this);
1815
+ if (isBeingConstructed(vm)) {
1816
+ return;
1817
+ }
1818
+ componentValueObserved(vm, key);
1819
+ return vm.cmpProps[key];
1820
+ },
1821
+ set(newValue) {
1822
+ const vm = getAssociatedVM(this);
1823
+ vm.cmpProps[key] = newValue;
1824
+ componentValueMutated(vm, key);
1825
+ },
1826
+ enumerable: true,
1827
+ configurable: true,
1828
+ };
1770
1829
  }
1771
1830
  function createPublicAccessorDescriptor(key, descriptor) {
1772
- const {
1773
- get,
1774
- set,
1775
- enumerable,
1776
- configurable
1777
- } = descriptor;
1778
- if (!isFunction$1(get)) {
1779
- throw new Error();
1780
- }
1781
- return {
1782
- get() {
1783
- return get.call(this);
1784
- },
1785
- set(newValue) {
1786
- const vm = getAssociatedVM(this);
1787
- if (set) {
1788
- if (lwcRuntimeFlags.ENABLE_REACTIVE_SETTER) {
1789
- let ro = vm.oar[key];
1790
- if (isUndefined$1(ro)) {
1791
- ro = vm.oar[key] = createAccessorReactiveObserver(vm, set);
1792
- }
1793
- // every time we invoke this setter from outside (through this wrapper setter)
1794
- // we should reset the value and then debounce just in case there is a pending
1795
- // invocation the next tick that is not longer relevant since the value is changing
1796
- // from outside.
1797
- ro.reset(newValue);
1798
- ro.observe(() => {
1799
- set.call(this, newValue);
1800
- });
1801
- } else {
1802
- set.call(this, newValue);
1803
- }
1804
- }
1805
- },
1806
- enumerable,
1807
- configurable
1808
- };
1831
+ const { get, set, enumerable, configurable } = descriptor;
1832
+ if (!isFunction$1(get)) {
1833
+ throw new Error();
1834
+ }
1835
+ return {
1836
+ get() {
1837
+ return get.call(this);
1838
+ },
1839
+ set(newValue) {
1840
+ getAssociatedVM(this);
1841
+ if (set) {
1842
+ set.call(this, newValue);
1843
+ }
1844
+ },
1845
+ enumerable,
1846
+ configurable,
1847
+ };
1809
1848
  }
1810
1849
 
1811
1850
  /*
@@ -1987,12 +2026,6 @@
1987
2026
  return isUndefined$1(meta) ? defaultMeta : meta;
1988
2027
  }
1989
2028
 
1990
- /*
1991
- * Copyright (c) 2018, salesforce.com, inc.
1992
- * All rights reserved.
1993
- * SPDX-License-Identifier: MIT
1994
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1995
- */
1996
2029
  const signedTemplateSet = new Set();
1997
2030
  function defaultEmptyTemplate() {
1998
2031
  return [];
@@ -2007,32 +2040,6 @@
2007
2040
  */
2008
2041
  function registerTemplate(tpl) {
2009
2042
  signedTemplateSet.add(tpl);
2010
- // FIXME[@W-10950976]: the template object should be frozen, and it should not be possible to set
2011
- // the stylesheets or stylesheetToken(s). For backwards compat, though, we shim stylesheetTokens
2012
- // on top of stylesheetToken for anyone who is accessing the old internal API.
2013
- // Details: https://salesforce.quip.com/v1rmAFu2cKAr
2014
- defineProperty(tpl, 'stylesheetTokens', {
2015
- enumerable: true,
2016
- configurable: true,
2017
- get() {
2018
- const { stylesheetToken } = this;
2019
- if (isUndefined$1(stylesheetToken)) {
2020
- return stylesheetToken;
2021
- }
2022
- // Shim for the old `stylesheetTokens` property
2023
- // See https://github.com/salesforce/lwc/pull/2332/files#diff-7901555acef29969adaa6583185b3e9bce475cdc6f23e799a54e0018cb18abaa
2024
- return {
2025
- hostAttribute: `${stylesheetToken}-host`,
2026
- shadowAttribute: stylesheetToken,
2027
- };
2028
- },
2029
- set(value) {
2030
- // If the value is null or some other exotic object, you would be broken anyway in the past
2031
- // because the engine would try to access hostAttribute/shadowAttribute, which would throw an error.
2032
- // However it may be undefined in newer versions of LWC, so we need to guard against that case.
2033
- this.stylesheetToken = isUndefined$1(value) ? undefined : value.shadowAttribute;
2034
- },
2035
- });
2036
2043
  // chaining this method as a way to wrap existing
2037
2044
  // assignment of templates easily, without too much transformation
2038
2045
  return tpl;
@@ -2060,138 +2067,161 @@
2060
2067
  const cachedGetterByKey = create(null);
2061
2068
  const cachedSetterByKey = create(null);
2062
2069
  function createGetter(key) {
2063
- let fn = cachedGetterByKey[key];
2064
- if (isUndefined$1(fn)) {
2065
- fn = cachedGetterByKey[key] = function () {
2066
- const vm = getAssociatedVM(this);
2067
- const { getHook } = vm;
2068
- return getHook(vm.component, key);
2069
- };
2070
- }
2071
- return fn;
2070
+ let fn = cachedGetterByKey[key];
2071
+ if (isUndefined$1(fn)) {
2072
+ fn = cachedGetterByKey[key] = function () {
2073
+ const vm = getAssociatedVM(this);
2074
+ const {
2075
+ getHook
2076
+ } = vm;
2077
+ return getHook(vm.component, key);
2078
+ };
2079
+ }
2080
+ return fn;
2072
2081
  }
2073
2082
  function createSetter(key) {
2074
- let fn = cachedSetterByKey[key];
2075
- if (isUndefined$1(fn)) {
2076
- fn = cachedSetterByKey[key] = function (newValue) {
2077
- const vm = getAssociatedVM(this);
2078
- const { setHook } = vm;
2079
- newValue = getReadOnlyProxy(newValue);
2080
- setHook(vm.component, key, newValue);
2081
- };
2082
- }
2083
- return fn;
2083
+ let fn = cachedSetterByKey[key];
2084
+ if (isUndefined$1(fn)) {
2085
+ fn = cachedSetterByKey[key] = function (newValue) {
2086
+ const vm = getAssociatedVM(this);
2087
+ const {
2088
+ setHook
2089
+ } = vm;
2090
+ newValue = getReadOnlyProxy(newValue);
2091
+ setHook(vm.component, key, newValue);
2092
+ };
2093
+ }
2094
+ return fn;
2084
2095
  }
2085
2096
  function createMethodCaller(methodName) {
2086
- return function () {
2087
- const vm = getAssociatedVM(this);
2088
- const { callHook, component } = vm;
2089
- const fn = component[methodName];
2090
- return callHook(vm.component, fn, ArraySlice.call(arguments));
2091
- };
2097
+ return function () {
2098
+ const vm = getAssociatedVM(this);
2099
+ const {
2100
+ callHook,
2101
+ component
2102
+ } = vm;
2103
+ const fn = component[methodName];
2104
+ return callHook(vm.component, fn, ArraySlice.call(arguments));
2105
+ };
2092
2106
  }
2093
2107
  function createAttributeChangedCallback(attributeToPropMap, superAttributeChangedCallback) {
2094
- return function attributeChangedCallback(attrName, oldValue, newValue) {
2095
- if (oldValue === newValue) {
2096
- // Ignore same values.
2097
- return;
2098
- }
2099
- const propName = attributeToPropMap[attrName];
2100
- if (isUndefined$1(propName)) {
2101
- if (!isUndefined$1(superAttributeChangedCallback)) {
2102
- // delegate unknown attributes to the super.
2103
- // Typescript does not like it when you treat the `arguments` object as an array
2104
- // @ts-ignore type-mismatch
2105
- superAttributeChangedCallback.apply(this, arguments);
2106
- }
2107
- return;
2108
- }
2109
- if (!isAttributeLocked(this, attrName)) {
2110
- // Ignore changes triggered by the engine itself during:
2111
- // * diffing when public props are attempting to reflect to the DOM
2112
- // * component via `this.setAttribute()`, should never update the prop
2113
- // Both cases, the setAttribute call is always wrapped by the unlocking of the
2114
- // attribute to be changed
2115
- return;
2116
- }
2117
- // Reflect attribute change to the corresponding property when changed from outside.
2118
- this[propName] = newValue;
2119
- };
2120
- }
2121
- function HTMLBridgeElementFactory(SuperClass, props, methods) {
2122
- let HTMLBridgeElement;
2123
- /**
2124
- * Modern browsers will have all Native Constructors as regular Classes
2125
- * and must be instantiated with the new keyword. In older browsers,
2126
- * specifically IE11, those are objects with a prototype property defined,
2127
- * since they are not supposed to be extended or instantiated with the
2128
- * new keyword. This forking logic supports both cases, specifically because
2129
- * wc.ts relies on the construction path of the bridges to create new
2130
- * fully qualifying web components.
2131
- */
2132
- if (isFunction$1(SuperClass)) {
2133
- HTMLBridgeElement = class extends SuperClass {
2134
- };
2135
- }
2136
- else {
2137
- HTMLBridgeElement = function () {
2138
- // Bridge classes are not supposed to be instantiated directly in
2139
- // browsers that do not support web components.
2140
- throw new TypeError('Illegal constructor');
2141
- };
2142
- // prototype inheritance dance
2143
- setPrototypeOf(HTMLBridgeElement, SuperClass);
2144
- setPrototypeOf(HTMLBridgeElement.prototype, SuperClass.prototype);
2145
- defineProperty(HTMLBridgeElement.prototype, 'constructor', {
2146
- writable: true,
2147
- configurable: true,
2148
- value: HTMLBridgeElement,
2149
- });
2108
+ return function attributeChangedCallback(attrName, oldValue, newValue) {
2109
+ if (oldValue === newValue) {
2110
+ // Ignore same values.
2111
+ return;
2150
2112
  }
2151
- // generating the hash table for attributes to avoid duplicate fields and facilitate validation
2152
- // and false positives in case of inheritance.
2153
- const attributeToPropMap = create(null);
2154
- const { attributeChangedCallback: superAttributeChangedCallback } = SuperClass.prototype;
2155
- const { observedAttributes: superObservedAttributes = [] } = SuperClass;
2156
- const descriptors = create(null);
2157
- // expose getters and setters for each public props on the new Element Bridge
2158
- for (let i = 0, len = props.length; i < len; i += 1) {
2159
- const propName = props[i];
2160
- attributeToPropMap[htmlPropertyToAttribute(propName)] = propName;
2161
- descriptors[propName] = {
2162
- get: createGetter(propName),
2163
- set: createSetter(propName),
2164
- enumerable: true,
2165
- configurable: true,
2166
- };
2113
+ const propName = attributeToPropMap[attrName];
2114
+ if (isUndefined$1(propName)) {
2115
+ if (!isUndefined$1(superAttributeChangedCallback)) {
2116
+ // delegate unknown attributes to the super.
2117
+ // Typescript does not like it when you treat the `arguments` object as an array
2118
+ // @ts-ignore type-mismatch
2119
+ superAttributeChangedCallback.apply(this, arguments);
2120
+ }
2121
+ return;
2167
2122
  }
2168
- // expose public methods as props on the new Element Bridge
2169
- for (let i = 0, len = methods.length; i < len; i += 1) {
2170
- const methodName = methods[i];
2171
- descriptors[methodName] = {
2172
- value: createMethodCaller(methodName),
2173
- writable: true,
2174
- configurable: true,
2175
- };
2123
+ if (!isAttributeLocked(this, attrName)) {
2124
+ // Ignore changes triggered by the engine itself during:
2125
+ // * diffing when public props are attempting to reflect to the DOM
2126
+ // * component via `this.setAttribute()`, should never update the prop
2127
+ // Both cases, the setAttribute call is always wrapped by the unlocking of the
2128
+ // attribute to be changed
2129
+ return;
2176
2130
  }
2177
- // creating a new attributeChangedCallback per bridge because they are bound to the corresponding
2178
- // map of attributes to props. We do this after all other props and methods to avoid the possibility
2179
- // of getting overrule by a class declaration in user-land, and we make it non-writable, non-configurable
2180
- // to preserve this definition.
2181
- descriptors.attributeChangedCallback = {
2182
- value: createAttributeChangedCallback(attributeToPropMap, superAttributeChangedCallback),
2131
+ // Reflect attribute change to the corresponding property when changed from outside.
2132
+ this[propName] = newValue;
2133
+ };
2134
+ }
2135
+ function HTMLBridgeElementFactory(SuperClass, props, methods) {
2136
+ let HTMLBridgeElement;
2137
+ /**
2138
+ * Modern browsers will have all Native Constructors as regular Classes
2139
+ * and must be instantiated with the new keyword. In older browsers,
2140
+ * specifically IE11, those are objects with a prototype property defined,
2141
+ * since they are not supposed to be extended or instantiated with the
2142
+ * new keyword. This forking logic supports both cases, specifically because
2143
+ * wc.ts relies on the construction path of the bridges to create new
2144
+ * fully qualifying web components.
2145
+ */
2146
+ if (isFunction$1(SuperClass)) {
2147
+ HTMLBridgeElement = class extends SuperClass {};
2148
+ } else {
2149
+ HTMLBridgeElement = function () {
2150
+ // Bridge classes are not supposed to be instantiated directly in
2151
+ // browsers that do not support web components.
2152
+ throw new TypeError('Illegal constructor');
2183
2153
  };
2184
- // Specify attributes for which we want to reflect changes back to their corresponding
2185
- // properties via attributeChangedCallback.
2186
- defineProperty(HTMLBridgeElement, 'observedAttributes', {
2187
- get() {
2188
- return [...superObservedAttributes, ...keys(attributeToPropMap)];
2189
- },
2154
+ // prototype inheritance dance
2155
+ setPrototypeOf(HTMLBridgeElement, SuperClass);
2156
+ setPrototypeOf(HTMLBridgeElement.prototype, SuperClass.prototype);
2157
+ defineProperty(HTMLBridgeElement.prototype, 'constructor', {
2158
+ writable: true,
2159
+ configurable: true,
2160
+ value: HTMLBridgeElement
2190
2161
  });
2191
- defineProperties(HTMLBridgeElement.prototype, descriptors);
2192
- return HTMLBridgeElement;
2162
+ }
2163
+ // generating the hash table for attributes to avoid duplicate fields and facilitate validation
2164
+ // and false positives in case of inheritance.
2165
+ const attributeToPropMap = create(null);
2166
+ const {
2167
+ attributeChangedCallback: superAttributeChangedCallback
2168
+ } = SuperClass.prototype;
2169
+ const {
2170
+ observedAttributes: superObservedAttributes = []
2171
+ } = SuperClass;
2172
+ const descriptors = create(null);
2173
+ // expose getters and setters for each public props on the new Element Bridge
2174
+ for (let i = 0, len = props.length; i < len; i += 1) {
2175
+ const propName = props[i];
2176
+ attributeToPropMap[htmlPropertyToAttribute(propName)] = propName;
2177
+ descriptors[propName] = {
2178
+ get: createGetter(propName),
2179
+ set: createSetter(propName),
2180
+ enumerable: true,
2181
+ configurable: true
2182
+ };
2183
+ }
2184
+ // expose public methods as props on the new Element Bridge
2185
+ for (let i = 0, len = methods.length; i < len; i += 1) {
2186
+ const methodName = methods[i];
2187
+ descriptors[methodName] = {
2188
+ value: createMethodCaller(methodName),
2189
+ writable: true,
2190
+ configurable: true
2191
+ };
2192
+ }
2193
+ // creating a new attributeChangedCallback per bridge because they are bound to the corresponding
2194
+ // map of attributes to props. We do this after all other props and methods to avoid the possibility
2195
+ // of getting overrule by a class declaration in user-land, and we make it non-writable, non-configurable
2196
+ // to preserve this definition.
2197
+ descriptors.attributeChangedCallback = {
2198
+ value: createAttributeChangedCallback(attributeToPropMap, superAttributeChangedCallback)
2199
+ };
2200
+ // Specify attributes for which we want to reflect changes back to their corresponding
2201
+ // properties via attributeChangedCallback.
2202
+ defineProperty(HTMLBridgeElement, 'observedAttributes', {
2203
+ get() {
2204
+ return [...superObservedAttributes, ...keys(attributeToPropMap)];
2205
+ }
2206
+ });
2207
+ defineProperties(HTMLBridgeElement.prototype, descriptors);
2208
+ return HTMLBridgeElement;
2193
2209
  }
2194
2210
  const BaseBridgeElement = HTMLBridgeElementFactory(HTMLElementConstructor, getOwnPropertyNames$1(HTMLElementOriginalDescriptors), []);
2211
+ {
2212
+ // This ARIA reflection only really makes sense in the browser. On the server, there is no `renderedCallback()`,
2213
+ // so you cannot do e.g. `this.template.querySelector('x-child').ariaBusy = 'true'`. So we don't need to expose
2214
+ // ARIA props outside the LightningElement
2215
+ if (lwcRuntimeFlags.DISABLE_ARIA_REFLECTION_POLYFILL) {
2216
+ // If ARIA reflection is not applied globally to Element.prototype, apply it to HTMLBridgeElement.prototype.
2217
+ // This allows `elm.aria*` property accessors to work from outside a component, and to reflect `aria-*` attrs.
2218
+ // This is especially important because the template compiler compiles aria-* attrs on components to aria* props
2219
+ //
2220
+ // Also note that we apply this to BaseBridgeElement.prototype to avoid excessively redefining property
2221
+ // accessors inside the HTMLBridgeElementFactory.
2222
+ applyAriaReflection(BaseBridgeElement.prototype);
2223
+ }
2224
+ }
2195
2225
  freeze(BaseBridgeElement);
2196
2226
  seal(BaseBridgeElement.prototype);
2197
2227
  function setActiveVM(vm) {
@@ -3647,7 +3677,7 @@
3647
3677
  // undefined is for root components, but root components cannot accept slotted content
3648
3678
  setVMBeingRendered(slotset.owner);
3649
3679
  try {
3650
- ArrayPush$1.apply(newChildren, vnode.factory(data.slotData));
3680
+ ArrayPush$1.call(newChildren, vnode.factory(data.slotData, data.key));
3651
3681
  }
3652
3682
  finally {
3653
3683
  setVMBeingRendered(vmBeingRenderedInception);
@@ -4313,15 +4343,10 @@
4313
4343
  } = vm;
4314
4344
  if (state !== 2 /* VMState.disconnected */) {
4315
4345
  const {
4316
- oar,
4317
4346
  tro
4318
4347
  } = vm;
4319
4348
  // Making sure that any observing record will not trigger the rehydrated on this vm
4320
4349
  tro.reset();
4321
- // Making sure that any observing accessor record will not trigger the setter to be reinvoked
4322
- for (const key in oar) {
4323
- oar[key].reset();
4324
- }
4325
4350
  runDisconnectedCallback(vm);
4326
4351
  // Spec: https://dom.spec.whatwg.org/#concept-node-remove (step 14-15)
4327
4352
  runChildNodesDisconnectedCallback(vm);
@@ -4368,7 +4393,6 @@
4368
4393
  cmpSlots: {
4369
4394
  slotAssignments: create(null)
4370
4395
  },
4371
- oar: create(null),
4372
4396
  cmpTemplate: null,
4373
4397
  hydrated: Boolean(hydrated),
4374
4398
  renderMode: def.renderMode,
@@ -5398,9 +5422,60 @@
5398
5422
  hooksAreSet = true;
5399
5423
  setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
5400
5424
  }
5401
- // TODO [#2782]: eventually freezeTemplate() will _actually_ freeze the tmpl object. Today it
5402
- // just warns on mutation.
5425
+ // Deeply freeze the entire array (of arrays) of stylesheet factory functions
5426
+ function deepFreeze(stylesheets) {
5427
+ traverseStylesheets(stylesheets, subStylesheets => {
5428
+ freeze(subStylesheets);
5429
+ });
5430
+ }
5431
+ // Deep-traverse an array (of arrays) of stylesheet factory functions, and call the callback for every array/function
5432
+ function traverseStylesheets(stylesheets, callback) {
5433
+ callback(stylesheets);
5434
+ for (let i = 0; i < stylesheets.length; i++) {
5435
+ const stylesheet = stylesheets[i];
5436
+ if (isArray$1(stylesheet)) {
5437
+ traverseStylesheets(stylesheet, callback);
5438
+ } else {
5439
+ callback(stylesheet);
5440
+ }
5441
+ }
5442
+ }
5403
5443
  function freezeTemplate(tmpl) {
5444
+ if (lwcRuntimeFlags.ENABLE_FROZEN_TEMPLATE) {
5445
+ // Deep freeze the template
5446
+ freeze(tmpl);
5447
+ if (!isUndefined$1(tmpl.stylesheets)) {
5448
+ deepFreeze(tmpl.stylesheets);
5449
+ }
5450
+ } else {
5451
+ // TODO [#2782]: remove this flag and delete the legacy behavior
5452
+ // When ENABLE_FROZEN_TEMPLATE is false, then we shim stylesheetTokens on top of stylesheetToken for anyone who
5453
+ // is accessing the old internal API (backwards compat). Details: https://salesforce.quip.com/v1rmAFu2cKAr
5454
+ defineProperty(tmpl, 'stylesheetTokens', {
5455
+ enumerable: true,
5456
+ configurable: true,
5457
+ get() {
5458
+ const {
5459
+ stylesheetToken
5460
+ } = this;
5461
+ if (isUndefined$1(stylesheetToken)) {
5462
+ return stylesheetToken;
5463
+ }
5464
+ // Shim for the old `stylesheetTokens` property
5465
+ // See https://github.com/salesforce/lwc/pull/2332/files#diff-7901555acef29969adaa6583185b3e9bce475cdc6f23e799a54e0018cb18abaa
5466
+ return {
5467
+ hostAttribute: `${stylesheetToken}-host`,
5468
+ shadowAttribute: stylesheetToken
5469
+ };
5470
+ },
5471
+ set(value) {
5472
+ // If the value is null or some other exotic object, you would be broken anyway in the past
5473
+ // because the engine would try to access hostAttribute/shadowAttribute, which would throw an error.
5474
+ // However it may be undefined in newer versions of LWC, so we need to guard against that case.
5475
+ this.stylesheetToken = isUndefined$1(value) ? undefined : value.shadowAttribute;
5476
+ }
5477
+ });
5478
+ }
5404
5479
  }
5405
5480
 
5406
5481
  /*
@@ -6308,7 +6383,7 @@
6308
6383
  function isNull(obj) {
6309
6384
  return obj === null;
6310
6385
  }
6311
- /** version: 2.32.0 */
6386
+ /** version: 2.33.0 */
6312
6387
 
6313
6388
  /*
6314
6389
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6861,7 +6936,7 @@
6861
6936
  });
6862
6937
  freeze(LightningElement);
6863
6938
  seal(LightningElement.prototype);
6864
- /* version: 2.32.0 */
6939
+ /* version: 2.33.0 */
6865
6940
 
6866
6941
  exports.LightningElement = LightningElement;
6867
6942
  exports.__unstable__ProfilerControl = profilerControl;