lwc 2.32.1 → 2.34.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 +842 -595
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +842 -595
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +758 -501
  5. package/dist/engine-dom/iife/es5/engine-dom.js +316 -177
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +329 -173
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +842 -595
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +758 -501
  11. package/dist/engine-dom/umd/es5/engine-dom.js +316 -177
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +329 -173
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +807 -507
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +807 -507
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +3 -3
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +3 -3
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.min.js +2 -2
  20. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +3 -3
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +7 -5
  22. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.min.js +2 -2
  23. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +7 -5
  24. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +3 -3
  25. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.min.js +2 -2
  26. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +3 -3
  27. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +7 -5
  28. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.min.js +2 -2
  29. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +7 -5
  30. package/dist/wire-service/esm/es2017/wire-service.js +2 -2
  31. package/dist/wire-service/iife/es2017/wire-service.js +2 -2
  32. package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
  33. package/dist/wire-service/iife/es5/wire-service.js +5 -3
  34. package/dist/wire-service/iife/es5/wire-service.min.js +1 -1
  35. package/dist/wire-service/iife/es5/wire-service_debug.js +5 -3
  36. package/dist/wire-service/umd/es2017/wire-service.js +2 -2
  37. package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
  38. package/dist/wire-service/umd/es5/wire-service.js +5 -3
  39. package/dist/wire-service/umd/es5/wire-service.min.js +1 -1
  40. package/dist/wire-service/umd/es5/wire-service_debug.js +5 -3
  41. package/package.json +7 -7
@@ -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.1 */
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.1 */
339
+ /** version: 2.34.0 */
419
340
 
420
341
  /**
421
342
  * Copyright (C) 2018 salesforce.com, inc.
@@ -437,6 +358,8 @@ var LWC = (function (exports) {
437
358
  DISABLE_LIGHT_DOM_UNSCOPED_CSS: null,
438
359
  ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY: null,
439
360
  ENABLE_FROZEN_TEMPLATE: null,
361
+ DISABLE_ARIA_REFLECTION_POLYFILL: null,
362
+ ENABLE_PROGRAMMATIC_STYLESHEETS: null,
440
363
  };
441
364
  if (!_globalThis.lwcRuntimeFlags) {
442
365
  Object.defineProperty(_globalThis, 'lwcRuntimeFlags', { value: create(null) });
@@ -480,6 +403,83 @@ var LWC = (function (exports) {
480
403
  */
481
404
  function setFeatureFlagForTest(name, value) {
482
405
  }
406
+ /** version: 2.34.0 */
407
+
408
+ /**
409
+ * Copyright (C) 2018 salesforce.com, inc.
410
+ */
411
+
412
+ /*
413
+ * Copyright (c) 2018, salesforce.com, inc.
414
+ * All rights reserved.
415
+ * SPDX-License-Identifier: MIT
416
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
417
+ */
418
+ function detect(propName, prototype) {
419
+ return isUndefined$1(getOwnPropertyDescriptor$1(prototype, propName));
420
+ }
421
+
422
+ /*
423
+ * Copyright (c) 2018, salesforce.com, inc.
424
+ * All rights reserved.
425
+ * SPDX-License-Identifier: MIT
426
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
427
+ */
428
+ function createAriaPropertyPropertyDescriptor(attrName) {
429
+ // Note that we need to call this.{get,set,has,remove}Attribute rather than dereferencing
430
+ // from Element.prototype, because these methods are overridden in LightningElement.
431
+ return {
432
+ get() {
433
+ // reflect what's in the attribute
434
+ return this.hasAttribute(attrName) ? this.getAttribute(attrName) : null;
435
+ },
436
+ set(newValue) {
437
+ // reflect into the corresponding attribute
438
+ if (isNull(newValue)) {
439
+ this.removeAttribute(attrName);
440
+ }
441
+ else {
442
+ this.setAttribute(attrName, newValue);
443
+ }
444
+ },
445
+ configurable: true,
446
+ enumerable: true,
447
+ };
448
+ }
449
+ function patch$1(propName, prototype) {
450
+ const attrName = AriaPropNameToAttrNameMap[propName];
451
+ const descriptor = createAriaPropertyPropertyDescriptor(attrName);
452
+ defineProperty(prototype, propName, descriptor);
453
+ }
454
+
455
+ /*
456
+ * Copyright (c) 2018, salesforce.com, inc.
457
+ * All rights reserved.
458
+ * SPDX-License-Identifier: MIT
459
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
460
+ */
461
+ function applyAriaReflection(prototype = Element.prototype) {
462
+ const ElementPrototypeAriaPropertyNames = keys(AriaPropNameToAttrNameMap);
463
+ for (let i = 0, len = ElementPrototypeAriaPropertyNames.length; i < len; i += 1) {
464
+ const propName = ElementPrototypeAriaPropertyNames[i];
465
+ if (detect(propName, prototype)) {
466
+ patch$1(propName, prototype);
467
+ }
468
+ }
469
+ }
470
+ /** version: 2.34.0 */
471
+
472
+ /*
473
+ * Copyright (c) 2018, salesforce.com, inc.
474
+ * All rights reserved.
475
+ * SPDX-License-Identifier: MIT
476
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
477
+ */
478
+ if (!lwcRuntimeFlags.DISABLE_ARIA_REFLECTION_POLYFILL) {
479
+ // If DISABLE_ARIA_REFLECTION_POLYFILL is false, then we need to apply the ARIA reflection polyfill globally,
480
+ // i.e. to the global Element.prototype
481
+ applyAriaReflection();
482
+ }
483
483
 
484
484
  /*
485
485
  * Copyright (c) 2018, salesforce.com, inc.
@@ -539,6 +539,18 @@ var LWC = (function (exports) {
539
539
  }
540
540
  return result;
541
541
  }
542
+ function flattenStylesheets(stylesheets) {
543
+ const list = [];
544
+ for (const stylesheet of stylesheets) {
545
+ if (!Array.isArray(stylesheet)) {
546
+ list.push(stylesheet);
547
+ }
548
+ else {
549
+ list.push(...flattenStylesheets(stylesheet));
550
+ }
551
+ }
552
+ return list;
553
+ }
542
554
  // Set a ref (lwc:ref) on a VM, from a template API
543
555
  function setRefVNode(vm, ref, vnode) {
544
556
  // If this method is called, then vm.refVNodes is set as the template has refs.
@@ -784,6 +796,9 @@ var LWC = (function (exports) {
784
796
  // Global HTML Attributes & Properties
785
797
  // https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes
786
798
  // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement
799
+ //
800
+ // If you update this list, check for test files that recapitulate the same list. Searching the codebase
801
+ // for e.g. "dropzone" should suffice.
787
802
  assign(create(null), {
788
803
  accessKey: {
789
804
  attribute: 'accesskey',
@@ -1386,30 +1401,35 @@ var LWC = (function (exports) {
1386
1401
  * for the Base Lightning Element, it also include the reactivity bit, so the standard property is reactive.
1387
1402
  */
1388
1403
  function createBridgeToElementDescriptor(propName, descriptor) {
1389
- const { get, set, enumerable, configurable } = descriptor;
1390
- if (!isFunction$1(get)) {
1391
- throw new TypeError();
1392
- }
1393
- if (!isFunction$1(set)) {
1394
- throw new TypeError();
1404
+ const {
1405
+ get,
1406
+ set,
1407
+ enumerable,
1408
+ configurable
1409
+ } = descriptor;
1410
+ if (!isFunction$1(get)) {
1411
+ throw new TypeError();
1412
+ }
1413
+ if (!isFunction$1(set)) {
1414
+ throw new TypeError();
1415
+ }
1416
+ return {
1417
+ enumerable,
1418
+ configurable,
1419
+ get() {
1420
+ const vm = getAssociatedVM(this);
1421
+ if (isBeingConstructed(vm)) {
1422
+ return;
1423
+ }
1424
+ componentValueObserved(vm, propName);
1425
+ return get.call(vm.elm);
1426
+ },
1427
+ set(newValue) {
1428
+ const vm = getAssociatedVM(this);
1429
+ updateComponentValue(vm, propName, newValue);
1430
+ return set.call(vm.elm, newValue);
1395
1431
  }
1396
- return {
1397
- enumerable,
1398
- configurable,
1399
- get() {
1400
- const vm = getAssociatedVM(this);
1401
- if (isBeingConstructed(vm)) {
1402
- return;
1403
- }
1404
- componentValueObserved(vm, propName);
1405
- return get.call(vm.elm);
1406
- },
1407
- set(newValue) {
1408
- const vm = getAssociatedVM(this);
1409
- updateComponentValue(vm, propName, newValue);
1410
- return set.call(vm.elm, newValue);
1411
- },
1412
- };
1432
+ };
1413
1433
  }
1414
1434
  const EMPTY_REFS = freeze(create(null));
1415
1435
  const refsCache = new WeakMap();
@@ -1419,262 +1439,361 @@ var LWC = (function (exports) {
1419
1439
  **/
1420
1440
  // @ts-ignore
1421
1441
  const LightningElement = function () {
1422
- // This should be as performant as possible, while any initialization should be done lazily
1423
- if (isNull(vmBeingConstructed)) {
1424
- // Thrown when doing something like `new LightningElement()` or
1425
- // `class Foo extends LightningElement {}; new Foo()`
1426
- throw new TypeError('Illegal constructor');
1427
- }
1428
- const vm = vmBeingConstructed;
1429
- const { def, elm } = vm;
1430
- const { bridge } = def;
1431
- const component = this;
1432
- setPrototypeOf(elm, bridge.prototype);
1433
- vm.component = this;
1434
- // Locker hooks assignment. When the LWC engine run with Locker, Locker intercepts all the new
1435
- // component creation and passes hooks to instrument all the component interactions with the
1436
- // engine. We are intentionally hiding this argument from the formal API of LightningElement
1437
- // because we don't want folks to know about it just yet.
1438
- if (arguments.length === 1) {
1439
- const { callHook, setHook, getHook } = arguments[0];
1440
- vm.callHook = callHook;
1441
- vm.setHook = setHook;
1442
- vm.getHook = getHook;
1443
- }
1444
- markLockerLiveObject(this);
1445
- // Linking elm, shadow root and component with the VM.
1446
- associateVM(component, vm);
1447
- associateVM(elm, vm);
1448
- if (vm.renderMode === 1 /* RenderMode.Shadow */) {
1449
- vm.renderRoot = doAttachShadow(vm);
1450
- }
1451
- else {
1452
- vm.renderRoot = elm;
1453
- }
1454
- return this;
1442
+ // This should be as performant as possible, while any initialization should be done lazily
1443
+ if (isNull(vmBeingConstructed)) {
1444
+ // Thrown when doing something like `new LightningElement()` or
1445
+ // `class Foo extends LightningElement {}; new Foo()`
1446
+ throw new TypeError('Illegal constructor');
1447
+ }
1448
+ const vm = vmBeingConstructed;
1449
+ const {
1450
+ def,
1451
+ elm
1452
+ } = vm;
1453
+ const {
1454
+ bridge
1455
+ } = def;
1456
+ const component = this;
1457
+ setPrototypeOf(elm, bridge.prototype);
1458
+ vm.component = this;
1459
+ // Locker hooks assignment. When the LWC engine run with Locker, Locker intercepts all the new
1460
+ // component creation and passes hooks to instrument all the component interactions with the
1461
+ // engine. We are intentionally hiding this argument from the formal API of LightningElement
1462
+ // because we don't want folks to know about it just yet.
1463
+ if (arguments.length === 1) {
1464
+ const {
1465
+ callHook,
1466
+ setHook,
1467
+ getHook
1468
+ } = arguments[0];
1469
+ vm.callHook = callHook;
1470
+ vm.setHook = setHook;
1471
+ vm.getHook = getHook;
1472
+ }
1473
+ markLockerLiveObject(this);
1474
+ // Linking elm, shadow root and component with the VM.
1475
+ associateVM(component, vm);
1476
+ associateVM(elm, vm);
1477
+ if (vm.renderMode === 1 /* RenderMode.Shadow */) {
1478
+ vm.renderRoot = doAttachShadow(vm);
1479
+ } else {
1480
+ vm.renderRoot = elm;
1481
+ }
1482
+ return this;
1455
1483
  };
1456
1484
  function doAttachShadow(vm) {
1457
- const { elm, mode, shadowMode, def: { ctor }, renderer: { attachShadow }, } = vm;
1458
- const shadowRoot = attachShadow(elm, {
1459
- [KEY__SYNTHETIC_MODE]: shadowMode === 1 /* ShadowMode.Synthetic */,
1460
- delegatesFocus: Boolean(ctor.delegatesFocus),
1461
- mode,
1462
- });
1463
- vm.shadowRoot = shadowRoot;
1464
- associateVM(shadowRoot, vm);
1465
- return shadowRoot;
1485
+ const {
1486
+ elm,
1487
+ mode,
1488
+ shadowMode,
1489
+ def: {
1490
+ ctor
1491
+ },
1492
+ renderer: {
1493
+ attachShadow
1494
+ }
1495
+ } = vm;
1496
+ const shadowRoot = attachShadow(elm, {
1497
+ [KEY__SYNTHETIC_MODE]: shadowMode === 1 /* ShadowMode.Synthetic */,
1498
+ delegatesFocus: Boolean(ctor.delegatesFocus),
1499
+ mode
1500
+ });
1501
+ vm.shadowRoot = shadowRoot;
1502
+ associateVM(shadowRoot, vm);
1503
+ return shadowRoot;
1466
1504
  }
1467
1505
  // @ts-ignore
1468
1506
  LightningElement.prototype = {
1469
- constructor: LightningElement,
1470
- dispatchEvent(event) {
1471
- const vm = getAssociatedVM(this);
1472
- const { elm, renderer: { dispatchEvent }, } = vm;
1473
- return dispatchEvent(elm, event);
1474
- },
1475
- addEventListener(type, listener, options) {
1476
- const vm = getAssociatedVM(this);
1477
- const { elm, renderer: { addEventListener }, } = vm;
1478
- const wrappedListener = getWrappedComponentsListener(vm, listener);
1479
- addEventListener(elm, type, wrappedListener, options);
1480
- },
1481
- removeEventListener(type, listener, options) {
1482
- const vm = getAssociatedVM(this);
1483
- const { elm, renderer: { removeEventListener }, } = vm;
1484
- const wrappedListener = getWrappedComponentsListener(vm, listener);
1485
- removeEventListener(elm, type, wrappedListener, options);
1486
- },
1487
- hasAttribute(name) {
1488
- const vm = getAssociatedVM(this);
1489
- const { elm, renderer: { getAttribute }, } = vm;
1490
- return !isNull(getAttribute(elm, name));
1491
- },
1492
- hasAttributeNS(namespace, name) {
1493
- const vm = getAssociatedVM(this);
1494
- const { elm, renderer: { getAttribute }, } = vm;
1495
- return !isNull(getAttribute(elm, name, namespace));
1496
- },
1497
- removeAttribute(name) {
1498
- const vm = getAssociatedVM(this);
1499
- const { elm, renderer: { removeAttribute }, } = vm;
1500
- unlockAttribute(elm, name);
1501
- removeAttribute(elm, name);
1502
- lockAttribute();
1503
- },
1504
- removeAttributeNS(namespace, name) {
1505
- const { elm, renderer: { removeAttribute }, } = getAssociatedVM(this);
1506
- unlockAttribute(elm, name);
1507
- removeAttribute(elm, name, namespace);
1508
- lockAttribute();
1509
- },
1510
- getAttribute(name) {
1511
- const vm = getAssociatedVM(this);
1512
- const { elm } = vm;
1513
- const { getAttribute } = vm.renderer;
1514
- return getAttribute(elm, name);
1515
- },
1516
- getAttributeNS(namespace, name) {
1517
- const vm = getAssociatedVM(this);
1518
- const { elm } = vm;
1519
- const { getAttribute } = vm.renderer;
1520
- return getAttribute(elm, name, namespace);
1521
- },
1522
- setAttribute(name, value) {
1523
- const vm = getAssociatedVM(this);
1524
- const { elm, renderer: { setAttribute }, } = vm;
1525
- unlockAttribute(elm, name);
1526
- setAttribute(elm, name, value);
1527
- lockAttribute();
1528
- },
1529
- setAttributeNS(namespace, name, value) {
1530
- const vm = getAssociatedVM(this);
1531
- const { elm, renderer: { setAttribute }, } = vm;
1532
- unlockAttribute(elm, name);
1533
- setAttribute(elm, name, value, namespace);
1534
- lockAttribute();
1535
- },
1536
- getBoundingClientRect() {
1537
- const vm = getAssociatedVM(this);
1538
- const { elm, renderer: { getBoundingClientRect }, } = vm;
1539
- return getBoundingClientRect(elm);
1540
- },
1541
- get isConnected() {
1542
- const vm = getAssociatedVM(this);
1543
- const { elm, renderer: { isConnected }, } = vm;
1544
- return isConnected(elm);
1545
- },
1546
- get classList() {
1547
- const vm = getAssociatedVM(this);
1548
- const { elm, renderer: { getClassList }, } = vm;
1549
- return getClassList(elm);
1550
- },
1551
- get template() {
1552
- const vm = getAssociatedVM(this);
1553
- return vm.shadowRoot;
1554
- },
1555
- get refs() {
1556
- const vm = getAssociatedVM(this);
1557
- if (isUpdatingTemplate) {
1558
- // If the template is in the process of being updated, then we don't want to go through the normal
1559
- // process of returning the refs and caching them, because the state of the refs is unstable.
1560
- // This can happen if e.g. a template contains `<div class={foo}></div>` and `foo` is computed
1561
- // based on `this.refs.bar`.
1562
- return;
1563
- }
1564
- const { refVNodes, hasRefVNodes, cmpTemplate } = vm;
1565
- // For backwards compatibility with component written before template refs
1566
- // were introduced, we return undefined if the template has no refs defined
1567
- // anywhere. This fixes components that may want to add an expando called `refs`
1568
- // and are checking if it exists with `if (this.refs)` before adding it.
1569
- // Note it is not sufficient to just check if `refVNodes` is null or empty,
1570
- // because a template may have `lwc:ref` defined within a falsy `if:true` block.
1571
- if (!hasRefVNodes) {
1572
- return;
1573
- }
1574
- // For templates that are using `lwc:ref`, if there are no refs currently available
1575
- // (e.g. refs inside of a falsy `if:true` block), we return an empty object.
1576
- if (isNull(refVNodes)) {
1577
- return EMPTY_REFS;
1578
- }
1579
- // The refNodes can be cached based on the refVNodes, since the refVNodes
1580
- // are recreated from scratch every time the template is rendered.
1581
- // This happens with `vm.refVNodes = null` in `template.ts` in `@lwc/engine-core`.
1582
- let refs = refsCache.get(refVNodes);
1583
- if (isUndefined$1(refs)) {
1584
- refs = create(null);
1585
- for (const key of keys(refVNodes)) {
1586
- refs[key] = refVNodes[key].elm;
1587
- }
1588
- freeze(refs);
1589
- refsCache.set(refVNodes, refs);
1590
- }
1591
- return refs;
1592
- },
1593
- // For backwards compat, we allow component authors to set `refs` as an expando
1594
- set refs(value) {
1595
- defineProperty(this, 'refs', {
1596
- configurable: true,
1597
- enumerable: true,
1598
- writable: true,
1599
- value,
1600
- });
1601
- },
1602
- get shadowRoot() {
1603
- // From within the component instance, the shadowRoot is always reported as "closed".
1604
- // Authors should rely on this.template instead.
1605
- return null;
1606
- },
1607
- get children() {
1608
- const vm = getAssociatedVM(this);
1609
- const renderer = vm.renderer;
1610
- return renderer.getChildren(vm.elm);
1611
- },
1612
- get childNodes() {
1613
- const vm = getAssociatedVM(this);
1614
- const renderer = vm.renderer;
1615
- return renderer.getChildNodes(vm.elm);
1616
- },
1617
- get firstChild() {
1618
- const vm = getAssociatedVM(this);
1619
- const renderer = vm.renderer;
1620
- return renderer.getFirstChild(vm.elm);
1621
- },
1622
- get firstElementChild() {
1623
- const vm = getAssociatedVM(this);
1624
- const renderer = vm.renderer;
1625
- return renderer.getFirstElementChild(vm.elm);
1626
- },
1627
- get lastChild() {
1628
- const vm = getAssociatedVM(this);
1629
- const renderer = vm.renderer;
1630
- return renderer.getLastChild(vm.elm);
1631
- },
1632
- get lastElementChild() {
1633
- const vm = getAssociatedVM(this);
1634
- const renderer = vm.renderer;
1635
- return renderer.getLastElementChild(vm.elm);
1636
- },
1637
- render() {
1638
- const vm = getAssociatedVM(this);
1639
- return vm.def.template;
1640
- },
1641
- toString() {
1642
- const vm = getAssociatedVM(this);
1643
- return `[object ${vm.def.name}]`;
1644
- },
1507
+ constructor: LightningElement,
1508
+ dispatchEvent(event) {
1509
+ const vm = getAssociatedVM(this);
1510
+ const {
1511
+ elm,
1512
+ renderer: {
1513
+ dispatchEvent
1514
+ }
1515
+ } = vm;
1516
+ return dispatchEvent(elm, event);
1517
+ },
1518
+ addEventListener(type, listener, options) {
1519
+ const vm = getAssociatedVM(this);
1520
+ const {
1521
+ elm,
1522
+ renderer: {
1523
+ addEventListener
1524
+ }
1525
+ } = vm;
1526
+ const wrappedListener = getWrappedComponentsListener(vm, listener);
1527
+ addEventListener(elm, type, wrappedListener, options);
1528
+ },
1529
+ removeEventListener(type, listener, options) {
1530
+ const vm = getAssociatedVM(this);
1531
+ const {
1532
+ elm,
1533
+ renderer: {
1534
+ removeEventListener
1535
+ }
1536
+ } = vm;
1537
+ const wrappedListener = getWrappedComponentsListener(vm, listener);
1538
+ removeEventListener(elm, type, wrappedListener, options);
1539
+ },
1540
+ hasAttribute(name) {
1541
+ const vm = getAssociatedVM(this);
1542
+ const {
1543
+ elm,
1544
+ renderer: {
1545
+ getAttribute
1546
+ }
1547
+ } = vm;
1548
+ return !isNull(getAttribute(elm, name));
1549
+ },
1550
+ hasAttributeNS(namespace, name) {
1551
+ const vm = getAssociatedVM(this);
1552
+ const {
1553
+ elm,
1554
+ renderer: {
1555
+ getAttribute
1556
+ }
1557
+ } = vm;
1558
+ return !isNull(getAttribute(elm, name, namespace));
1559
+ },
1560
+ removeAttribute(name) {
1561
+ const vm = getAssociatedVM(this);
1562
+ const {
1563
+ elm,
1564
+ renderer: {
1565
+ removeAttribute
1566
+ }
1567
+ } = vm;
1568
+ unlockAttribute(elm, name);
1569
+ removeAttribute(elm, name);
1570
+ lockAttribute();
1571
+ },
1572
+ removeAttributeNS(namespace, name) {
1573
+ const {
1574
+ elm,
1575
+ renderer: {
1576
+ removeAttribute
1577
+ }
1578
+ } = getAssociatedVM(this);
1579
+ unlockAttribute(elm, name);
1580
+ removeAttribute(elm, name, namespace);
1581
+ lockAttribute();
1582
+ },
1583
+ getAttribute(name) {
1584
+ const vm = getAssociatedVM(this);
1585
+ const {
1586
+ elm
1587
+ } = vm;
1588
+ const {
1589
+ getAttribute
1590
+ } = vm.renderer;
1591
+ return getAttribute(elm, name);
1592
+ },
1593
+ getAttributeNS(namespace, name) {
1594
+ const vm = getAssociatedVM(this);
1595
+ const {
1596
+ elm
1597
+ } = vm;
1598
+ const {
1599
+ getAttribute
1600
+ } = vm.renderer;
1601
+ return getAttribute(elm, name, namespace);
1602
+ },
1603
+ setAttribute(name, value) {
1604
+ const vm = getAssociatedVM(this);
1605
+ const {
1606
+ elm,
1607
+ renderer: {
1608
+ setAttribute
1609
+ }
1610
+ } = vm;
1611
+ unlockAttribute(elm, name);
1612
+ setAttribute(elm, name, value);
1613
+ lockAttribute();
1614
+ },
1615
+ setAttributeNS(namespace, name, value) {
1616
+ const vm = getAssociatedVM(this);
1617
+ const {
1618
+ elm,
1619
+ renderer: {
1620
+ setAttribute
1621
+ }
1622
+ } = vm;
1623
+ unlockAttribute(elm, name);
1624
+ setAttribute(elm, name, value, namespace);
1625
+ lockAttribute();
1626
+ },
1627
+ getBoundingClientRect() {
1628
+ const vm = getAssociatedVM(this);
1629
+ const {
1630
+ elm,
1631
+ renderer: {
1632
+ getBoundingClientRect
1633
+ }
1634
+ } = vm;
1635
+ return getBoundingClientRect(elm);
1636
+ },
1637
+ get isConnected() {
1638
+ const vm = getAssociatedVM(this);
1639
+ const {
1640
+ elm,
1641
+ renderer: {
1642
+ isConnected
1643
+ }
1644
+ } = vm;
1645
+ return isConnected(elm);
1646
+ },
1647
+ get classList() {
1648
+ const vm = getAssociatedVM(this);
1649
+ const {
1650
+ elm,
1651
+ renderer: {
1652
+ getClassList
1653
+ }
1654
+ } = vm;
1655
+ return getClassList(elm);
1656
+ },
1657
+ get template() {
1658
+ const vm = getAssociatedVM(this);
1659
+ return vm.shadowRoot;
1660
+ },
1661
+ get refs() {
1662
+ const vm = getAssociatedVM(this);
1663
+ if (isUpdatingTemplate) {
1664
+ // If the template is in the process of being updated, then we don't want to go through the normal
1665
+ // process of returning the refs and caching them, because the state of the refs is unstable.
1666
+ // This can happen if e.g. a template contains `<div class={foo}></div>` and `foo` is computed
1667
+ // based on `this.refs.bar`.
1668
+ return;
1669
+ }
1670
+ const {
1671
+ refVNodes,
1672
+ hasRefVNodes,
1673
+ cmpTemplate
1674
+ } = vm;
1675
+ // For backwards compatibility with component written before template refs
1676
+ // were introduced, we return undefined if the template has no refs defined
1677
+ // anywhere. This fixes components that may want to add an expando called `refs`
1678
+ // and are checking if it exists with `if (this.refs)` before adding it.
1679
+ // Note it is not sufficient to just check if `refVNodes` is null or empty,
1680
+ // because a template may have `lwc:ref` defined within a falsy `if:true` block.
1681
+ if (!hasRefVNodes) {
1682
+ return;
1683
+ }
1684
+ // For templates that are using `lwc:ref`, if there are no refs currently available
1685
+ // (e.g. refs inside of a falsy `if:true` block), we return an empty object.
1686
+ if (isNull(refVNodes)) {
1687
+ return EMPTY_REFS;
1688
+ }
1689
+ // The refNodes can be cached based on the refVNodes, since the refVNodes
1690
+ // are recreated from scratch every time the template is rendered.
1691
+ // This happens with `vm.refVNodes = null` in `template.ts` in `@lwc/engine-core`.
1692
+ let refs = refsCache.get(refVNodes);
1693
+ if (isUndefined$1(refs)) {
1694
+ refs = create(null);
1695
+ for (const key of keys(refVNodes)) {
1696
+ refs[key] = refVNodes[key].elm;
1697
+ }
1698
+ freeze(refs);
1699
+ refsCache.set(refVNodes, refs);
1700
+ }
1701
+ return refs;
1702
+ },
1703
+ // For backwards compat, we allow component authors to set `refs` as an expando
1704
+ set refs(value) {
1705
+ defineProperty(this, 'refs', {
1706
+ configurable: true,
1707
+ enumerable: true,
1708
+ writable: true,
1709
+ value
1710
+ });
1711
+ },
1712
+ get shadowRoot() {
1713
+ // From within the component instance, the shadowRoot is always reported as "closed".
1714
+ // Authors should rely on this.template instead.
1715
+ return null;
1716
+ },
1717
+ get children() {
1718
+ const vm = getAssociatedVM(this);
1719
+ const renderer = vm.renderer;
1720
+ return renderer.getChildren(vm.elm);
1721
+ },
1722
+ get childNodes() {
1723
+ const vm = getAssociatedVM(this);
1724
+ const renderer = vm.renderer;
1725
+ return renderer.getChildNodes(vm.elm);
1726
+ },
1727
+ get firstChild() {
1728
+ const vm = getAssociatedVM(this);
1729
+ const renderer = vm.renderer;
1730
+ return renderer.getFirstChild(vm.elm);
1731
+ },
1732
+ get firstElementChild() {
1733
+ const vm = getAssociatedVM(this);
1734
+ const renderer = vm.renderer;
1735
+ return renderer.getFirstElementChild(vm.elm);
1736
+ },
1737
+ get lastChild() {
1738
+ const vm = getAssociatedVM(this);
1739
+ const renderer = vm.renderer;
1740
+ return renderer.getLastChild(vm.elm);
1741
+ },
1742
+ get lastElementChild() {
1743
+ const vm = getAssociatedVM(this);
1744
+ const renderer = vm.renderer;
1745
+ return renderer.getLastElementChild(vm.elm);
1746
+ },
1747
+ render() {
1748
+ const vm = getAssociatedVM(this);
1749
+ return vm.def.template;
1750
+ },
1751
+ toString() {
1752
+ const vm = getAssociatedVM(this);
1753
+ return `[object ${vm.def.name}]`;
1754
+ }
1645
1755
  };
1646
1756
  const queryAndChildGetterDescriptors = create(null);
1647
- const queryMethods = [
1648
- 'getElementsByClassName',
1649
- 'getElementsByTagName',
1650
- 'querySelector',
1651
- 'querySelectorAll',
1652
- ];
1757
+ const queryMethods = ['getElementsByClassName', 'getElementsByTagName', 'querySelector', 'querySelectorAll'];
1653
1758
  // Generic passthrough for query APIs on HTMLElement to the relevant Renderer APIs
1654
1759
  for (const queryMethod of queryMethods) {
1655
- queryAndChildGetterDescriptors[queryMethod] = {
1656
- value(arg) {
1657
- const vm = getAssociatedVM(this);
1658
- const { elm, renderer } = vm;
1659
- return renderer[queryMethod](elm, arg);
1660
- },
1661
- configurable: true,
1662
- enumerable: true,
1663
- writable: true,
1664
- };
1760
+ queryAndChildGetterDescriptors[queryMethod] = {
1761
+ value(arg) {
1762
+ const vm = getAssociatedVM(this);
1763
+ const {
1764
+ elm,
1765
+ renderer
1766
+ } = vm;
1767
+ return renderer[queryMethod](elm, arg);
1768
+ },
1769
+ configurable: true,
1770
+ enumerable: true,
1771
+ writable: true
1772
+ };
1665
1773
  }
1666
1774
  defineProperties(LightningElement.prototype, queryAndChildGetterDescriptors);
1667
1775
  const lightningBasedDescriptors = create(null);
1668
1776
  for (const propName in HTMLElementOriginalDescriptors) {
1669
- lightningBasedDescriptors[propName] = createBridgeToElementDescriptor(propName, HTMLElementOriginalDescriptors[propName]);
1777
+ lightningBasedDescriptors[propName] = createBridgeToElementDescriptor(propName, HTMLElementOriginalDescriptors[propName]);
1670
1778
  }
1671
1779
  defineProperties(LightningElement.prototype, lightningBasedDescriptors);
1780
+ function applyAriaReflectionToLightningElement() {
1781
+ // If ARIA reflection is not applied globally to Element.prototype, or if we are running server-side,
1782
+ // apply it to LightningElement.prototype.
1783
+ // This allows `this.aria*` property accessors to work from inside a component, and to reflect `aria-*` attrs.
1784
+ applyAriaReflection(LightningElement.prototype);
1785
+ }
1786
+ // The reason for this odd if/else branching is limitations in @lwc/features:
1787
+ // https://github.com/salesforce/lwc/blob/master/packages/%40lwc/features/README.md#only-works-with-if-statements
1788
+ if (lwcRuntimeFlags.DISABLE_ARIA_REFLECTION_POLYFILL) {
1789
+ applyAriaReflectionToLightningElement();
1790
+ }
1672
1791
  defineProperty(LightningElement, 'CustomElementConstructor', {
1673
- get() {
1674
- // If required, a runtime-specific implementation must be defined.
1675
- throw new ReferenceError('The current runtime does not support CustomElementConstructor.');
1676
- },
1677
- configurable: true,
1792
+ get() {
1793
+ // If required, a runtime-specific implementation must be defined.
1794
+ throw new ReferenceError('The current runtime does not support CustomElementConstructor.');
1795
+ },
1796
+ configurable: true
1678
1797
  });
1679
1798
 
1680
1799
  function createObservedFieldPropertyDescriptor(key) {
@@ -1961,138 +2080,161 @@ var LWC = (function (exports) {
1961
2080
  const cachedGetterByKey = create(null);
1962
2081
  const cachedSetterByKey = create(null);
1963
2082
  function createGetter(key) {
1964
- let fn = cachedGetterByKey[key];
1965
- if (isUndefined$1(fn)) {
1966
- fn = cachedGetterByKey[key] = function () {
1967
- const vm = getAssociatedVM(this);
1968
- const { getHook } = vm;
1969
- return getHook(vm.component, key);
1970
- };
1971
- }
1972
- return fn;
2083
+ let fn = cachedGetterByKey[key];
2084
+ if (isUndefined$1(fn)) {
2085
+ fn = cachedGetterByKey[key] = function () {
2086
+ const vm = getAssociatedVM(this);
2087
+ const {
2088
+ getHook
2089
+ } = vm;
2090
+ return getHook(vm.component, key);
2091
+ };
2092
+ }
2093
+ return fn;
1973
2094
  }
1974
2095
  function createSetter(key) {
1975
- let fn = cachedSetterByKey[key];
1976
- if (isUndefined$1(fn)) {
1977
- fn = cachedSetterByKey[key] = function (newValue) {
1978
- const vm = getAssociatedVM(this);
1979
- const { setHook } = vm;
1980
- newValue = getReadOnlyProxy(newValue);
1981
- setHook(vm.component, key, newValue);
1982
- };
1983
- }
1984
- return fn;
2096
+ let fn = cachedSetterByKey[key];
2097
+ if (isUndefined$1(fn)) {
2098
+ fn = cachedSetterByKey[key] = function (newValue) {
2099
+ const vm = getAssociatedVM(this);
2100
+ const {
2101
+ setHook
2102
+ } = vm;
2103
+ newValue = getReadOnlyProxy(newValue);
2104
+ setHook(vm.component, key, newValue);
2105
+ };
2106
+ }
2107
+ return fn;
1985
2108
  }
1986
2109
  function createMethodCaller(methodName) {
1987
- return function () {
1988
- const vm = getAssociatedVM(this);
1989
- const { callHook, component } = vm;
1990
- const fn = component[methodName];
1991
- return callHook(vm.component, fn, ArraySlice.call(arguments));
1992
- };
2110
+ return function () {
2111
+ const vm = getAssociatedVM(this);
2112
+ const {
2113
+ callHook,
2114
+ component
2115
+ } = vm;
2116
+ const fn = component[methodName];
2117
+ return callHook(vm.component, fn, ArraySlice.call(arguments));
2118
+ };
1993
2119
  }
1994
2120
  function createAttributeChangedCallback(attributeToPropMap, superAttributeChangedCallback) {
1995
- return function attributeChangedCallback(attrName, oldValue, newValue) {
1996
- if (oldValue === newValue) {
1997
- // Ignore same values.
1998
- return;
1999
- }
2000
- const propName = attributeToPropMap[attrName];
2001
- if (isUndefined$1(propName)) {
2002
- if (!isUndefined$1(superAttributeChangedCallback)) {
2003
- // delegate unknown attributes to the super.
2004
- // Typescript does not like it when you treat the `arguments` object as an array
2005
- // @ts-ignore type-mismatch
2006
- superAttributeChangedCallback.apply(this, arguments);
2007
- }
2008
- return;
2009
- }
2010
- if (!isAttributeLocked(this, attrName)) {
2011
- // Ignore changes triggered by the engine itself during:
2012
- // * diffing when public props are attempting to reflect to the DOM
2013
- // * component via `this.setAttribute()`, should never update the prop
2014
- // Both cases, the setAttribute call is always wrapped by the unlocking of the
2015
- // attribute to be changed
2016
- return;
2017
- }
2018
- // Reflect attribute change to the corresponding property when changed from outside.
2019
- this[propName] = newValue;
2020
- };
2021
- }
2022
- function HTMLBridgeElementFactory(SuperClass, props, methods) {
2023
- let HTMLBridgeElement;
2024
- /**
2025
- * Modern browsers will have all Native Constructors as regular Classes
2026
- * and must be instantiated with the new keyword. In older browsers,
2027
- * specifically IE11, those are objects with a prototype property defined,
2028
- * since they are not supposed to be extended or instantiated with the
2029
- * new keyword. This forking logic supports both cases, specifically because
2030
- * wc.ts relies on the construction path of the bridges to create new
2031
- * fully qualifying web components.
2032
- */
2033
- if (isFunction$1(SuperClass)) {
2034
- HTMLBridgeElement = class extends SuperClass {
2035
- };
2036
- }
2037
- else {
2038
- HTMLBridgeElement = function () {
2039
- // Bridge classes are not supposed to be instantiated directly in
2040
- // browsers that do not support web components.
2041
- throw new TypeError('Illegal constructor');
2042
- };
2043
- // prototype inheritance dance
2044
- setPrototypeOf(HTMLBridgeElement, SuperClass);
2045
- setPrototypeOf(HTMLBridgeElement.prototype, SuperClass.prototype);
2046
- defineProperty(HTMLBridgeElement.prototype, 'constructor', {
2047
- writable: true,
2048
- configurable: true,
2049
- value: HTMLBridgeElement,
2050
- });
2121
+ return function attributeChangedCallback(attrName, oldValue, newValue) {
2122
+ if (oldValue === newValue) {
2123
+ // Ignore same values.
2124
+ return;
2051
2125
  }
2052
- // generating the hash table for attributes to avoid duplicate fields and facilitate validation
2053
- // and false positives in case of inheritance.
2054
- const attributeToPropMap = create(null);
2055
- const { attributeChangedCallback: superAttributeChangedCallback } = SuperClass.prototype;
2056
- const { observedAttributes: superObservedAttributes = [] } = SuperClass;
2057
- const descriptors = create(null);
2058
- // expose getters and setters for each public props on the new Element Bridge
2059
- for (let i = 0, len = props.length; i < len; i += 1) {
2060
- const propName = props[i];
2061
- attributeToPropMap[htmlPropertyToAttribute(propName)] = propName;
2062
- descriptors[propName] = {
2063
- get: createGetter(propName),
2064
- set: createSetter(propName),
2065
- enumerable: true,
2066
- configurable: true,
2067
- };
2126
+ const propName = attributeToPropMap[attrName];
2127
+ if (isUndefined$1(propName)) {
2128
+ if (!isUndefined$1(superAttributeChangedCallback)) {
2129
+ // delegate unknown attributes to the super.
2130
+ // Typescript does not like it when you treat the `arguments` object as an array
2131
+ // @ts-ignore type-mismatch
2132
+ superAttributeChangedCallback.apply(this, arguments);
2133
+ }
2134
+ return;
2068
2135
  }
2069
- // expose public methods as props on the new Element Bridge
2070
- for (let i = 0, len = methods.length; i < len; i += 1) {
2071
- const methodName = methods[i];
2072
- descriptors[methodName] = {
2073
- value: createMethodCaller(methodName),
2074
- writable: true,
2075
- configurable: true,
2076
- };
2136
+ if (!isAttributeLocked(this, attrName)) {
2137
+ // Ignore changes triggered by the engine itself during:
2138
+ // * diffing when public props are attempting to reflect to the DOM
2139
+ // * component via `this.setAttribute()`, should never update the prop
2140
+ // Both cases, the setAttribute call is always wrapped by the unlocking of the
2141
+ // attribute to be changed
2142
+ return;
2077
2143
  }
2078
- // creating a new attributeChangedCallback per bridge because they are bound to the corresponding
2079
- // map of attributes to props. We do this after all other props and methods to avoid the possibility
2080
- // of getting overrule by a class declaration in user-land, and we make it non-writable, non-configurable
2081
- // to preserve this definition.
2082
- descriptors.attributeChangedCallback = {
2083
- value: createAttributeChangedCallback(attributeToPropMap, superAttributeChangedCallback),
2144
+ // Reflect attribute change to the corresponding property when changed from outside.
2145
+ this[propName] = newValue;
2146
+ };
2147
+ }
2148
+ function HTMLBridgeElementFactory(SuperClass, props, methods) {
2149
+ let HTMLBridgeElement;
2150
+ /**
2151
+ * Modern browsers will have all Native Constructors as regular Classes
2152
+ * and must be instantiated with the new keyword. In older browsers,
2153
+ * specifically IE11, those are objects with a prototype property defined,
2154
+ * since they are not supposed to be extended or instantiated with the
2155
+ * new keyword. This forking logic supports both cases, specifically because
2156
+ * wc.ts relies on the construction path of the bridges to create new
2157
+ * fully qualifying web components.
2158
+ */
2159
+ if (isFunction$1(SuperClass)) {
2160
+ HTMLBridgeElement = class extends SuperClass {};
2161
+ } else {
2162
+ HTMLBridgeElement = function () {
2163
+ // Bridge classes are not supposed to be instantiated directly in
2164
+ // browsers that do not support web components.
2165
+ throw new TypeError('Illegal constructor');
2084
2166
  };
2085
- // Specify attributes for which we want to reflect changes back to their corresponding
2086
- // properties via attributeChangedCallback.
2087
- defineProperty(HTMLBridgeElement, 'observedAttributes', {
2088
- get() {
2089
- return [...superObservedAttributes, ...keys(attributeToPropMap)];
2090
- },
2167
+ // prototype inheritance dance
2168
+ setPrototypeOf(HTMLBridgeElement, SuperClass);
2169
+ setPrototypeOf(HTMLBridgeElement.prototype, SuperClass.prototype);
2170
+ defineProperty(HTMLBridgeElement.prototype, 'constructor', {
2171
+ writable: true,
2172
+ configurable: true,
2173
+ value: HTMLBridgeElement
2091
2174
  });
2092
- defineProperties(HTMLBridgeElement.prototype, descriptors);
2093
- return HTMLBridgeElement;
2175
+ }
2176
+ // generating the hash table for attributes to avoid duplicate fields and facilitate validation
2177
+ // and false positives in case of inheritance.
2178
+ const attributeToPropMap = create(null);
2179
+ const {
2180
+ attributeChangedCallback: superAttributeChangedCallback
2181
+ } = SuperClass.prototype;
2182
+ const {
2183
+ observedAttributes: superObservedAttributes = []
2184
+ } = SuperClass;
2185
+ const descriptors = create(null);
2186
+ // expose getters and setters for each public props on the new Element Bridge
2187
+ for (let i = 0, len = props.length; i < len; i += 1) {
2188
+ const propName = props[i];
2189
+ attributeToPropMap[htmlPropertyToAttribute(propName)] = propName;
2190
+ descriptors[propName] = {
2191
+ get: createGetter(propName),
2192
+ set: createSetter(propName),
2193
+ enumerable: true,
2194
+ configurable: true
2195
+ };
2196
+ }
2197
+ // expose public methods as props on the new Element Bridge
2198
+ for (let i = 0, len = methods.length; i < len; i += 1) {
2199
+ const methodName = methods[i];
2200
+ descriptors[methodName] = {
2201
+ value: createMethodCaller(methodName),
2202
+ writable: true,
2203
+ configurable: true
2204
+ };
2205
+ }
2206
+ // creating a new attributeChangedCallback per bridge because they are bound to the corresponding
2207
+ // map of attributes to props. We do this after all other props and methods to avoid the possibility
2208
+ // of getting overrule by a class declaration in user-land, and we make it non-writable, non-configurable
2209
+ // to preserve this definition.
2210
+ descriptors.attributeChangedCallback = {
2211
+ value: createAttributeChangedCallback(attributeToPropMap, superAttributeChangedCallback)
2212
+ };
2213
+ // Specify attributes for which we want to reflect changes back to their corresponding
2214
+ // properties via attributeChangedCallback.
2215
+ defineProperty(HTMLBridgeElement, 'observedAttributes', {
2216
+ get() {
2217
+ return [...superObservedAttributes, ...keys(attributeToPropMap)];
2218
+ }
2219
+ });
2220
+ defineProperties(HTMLBridgeElement.prototype, descriptors);
2221
+ return HTMLBridgeElement;
2094
2222
  }
2095
2223
  const BaseBridgeElement = HTMLBridgeElementFactory(HTMLElementConstructor, getOwnPropertyNames$1(HTMLElementOriginalDescriptors), []);
2224
+ {
2225
+ // This ARIA reflection only really makes sense in the browser. On the server, there is no `renderedCallback()`,
2226
+ // so you cannot do e.g. `this.template.querySelector('x-child').ariaBusy = 'true'`. So we don't need to expose
2227
+ // ARIA props outside the LightningElement
2228
+ if (lwcRuntimeFlags.DISABLE_ARIA_REFLECTION_POLYFILL) {
2229
+ // If ARIA reflection is not applied globally to Element.prototype, apply it to HTMLBridgeElement.prototype.
2230
+ // This allows `elm.aria*` property accessors to work from outside a component, and to reflect `aria-*` attrs.
2231
+ // This is especially important because the template compiler compiles aria-* attrs on components to aria* props
2232
+ //
2233
+ // Also note that we apply this to BaseBridgeElement.prototype to avoid excessively redefining property
2234
+ // accessors inside the HTMLBridgeElementFactory.
2235
+ applyAriaReflection(BaseBridgeElement.prototype);
2236
+ }
2237
+ }
2096
2238
  freeze(BaseBridgeElement);
2097
2239
  seal(BaseBridgeElement.prototype);
2098
2240
  function setActiveVM(vm) {
@@ -2318,6 +2460,9 @@ var LWC = (function (exports) {
2318
2460
  stylesheets: newStylesheets,
2319
2461
  stylesheetToken: newStylesheetToken
2320
2462
  } = template;
2463
+ const {
2464
+ stylesheets: newVmStylesheets
2465
+ } = vm;
2321
2466
  const isSyntheticShadow = renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */;
2322
2467
  const {
2323
2468
  hasScopedStyles
@@ -2341,7 +2486,9 @@ var LWC = (function (exports) {
2341
2486
  }
2342
2487
  // Apply the new template styling token to the host element, if the new template has any
2343
2488
  // associated stylesheets. In the case of light DOM, also ensure there is at least one scoped stylesheet.
2344
- if (!isUndefined$1(newStylesheets) && newStylesheets.length !== 0) {
2489
+ const hasNewStylesheets = hasStyles(newStylesheets);
2490
+ const hasNewVmStylesheets = hasStyles(newVmStylesheets);
2491
+ if (hasNewStylesheets || hasNewVmStylesheets) {
2345
2492
  newToken = newStylesheetToken;
2346
2493
  }
2347
2494
  // Set the new styling token on the host element
@@ -2405,10 +2552,17 @@ var LWC = (function (exports) {
2405
2552
  stylesheets,
2406
2553
  stylesheetToken
2407
2554
  } = template;
2555
+ const {
2556
+ stylesheets: vmStylesheets
2557
+ } = vm;
2408
2558
  let content = [];
2409
- if (!isUndefined$1(stylesheets) && stylesheets.length !== 0) {
2559
+ if (hasStyles(stylesheets)) {
2410
2560
  content = evaluateStylesheetsContent(stylesheets, stylesheetToken, vm);
2411
2561
  }
2562
+ // VM (component) stylesheets apply after template stylesheets
2563
+ if (hasStyles(vmStylesheets)) {
2564
+ ArrayPush$1.apply(content, evaluateStylesheetsContent(vmStylesheets, stylesheetToken, vm));
2565
+ }
2412
2566
  return content;
2413
2567
  }
2414
2568
  // It might be worth caching this to avoid doing the lookup repeatedly, but
@@ -2446,10 +2600,13 @@ var LWC = (function (exports) {
2446
2600
  const {
2447
2601
  template
2448
2602
  } = getComponentInternalDef(vnode.ctor);
2603
+ const {
2604
+ vm
2605
+ } = vnode;
2449
2606
  const {
2450
2607
  stylesheetToken
2451
2608
  } = template;
2452
- return !isUndefined$1(stylesheetToken) && computeHasScopedStyles(template) ? makeHostToken(stylesheetToken) : null;
2609
+ return !isUndefined$1(stylesheetToken) && computeHasScopedStyles(template, vm) ? makeHostToken(stylesheetToken) : null;
2453
2610
  }
2454
2611
  function getNearestNativeShadowComponent(vm) {
2455
2612
  const owner = getNearestShadowComponent(vm);
@@ -3032,6 +3189,28 @@ var LWC = (function (exports) {
3032
3189
  // in fallback mode, the allocation will always set children to
3033
3190
  // empty and delegate the real allocation to the slot elements
3034
3191
  allocateChildren(n2, vm);
3192
+ // Solves an edge case with slotted VFragments in native shadow mode.
3193
+ //
3194
+ // During allocation, in native shadow, slotted VFragment nodes are flattened and their text delimiters are removed
3195
+ // to avoid interfering with native slot behavior. When this happens, if any of the fragments
3196
+ // were not stable, the children must go through the dynamic diffing algo.
3197
+ //
3198
+ // If the new children (n2.children) contain no VFragments, but the previous children (n1.children) were dynamic,
3199
+ // the new nodes must be marked dynamic so that all nodes are properly updated. The only indicator that the new
3200
+ // nodes need to be dynamic comes from the previous children, so we check that to determine whether we need to
3201
+ // mark the new children dynamic.
3202
+ //
3203
+ // Example:
3204
+ // n1.children: [div, VFragment('', div, null, ''), div] => [div, div, null, div]; // marked dynamic
3205
+ // n2.children: [div, null, div] => [div, null, div] // marked ???
3206
+ const {
3207
+ shadowMode,
3208
+ renderMode
3209
+ } = vm;
3210
+ if (shadowMode == 0 /* ShadowMode.Native */ && renderMode !== 0 /* RenderMode.Light */ && hasDynamicChildren(n1.children)) {
3211
+ // No-op if children has already been marked dynamic by 'allocateChildren()'.
3212
+ markAsDynamicChildren(n2.children);
3213
+ }
3035
3214
  }
3036
3215
  // in fallback mode, the children will be always empty, so, nothing
3037
3216
  // will happen, but in native, it does allocate the light dom
@@ -3193,20 +3372,65 @@ var LWC = (function (exports) {
3193
3372
  //
3194
3373
  // In case #2, we will always get a fresh VCustomElement.
3195
3374
  const children = vnode.aChildren || vnode.children;
3196
- vm.aChildren = children;
3197
3375
  const {
3198
3376
  renderMode,
3199
3377
  shadowMode
3200
3378
  } = vm;
3379
+ // If any of the children being allocated are VFragments, we remove the text delimiters and flatten all immediate
3380
+ // children VFragments to avoid them interfering with default slot behavior.
3381
+ const allocatedChildren = flattenFragmentsInChildren(children);
3382
+ vnode.children = allocatedChildren;
3383
+ vm.aChildren = allocatedChildren;
3201
3384
  if (shadowMode === 1 /* ShadowMode.Synthetic */ || renderMode === 0 /* RenderMode.Light */) {
3202
3385
  // slow path
3203
- allocateInSlot(vm, children, vnode.owner);
3386
+ allocateInSlot(vm, allocatedChildren, vnode.owner);
3204
3387
  // save the allocated children in case this vnode is reused.
3205
- vnode.aChildren = children;
3388
+ vnode.aChildren = allocatedChildren;
3206
3389
  // every child vnode is now allocated, and the host should receive none directly, it receives them via the shadow!
3207
3390
  vnode.children = EmptyArray;
3208
3391
  }
3209
3392
  }
3393
+ /**
3394
+ * Flattens the contents of all VFragments in an array of VNodes, removes the text delimiters on those VFragments, and
3395
+ * marks the resulting children array as dynamic. Uses a stack (array) to iteratively traverse the nested VFragments
3396
+ * and avoid the perf overhead of creating/destroying throwaway arrays/objects in a recursive approach.
3397
+ *
3398
+ * With the delimiters removed, the contents are marked dynamic so they are diffed correctly.
3399
+ *
3400
+ * This function is used for slotted VFragments to avoid the text delimiters interfering with slotting functionality.
3401
+ */
3402
+ function flattenFragmentsInChildren(children) {
3403
+ const flattenedChildren = [];
3404
+ // Initialize our stack with the direct children of the custom component and check whether we have a VFragment.
3405
+ // If no VFragment is found in children, we don't need to traverse anything or mark the children dynamic and can return early.
3406
+ const nodeStack = [];
3407
+ let fragmentFound = false;
3408
+ for (let i = children.length - 1; i > -1; i -= 1) {
3409
+ const child = children[i];
3410
+ ArrayPush$1.call(nodeStack, child);
3411
+ fragmentFound = fragmentFound || !!(child && isVFragment(child));
3412
+ }
3413
+ if (!fragmentFound) {
3414
+ return children;
3415
+ }
3416
+ let currentNode;
3417
+ while (!isUndefined$1(currentNode = ArrayPop.call(nodeStack))) {
3418
+ if (!isNull(currentNode) && isVFragment(currentNode)) {
3419
+ const fChildren = currentNode.children;
3420
+ // Ignore the start and end text node delimiters
3421
+ for (let i = fChildren.length - 2; i > 0; i -= 1) {
3422
+ ArrayPush$1.call(nodeStack, fChildren[i]);
3423
+ }
3424
+ } else {
3425
+ ArrayPush$1.call(flattenedChildren, currentNode);
3426
+ }
3427
+ }
3428
+ // We always mark the children as dynamic because nothing generates stable VFragments yet.
3429
+ // If/when stable VFragments are generated by the compiler, this code should be updated to
3430
+ // not mark dynamic if all flattened VFragments were stable.
3431
+ markAsDynamicChildren(flattenedChildren);
3432
+ return flattenedChildren;
3433
+ }
3210
3434
  function createViewModelHook(elm, vnode, renderer) {
3211
3435
  let vm = getAssociatedVMIfPresent(elm);
3212
3436
  // There is a possibility that a custom element is registered under tagName, in which case, the
@@ -3228,22 +3452,20 @@ var LWC = (function (exports) {
3228
3452
  });
3229
3453
  return vm;
3230
3454
  }
3231
- /**
3232
- * Collects all slots into a SlotSet, traversing through VFragment Nodes
3233
- */
3234
- function collectSlots(vm, children, cmpSlotsMapping) {
3455
+ function allocateInSlot(vm, children, owner) {
3235
3456
  var _a, _b;
3457
+ const {
3458
+ cmpSlots: {
3459
+ slotAssignments: oldSlotsMapping
3460
+ }
3461
+ } = vm;
3462
+ const cmpSlotsMapping = create(null);
3463
+ // Collect all slots into cmpSlotsMapping
3236
3464
  for (let i = 0, len = children.length; i < len; i += 1) {
3237
3465
  const vnode = children[i];
3238
3466
  if (isNull(vnode)) {
3239
3467
  continue;
3240
3468
  }
3241
- // Dive further iff the content is wrapped in a VFragment
3242
- if (isVFragment(vnode)) {
3243
- // Remove the text delimiter nodes to avoid overriding default slot content
3244
- collectSlots(vm, vnode.children.slice(1, -1), cmpSlotsMapping);
3245
- continue;
3246
- }
3247
3469
  let slotName = '';
3248
3470
  if (isVBaseElement(vnode)) {
3249
3471
  slotName = (_b = (_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) !== null && _b !== void 0 ? _b : '';
@@ -3253,15 +3475,6 @@ var LWC = (function (exports) {
3253
3475
  const vnodes = cmpSlotsMapping[slotName] = cmpSlotsMapping[slotName] || [];
3254
3476
  ArrayPush$1.call(vnodes, vnode);
3255
3477
  }
3256
- }
3257
- function allocateInSlot(vm, children, owner) {
3258
- const {
3259
- cmpSlots: {
3260
- slotAssignments: oldSlotsMapping
3261
- }
3262
- } = vm;
3263
- const cmpSlotsMapping = create(null);
3264
- collectSlots(vm, children, cmpSlotsMapping);
3265
3478
  vm.cmpSlots = {
3266
3479
  owner,
3267
3480
  slotAssignments: cmpSlotsMapping
@@ -3292,14 +3505,14 @@ var LWC = (function (exports) {
3292
3505
  }
3293
3506
  }
3294
3507
  // Using a WeakMap instead of a WeakSet because this one works in IE11 :(
3295
- const FromIteration = new WeakMap();
3296
- // dynamic children means it was generated by an iteration
3297
- // in a template, and will require a more complex diffing algo.
3508
+ const DynamicChildren = new WeakMap();
3509
+ // dynamic children means it was either generated by an iteration in a template
3510
+ // or part of an unstable fragment, and will require a more complex diffing algo.
3298
3511
  function markAsDynamicChildren(children) {
3299
- FromIteration.set(children, 1);
3512
+ DynamicChildren.set(children, 1);
3300
3513
  }
3301
3514
  function hasDynamicChildren(children) {
3302
- return FromIteration.has(children);
3515
+ return DynamicChildren.has(children);
3303
3516
  }
3304
3517
  function createKeyToOldIdx(children, beginIdx, endIdx) {
3305
3518
  const map = {};
@@ -3958,7 +4171,7 @@ var LWC = (function (exports) {
3958
4171
  // Create a brand new template cache for the swapped templated.
3959
4172
  context.tplCache = create(null);
3960
4173
  // Set the computeHasScopedStyles property in the context, to avoid recomputing it repeatedly.
3961
- context.hasScopedStyles = computeHasScopedStyles(html);
4174
+ context.hasScopedStyles = computeHasScopedStyles(html, vm);
3962
4175
  // Update the scoping token on the host element.
3963
4176
  updateStylesheetToken(vm, html);
3964
4177
  // Evaluate, create stylesheet and cache the produced VNode for future
@@ -3993,9 +4206,8 @@ var LWC = (function (exports) {
3993
4206
  });
3994
4207
  return vnodes;
3995
4208
  }
3996
- function computeHasScopedStyles(template) {
3997
- const { stylesheets } = template;
3998
- if (!isUndefined$1(stylesheets)) {
4209
+ function computeHasScopedStylesInStylesheets(stylesheets) {
4210
+ if (hasStyles(stylesheets)) {
3999
4211
  for (let i = 0; i < stylesheets.length; i++) {
4000
4212
  if (isTrue(stylesheets[i][KEY__SCOPED_CSS])) {
4001
4213
  return true;
@@ -4004,6 +4216,15 @@ var LWC = (function (exports) {
4004
4216
  }
4005
4217
  return false;
4006
4218
  }
4219
+ function computeHasScopedStyles(template, vm) {
4220
+ const { stylesheets } = template;
4221
+ const vmStylesheets = !isUndefined$1(vm) ? vm.stylesheets : null;
4222
+ return (computeHasScopedStylesInStylesheets(stylesheets) ||
4223
+ computeHasScopedStylesInStylesheets(vmStylesheets));
4224
+ }
4225
+ function hasStyles(stylesheets) {
4226
+ return !isUndefined$1(stylesheets) && !isNull(stylesheets) && stylesheets.length > 0;
4227
+ }
4007
4228
  let vmBeingConstructed = null;
4008
4229
  function isBeingConstructed(vm) {
4009
4230
  return vmBeingConstructed === vm;
@@ -4280,6 +4501,7 @@ var LWC = (function (exports) {
4280
4501
  // Properties set right after VM creation.
4281
4502
  tro: null,
4282
4503
  shadowMode: null,
4504
+ stylesheets: null,
4283
4505
  // Properties set by the LightningElement constructor.
4284
4506
  component: null,
4285
4507
  shadowRoot: null,
@@ -4289,6 +4511,7 @@ var LWC = (function (exports) {
4289
4511
  getHook,
4290
4512
  renderer
4291
4513
  };
4514
+ vm.stylesheets = computeStylesheets(vm, def.ctor);
4292
4515
  vm.shadowMode = computeShadowMode(vm, renderer);
4293
4516
  vm.tro = getTemplateReactiveObserver(vm);
4294
4517
  // Create component instance associated to the vm and the element.
@@ -4299,6 +4522,40 @@ var LWC = (function (exports) {
4299
4522
  }
4300
4523
  return vm;
4301
4524
  }
4525
+ function validateComponentStylesheets(vm, stylesheets) {
4526
+ let valid = true;
4527
+ const validate = arrayOrStylesheet => {
4528
+ if (isArray$1(arrayOrStylesheet)) {
4529
+ for (let i = 0; i < arrayOrStylesheet.length; i++) {
4530
+ validate(arrayOrStylesheet[i]);
4531
+ }
4532
+ } else if (!isFunction$1(arrayOrStylesheet)) {
4533
+ // function assumed to be a stylesheet factory
4534
+ valid = false;
4535
+ }
4536
+ };
4537
+ if (!isArray$1(stylesheets)) {
4538
+ valid = false;
4539
+ } else {
4540
+ validate(stylesheets);
4541
+ }
4542
+ return valid;
4543
+ }
4544
+ // Validate and flatten any stylesheets defined as `static stylesheets`
4545
+ function computeStylesheets(vm, ctor) {
4546
+ if (lwcRuntimeFlags.ENABLE_PROGRAMMATIC_STYLESHEETS) {
4547
+ const {
4548
+ stylesheets
4549
+ } = ctor;
4550
+ if (!isUndefined$1(stylesheets)) {
4551
+ const valid = validateComponentStylesheets(vm, stylesheets);
4552
+ if (valid) {
4553
+ return flattenStylesheets(stylesheets);
4554
+ }
4555
+ }
4556
+ }
4557
+ return null;
4558
+ }
4302
4559
  function computeShadowMode(vm, renderer) {
4303
4560
  const {
4304
4561
  def
@@ -6254,7 +6511,7 @@ var LWC = (function (exports) {
6254
6511
  function isNull(obj) {
6255
6512
  return obj === null;
6256
6513
  }
6257
- /** version: 2.32.1 */
6514
+ /** version: 2.34.0 */
6258
6515
 
6259
6516
  /*
6260
6517
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6807,7 +7064,7 @@ var LWC = (function (exports) {
6807
7064
  });
6808
7065
  freeze(LightningElement);
6809
7066
  seal(LightningElement.prototype);
6810
- /* version: 2.32.1 */
7067
+ /* version: 2.34.0 */
6811
7068
 
6812
7069
  exports.LightningElement = LightningElement;
6813
7070
  exports.__unstable__ProfilerControl = profilerControl;