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