lwc 2.33.0 → 2.35.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 (39) hide show
  1. package/dist/engine-dom/esm/es2017/engine-dom.js +1022 -649
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +1022 -648
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +824 -557
  5. package/dist/engine-dom/iife/es5/engine-dom.js +1179 -802
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +1002 -720
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +1022 -648
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +824 -557
  11. package/dist/engine-dom/umd/es5/engine-dom.js +1179 -802
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +1002 -720
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +789 -638
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +789 -638
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +15 -4
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +15 -4
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.min.js +2 -2
  20. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +15 -4
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +18 -3
  22. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.min.js +2 -2
  23. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +18 -3
  24. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +15 -4
  25. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.min.js +2 -2
  26. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +15 -4
  27. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +18 -3
  28. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.min.js +2 -2
  29. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +18 -3
  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 +2 -2
  34. package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
  35. package/dist/wire-service/umd/es2017/wire-service.js +2 -2
  36. package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
  37. package/dist/wire-service/umd/es5/wire-service.js +2 -2
  38. package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
  39. package/package.json +7 -7
@@ -12,11 +12,6 @@ var LWC = (function (exports) {
12
12
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
13
13
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
14
14
  function _getPrototypeOf2(o) { _getPrototypeOf2 = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf2(o); }
15
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
16
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
17
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
18
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
19
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
20
15
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
21
16
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
22
17
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
@@ -25,6 +20,11 @@ var LWC = (function (exports) {
25
20
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
26
21
  function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0) { ; } } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
27
22
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
23
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
24
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
25
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
26
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
27
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
28
28
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
29
29
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
30
30
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
@@ -90,6 +90,7 @@ var LWC = (function (exports) {
90
90
  ArrayIndexOf = _Array$prototype.indexOf,
91
91
  ArrayJoin = _Array$prototype.join,
92
92
  ArrayMap = _Array$prototype.map,
93
+ ArrayPop = _Array$prototype.pop,
93
94
  ArrayPush$1 = _Array$prototype.push,
94
95
  ArraySlice = _Array$prototype.slice,
95
96
  ArraySplice = _Array$prototype.splice,
@@ -99,6 +100,7 @@ var LWC = (function (exports) {
99
100
  var _String$prototype = String.prototype,
100
101
  StringCharCodeAt = _String$prototype.charCodeAt,
101
102
  StringReplace = _String$prototype.replace,
103
+ StringSplit = _String$prototype.split,
102
104
  StringSlice = _String$prototype.slice,
103
105
  StringToLowerCase = _String$prototype.toLowerCase;
104
106
  function isUndefined$1(obj) {
@@ -191,6 +193,9 @@ var LWC = (function (exports) {
191
193
  }(),
192
194
  AriaAttrNameToPropNameMap = _ref.AriaAttrNameToPropNameMap,
193
195
  AriaPropNameToAttrNameMap = _ref.AriaPropNameToAttrNameMap;
196
+ // These attributes take either an ID or a list of IDs as values.
197
+ // This includes aria-* attributes as well as the special non-ARIA "for" attribute
198
+ var ID_REFERENCING_ATTRIBUTES_SET = new Set(['aria-activedescendant', 'aria-controls', 'aria-describedby', 'aria-details', 'aria-errormessage', 'aria-flowto', 'aria-labelledby', 'aria-owns', 'for']);
194
199
 
195
200
  /*
196
201
  * Copyright (c) 2018, salesforce.com, inc.
@@ -244,6 +249,8 @@ var LWC = (function (exports) {
244
249
  var KEY__SHADOW_TOKEN = '$shadowToken$';
245
250
  var KEY__SYNTHETIC_MODE = '$$lwc-synthetic-mode';
246
251
  var KEY__SCOPED_CSS = '$scoped$';
252
+ var KEY__NATIVE_GET_ELEMENT_BY_ID = '$nativeGetElementById$';
253
+ var KEY__NATIVE_QUERY_SELECTOR_ALL = '$nativeQuerySelectorAll$';
247
254
  var XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
248
255
  var SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
249
256
  var XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
@@ -331,7 +338,7 @@ var LWC = (function (exports) {
331
338
  CACHED_ATTRIBUTE_PROPERTY_MAPPING.set(attrName, propertyName);
332
339
  return propertyName;
333
340
  }
334
- /** version: 2.33.0 */
341
+ /** version: 2.35.0 */
335
342
 
336
343
  /**
337
344
  * Copyright (C) 2018 salesforce.com, inc.
@@ -353,7 +360,8 @@ var LWC = (function (exports) {
353
360
  DISABLE_LIGHT_DOM_UNSCOPED_CSS: null,
354
361
  ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY: null,
355
362
  ENABLE_FROZEN_TEMPLATE: null,
356
- DISABLE_ARIA_REFLECTION_POLYFILL: null
363
+ DISABLE_ARIA_REFLECTION_POLYFILL: null,
364
+ ENABLE_PROGRAMMATIC_STYLESHEETS: null
357
365
  };
358
366
  if (!_globalThis.lwcRuntimeFlags) {
359
367
  Object.defineProperty(_globalThis, 'lwcRuntimeFlags', {
@@ -401,7 +409,7 @@ var LWC = (function (exports) {
401
409
  */
402
410
  function setFeatureFlagForTest(name, value) {
403
411
  }
404
- /** version: 2.33.0 */
412
+ /** version: 2.35.0 */
405
413
 
406
414
  /**
407
415
  * Copyright (C) 2018 salesforce.com, inc.
@@ -465,7 +473,7 @@ var LWC = (function (exports) {
465
473
  }
466
474
  }
467
475
  }
468
- /** version: 2.33.0 */
476
+ /** version: 2.35.0 */
469
477
 
470
478
  /*
471
479
  * Copyright (c) 2018, salesforce.com, inc.
@@ -485,80 +493,154 @@ var LWC = (function (exports) {
485
493
  * SPDX-License-Identifier: MIT
486
494
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
487
495
  */
488
- var nextTickCallbackQueue = [];
489
- var SPACE_CHAR = 32;
490
- var EmptyObject = seal(create(null));
491
- var EmptyArray = seal([]);
492
- function flushCallbackQueue() {
493
- var callbacks = nextTickCallbackQueue;
494
- nextTickCallbackQueue = []; // reset to a new queue
495
- for (var _i3 = 0, len = callbacks.length; _i3 < len; _i3 += 1) {
496
- callbacks[_i3]();
496
+ /** Callbacks to invoke when reporting is enabled **/
497
+ var onReportingEnabledCallbacks = [];
498
+ /** The currently assigned reporting dispatcher. */
499
+ var currentDispatcher$1 = noop;
500
+ /**
501
+ * Whether reporting is enabled.
502
+ *
503
+ * Note that this may seem redundant, given you can just check if the currentDispatcher is undefined,
504
+ * but it turns out that Terser only strips out unused code if we use this explicit boolean.
505
+ */
506
+ var enabled$1 = false;
507
+ var reportingControl = {
508
+ /**
509
+ * Attach a new reporting control (aka dispatcher).
510
+ *
511
+ * @param dispatcher - reporting control
512
+ */
513
+ attachDispatcher: function attachDispatcher(dispatcher) {
514
+ enabled$1 = true;
515
+ currentDispatcher$1 = dispatcher;
516
+ var _iterator = _createForOfIteratorHelper(onReportingEnabledCallbacks),
517
+ _step;
518
+ try {
519
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
520
+ var callback = _step.value;
521
+ try {
522
+ callback();
523
+ } catch (err) {
524
+ // This should never happen. But if it does, we don't want one callback to cause another to fail
525
+ // eslint-disable-next-line no-console
526
+ console.error('Could not invoke callback', err);
527
+ }
528
+ }
529
+ } catch (err) {
530
+ _iterator.e(err);
531
+ } finally {
532
+ _iterator.f();
533
+ }
534
+ onReportingEnabledCallbacks.length = 0; // clear the array
535
+ },
536
+ /**
537
+ * Detach the current reporting control (aka dispatcher).
538
+ */
539
+ detachDispatcher: function detachDispatcher() {
540
+ enabled$1 = false;
541
+ currentDispatcher$1 = noop;
542
+ }
543
+ };
544
+ /**
545
+ * Call a callback when reporting is enabled, or immediately if reporting is already enabled.
546
+ * Will only ever be called once.
547
+ * @param callback
548
+ */
549
+ function onReportingEnabled(callback) {
550
+ if (enabled$1) {
551
+ // call immediately
552
+ callback();
553
+ } else {
554
+ // call later
555
+ onReportingEnabledCallbacks.push(callback);
497
556
  }
498
557
  }
499
- function addCallbackToNextTick(callback) {
500
- if (nextTickCallbackQueue.length === 0) {
501
- Promise.resolve().then(flushCallbackQueue);
558
+ /**
559
+ * Report to the current dispatcher, if there is one.
560
+ * @param reportingEventId
561
+ * @param vm
562
+ */
563
+ function report(reportingEventId, vm) {
564
+ if (enabled$1) {
565
+ currentDispatcher$1(reportingEventId, vm.tagName, vm.idx);
502
566
  }
503
- ArrayPush$1.call(nextTickCallbackQueue, callback);
504
567
  }
505
- function guid() {
506
- function s4() {
507
- return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
568
+
569
+ /*
570
+ * Copyright (c) 2018, salesforce.com, inc.
571
+ * All rights reserved.
572
+ * SPDX-License-Identifier: MIT
573
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
574
+ */
575
+ function getComponentTag(vm) {
576
+ return "<".concat(StringToLowerCase.call(vm.tagName), ">");
577
+ }
578
+ // TODO [#1695]: Unify getComponentStack and getErrorComponentStack
579
+ function getComponentStack(vm) {
580
+ var stack = [];
581
+ var prefix = '';
582
+ while (!isNull(vm.owner)) {
583
+ ArrayPush$1.call(stack, prefix + getComponentTag(vm));
584
+ vm = vm.owner;
585
+ prefix += '\t';
508
586
  }
509
- return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
587
+ return ArrayJoin.call(stack, '\n');
510
588
  }
511
- // Borrowed from Vue template compiler.
512
- // https://github.com/vuejs/vue/blob/531371b818b0e31a989a06df43789728f23dc4e8/src/platforms/web/util/style.js#L5-L16
513
- var DECLARATION_DELIMITER = /;(?![^(]*\))/g;
514
- var PROPERTY_DELIMITER = /:(.+)/;
515
- function parseStyleText(cssText) {
516
- var styleMap = {};
517
- var declarations = cssText.split(DECLARATION_DELIMITER);
518
- var _iterator = _createForOfIteratorHelper(declarations),
519
- _step;
520
- try {
521
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
522
- var declaration = _step.value;
523
- if (declaration) {
524
- var _declaration$split = declaration.split(PROPERTY_DELIMITER),
525
- _declaration$split2 = _slicedToArray(_declaration$split, 2),
526
- prop = _declaration$split2[0],
527
- value = _declaration$split2[1];
528
- if (prop !== undefined && value !== undefined) {
529
- styleMap[prop.trim()] = value.trim();
530
- }
589
+ function getErrorComponentStack(vm) {
590
+ var wcStack = [];
591
+ var currentVm = vm;
592
+ while (!isNull(currentVm)) {
593
+ ArrayPush$1.call(wcStack, getComponentTag(currentVm));
594
+ currentVm = currentVm.owner;
595
+ }
596
+ return wcStack.reverse().join('\n\t');
597
+ }
598
+
599
+ /*
600
+ * Copyright (c) 2018, salesforce.com, inc.
601
+ * All rights reserved.
602
+ * SPDX-License-Identifier: MIT
603
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
604
+ */
605
+ function addErrorComponentStack(vm, error) {
606
+ if (!isFrozen(error) && isUndefined$1(error.wcStack)) {
607
+ var wcStack = getErrorComponentStack(vm);
608
+ defineProperty(error, 'wcStack', {
609
+ get: function get() {
610
+ return wcStack;
531
611
  }
532
- }
533
- } catch (err) {
534
- _iterator.e(err);
535
- } finally {
536
- _iterator.f();
612
+ });
537
613
  }
538
- return styleMap;
539
614
  }
540
- // Make a shallow copy of an object but omit the given key
541
- function cloneAndOmitKey(object, keyToOmit) {
542
- var result = {};
543
- for (var _i4 = 0, _Object$keys = Object.keys(object); _i4 < _Object$keys.length; _i4++) {
544
- var key = _Object$keys[_i4];
545
- if (key !== keyToOmit) {
546
- result[key] = object[key];
615
+
616
+ /*
617
+ * Copyright (c) 2018, salesforce.com, inc.
618
+ * All rights reserved.
619
+ * SPDX-License-Identifier: MIT
620
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
621
+ */
622
+ var alreadyLoggedMessages = new Set();
623
+ function log(method, message, vm, once) {
624
+ var msg = "[LWC ".concat(method, "]: ").concat(message);
625
+ if (!isUndefined$1(vm)) {
626
+ msg = "".concat(msg, "\n").concat(getComponentStack(vm));
627
+ }
628
+ if (once) {
629
+ if (alreadyLoggedMessages.has(msg)) {
630
+ return;
547
631
  }
632
+ alreadyLoggedMessages.add(msg);
548
633
  }
549
- return result;
550
- }
551
- // Set a ref (lwc:ref) on a VM, from a template API
552
- function setRefVNode(vm, ref, vnode) {
553
- // If this method is called, then vm.refVNodes is set as the template has refs.
554
- // If not, then something went wrong and we threw an error above.
555
- var refVNodes = vm.refVNodes;
556
- // In cases of conflict (two elements with the same ref), prefer, the last one,
557
- // in depth-first traversal order.
558
- if (!(ref in refVNodes) || refVNodes[ref].key < vnode.key) {
559
- refVNodes[ref] = vnode;
634
+ try {
635
+ throw new Error(msg);
636
+ } catch (e) {
637
+ /* eslint-disable-next-line no-console */
638
+ console[method](e);
560
639
  }
561
640
  }
641
+ function logError(message, vm) {
642
+ log('error', message, vm, false);
643
+ }
562
644
 
563
645
  /*
564
646
  * Copyright (c) 2019, salesforce.com, inc.
@@ -582,8 +664,8 @@ var LWC = (function (exports) {
582
664
  if (!isUndefined$1(reactiveRecord)) {
583
665
  var reactiveObservers = reactiveRecord[key];
584
666
  if (!isUndefined$1(reactiveObservers)) {
585
- for (var _i5 = 0, len = reactiveObservers.length; _i5 < len; _i5 += 1) {
586
- var ro = reactiveObservers[_i5];
667
+ for (var _i3 = 0, len = reactiveObservers.length; _i3 < len; _i3 += 1) {
668
+ var ro = reactiveObservers[_i3];
587
669
  ro.notify();
588
670
  }
589
671
  }
@@ -642,9 +724,9 @@ var LWC = (function (exports) {
642
724
  var listeners = this.listeners;
643
725
  var len = listeners.length;
644
726
  if (len > 0) {
645
- for (var _i6 = 0; _i6 < len; _i6 += 1) {
646
- var set = listeners[_i6];
647
- var pos = ArrayIndexOf.call(listeners[_i6], this);
727
+ for (var _i4 = 0; _i4 < len; _i4 += 1) {
728
+ var set = listeners[_i4];
729
+ var pos = ArrayIndexOf.call(listeners[_i4], this);
648
730
  ArraySplice.call(set, pos, 1);
649
731
  }
650
732
  listeners.length = 0;
@@ -689,67 +771,99 @@ var LWC = (function (exports) {
689
771
  * SPDX-License-Identifier: MIT
690
772
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
691
773
  */
692
- function getComponentTag(vm) {
693
- return "<".concat(StringToLowerCase.call(vm.tagName), ">");
774
+ var nextTickCallbackQueue = [];
775
+ var SPACE_CHAR = 32;
776
+ var EmptyObject = seal(create(null));
777
+ var EmptyArray = seal([]);
778
+ function flushCallbackQueue() {
779
+ var callbacks = nextTickCallbackQueue;
780
+ nextTickCallbackQueue = []; // reset to a new queue
781
+ for (var _i5 = 0, len = callbacks.length; _i5 < len; _i5 += 1) {
782
+ callbacks[_i5]();
783
+ }
694
784
  }
695
- // TODO [#1695]: Unify getComponentStack and getErrorComponentStack
696
- function getComponentStack(vm) {
697
- var stack = [];
698
- var prefix = '';
699
- while (!isNull(vm.owner)) {
700
- ArrayPush$1.call(stack, prefix + getComponentTag(vm));
701
- vm = vm.owner;
702
- prefix += '\t';
785
+ function addCallbackToNextTick(callback) {
786
+ if (nextTickCallbackQueue.length === 0) {
787
+ Promise.resolve().then(flushCallbackQueue);
703
788
  }
704
- return ArrayJoin.call(stack, '\n');
789
+ ArrayPush$1.call(nextTickCallbackQueue, callback);
705
790
  }
706
- function getErrorComponentStack(vm) {
707
- var wcStack = [];
708
- var currentVm = vm;
709
- while (!isNull(currentVm)) {
710
- ArrayPush$1.call(wcStack, getComponentTag(currentVm));
711
- currentVm = currentVm.owner;
791
+ function guid() {
792
+ function s4() {
793
+ return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
712
794
  }
713
- return wcStack.reverse().join('\n\t');
795
+ return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
714
796
  }
715
-
716
- /*
717
- * Copyright (c) 2018, salesforce.com, inc.
718
- * All rights reserved.
719
- * SPDX-License-Identifier: MIT
720
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
721
- */
722
- function addErrorComponentStack(vm, error) {
723
- if (!isFrozen(error) && isUndefined$1(error.wcStack)) {
724
- var wcStack = getErrorComponentStack(vm);
725
- defineProperty(error, 'wcStack', {
726
- get: function get() {
727
- return wcStack;
797
+ // Borrowed from Vue template compiler.
798
+ // https://github.com/vuejs/vue/blob/531371b818b0e31a989a06df43789728f23dc4e8/src/platforms/web/util/style.js#L5-L16
799
+ var DECLARATION_DELIMITER = /;(?![^(]*\))/g;
800
+ var PROPERTY_DELIMITER = /:(.+)/;
801
+ function parseStyleText(cssText) {
802
+ var styleMap = {};
803
+ var declarations = cssText.split(DECLARATION_DELIMITER);
804
+ var _iterator2 = _createForOfIteratorHelper(declarations),
805
+ _step2;
806
+ try {
807
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
808
+ var declaration = _step2.value;
809
+ if (declaration) {
810
+ var _declaration$split = declaration.split(PROPERTY_DELIMITER),
811
+ _declaration$split2 = _slicedToArray(_declaration$split, 2),
812
+ prop = _declaration$split2[0],
813
+ value = _declaration$split2[1];
814
+ if (prop !== undefined && value !== undefined) {
815
+ styleMap[prop.trim()] = value.trim();
816
+ }
728
817
  }
729
- });
818
+ }
819
+ } catch (err) {
820
+ _iterator2.e(err);
821
+ } finally {
822
+ _iterator2.f();
730
823
  }
824
+ return styleMap;
731
825
  }
732
-
733
- /*
734
- * Copyright (c) 2018, salesforce.com, inc.
735
- * All rights reserved.
736
- * SPDX-License-Identifier: MIT
737
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
738
- */
739
- function log(method, message, vm) {
740
- var msg = "[LWC ".concat(method, "]: ").concat(message);
741
- if (!isUndefined$1(vm)) {
742
- msg = "".concat(msg, "\n").concat(getComponentStack(vm));
826
+ // Make a shallow copy of an object but omit the given key
827
+ function cloneAndOmitKey(object, keyToOmit) {
828
+ var result = {};
829
+ for (var _i6 = 0, _Object$keys = Object.keys(object); _i6 < _Object$keys.length; _i6++) {
830
+ var key = _Object$keys[_i6];
831
+ if (key !== keyToOmit) {
832
+ result[key] = object[key];
833
+ }
743
834
  }
835
+ return result;
836
+ }
837
+ function flattenStylesheets(stylesheets) {
838
+ var list = [];
839
+ var _iterator3 = _createForOfIteratorHelper(stylesheets),
840
+ _step3;
744
841
  try {
745
- throw new Error(msg);
746
- } catch (e) {
747
- /* eslint-disable-next-line no-console */
748
- console[method](e);
842
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
843
+ var stylesheet = _step3.value;
844
+ if (!Array.isArray(stylesheet)) {
845
+ list.push(stylesheet);
846
+ } else {
847
+ list.push.apply(list, _toConsumableArray(flattenStylesheets(stylesheet)));
848
+ }
849
+ }
850
+ } catch (err) {
851
+ _iterator3.e(err);
852
+ } finally {
853
+ _iterator3.f();
749
854
  }
855
+ return list;
750
856
  }
751
- function logError(message, vm) {
752
- log('error', message, vm);
857
+ // Set a ref (lwc:ref) on a VM, from a template API
858
+ function setRefVNode(vm, ref, vnode) {
859
+ // If this method is called, then vm.refVNodes is set as the template has refs.
860
+ // If not, then something went wrong and we threw an error above.
861
+ var refVNodes = vm.refVNodes;
862
+ // In cases of conflict (two elements with the same ref), prefer, the last one,
863
+ // in depth-first traversal order.
864
+ if (!(ref in refVNodes) || refVNodes[ref].key < vnode.key) {
865
+ refVNodes[ref] = vnode;
866
+ }
753
867
  }
754
868
 
755
869
  /*
@@ -785,98 +899,6 @@ var LWC = (function (exports) {
785
899
  */
786
900
  // These properties get added to LWCElement.prototype publicProps automatically
787
901
  var defaultDefHTMLPropertyNames = ['accessKey', 'dir', 'draggable', 'hidden', 'id', 'lang', 'spellcheck', 'tabIndex', 'title'];
788
- function offsetPropertyErrorMessage(name) {
789
- return "Using the `".concat(name, "` property is an anti-pattern because it rounds the value to an integer. Instead, use the `getBoundingClientRect` method to obtain fractional values for the size of an element and its position relative to the viewport.");
790
- }
791
- // Global HTML Attributes & Properties
792
- // https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes
793
- // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement
794
- assign(create(null), {
795
- accessKey: {
796
- attribute: 'accesskey'
797
- },
798
- accessKeyLabel: {
799
- readOnly: true
800
- },
801
- className: {
802
- attribute: 'class',
803
- error: 'Using the `className` property is an anti-pattern because of slow runtime behavior and potential conflicts with classes provided by the owner element. Use the `classList` API instead.'
804
- },
805
- contentEditable: {
806
- attribute: 'contenteditable'
807
- },
808
- dataset: {
809
- readOnly: true,
810
- error: "Using the `dataset` property is an anti-pattern because it can't be statically analyzed. Expose each property individually using the `@api` decorator instead."
811
- },
812
- dir: {
813
- attribute: 'dir'
814
- },
815
- draggable: {
816
- attribute: 'draggable'
817
- },
818
- dropzone: {
819
- attribute: 'dropzone',
820
- readOnly: true
821
- },
822
- hidden: {
823
- attribute: 'hidden'
824
- },
825
- id: {
826
- attribute: 'id'
827
- },
828
- inputMode: {
829
- attribute: 'inputmode'
830
- },
831
- lang: {
832
- attribute: 'lang'
833
- },
834
- slot: {
835
- attribute: 'slot',
836
- error: 'Using the `slot` property is an anti-pattern.'
837
- },
838
- spellcheck: {
839
- attribute: 'spellcheck'
840
- },
841
- style: {
842
- attribute: 'style'
843
- },
844
- tabIndex: {
845
- attribute: 'tabindex'
846
- },
847
- title: {
848
- attribute: 'title'
849
- },
850
- translate: {
851
- attribute: 'translate'
852
- },
853
- // additional "global attributes" that are not present in the link above.
854
- isContentEditable: {
855
- readOnly: true
856
- },
857
- offsetHeight: {
858
- readOnly: true,
859
- error: offsetPropertyErrorMessage('offsetHeight')
860
- },
861
- offsetLeft: {
862
- readOnly: true,
863
- error: offsetPropertyErrorMessage('offsetLeft')
864
- },
865
- offsetParent: {
866
- readOnly: true
867
- },
868
- offsetTop: {
869
- readOnly: true,
870
- error: offsetPropertyErrorMessage('offsetTop')
871
- },
872
- offsetWidth: {
873
- readOnly: true,
874
- error: offsetPropertyErrorMessage('offsetWidth')
875
- },
876
- role: {
877
- attribute: 'role'
878
- }
879
- });
880
902
  var controlledElement = null;
881
903
  var controlledAttributeName;
882
904
  function isAttributeLocked(elm, attrName) {
@@ -1730,17 +1752,17 @@ var LWC = (function (exports) {
1730
1752
  var refs = refsCache.get(refVNodes);
1731
1753
  if (isUndefined$1(refs)) {
1732
1754
  refs = create(null);
1733
- var _iterator3 = _createForOfIteratorHelper(keys(refVNodes)),
1734
- _step3;
1755
+ var _iterator4 = _createForOfIteratorHelper(keys(refVNodes)),
1756
+ _step4;
1735
1757
  try {
1736
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
1737
- var key = _step3.value;
1758
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
1759
+ var key = _step4.value;
1738
1760
  refs[key] = refVNodes[key].elm;
1739
1761
  }
1740
1762
  } catch (err) {
1741
- _iterator3.e(err);
1763
+ _iterator4.e(err);
1742
1764
  } finally {
1743
- _iterator3.f();
1765
+ _iterator4.f();
1744
1766
  }
1745
1767
  freeze(refs);
1746
1768
  refsCache.set(refVNodes, refs);
@@ -1866,166 +1888,422 @@ var LWC = (function (exports) {
1866
1888
  * SPDX-License-Identifier: MIT
1867
1889
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1868
1890
  */
1869
- function api$1() {
1870
- throw new Error();
1871
- }
1872
- function createPublicPropertyDescriptor(key) {
1873
- return {
1874
- get: function get() {
1875
- var vm = getAssociatedVM(this);
1876
- if (isBeingConstructed(vm)) {
1877
- return;
1891
+ var DeprecatedWiredElementHost = '$$DeprecatedWiredElementHostKey$$';
1892
+ var DeprecatedWiredParamsMeta = '$$DeprecatedWiredParamsMetaKey$$';
1893
+ var WireMetaMap = new Map();
1894
+ var WireContextRegistrationEvent = /*#__PURE__*/function (_CustomEvent) {
1895
+ _inherits(WireContextRegistrationEvent, _CustomEvent);
1896
+ var _super3 = _createSuper(WireContextRegistrationEvent);
1897
+ function WireContextRegistrationEvent(adapterToken, _ref3) {
1898
+ var _this2;
1899
+ var setNewContext = _ref3.setNewContext,
1900
+ setDisconnectedCallback = _ref3.setDisconnectedCallback;
1901
+ _classCallCheck(this, WireContextRegistrationEvent);
1902
+ _this2 = _super3.call(this, adapterToken, {
1903
+ bubbles: true,
1904
+ composed: true
1905
+ });
1906
+ defineProperties(_assertThisInitialized(_this2), {
1907
+ setNewContext: {
1908
+ value: setNewContext
1909
+ },
1910
+ setDisconnectedCallback: {
1911
+ value: setDisconnectedCallback
1878
1912
  }
1879
- componentValueObserved(vm, key);
1880
- return vm.cmpProps[key];
1881
- },
1882
- set: function set(newValue) {
1883
- var vm = getAssociatedVM(this);
1884
- vm.cmpProps[key] = newValue;
1885
- componentValueMutated(vm, key);
1886
- },
1887
- enumerable: true,
1888
- configurable: true
1889
- };
1890
- }
1891
- function createPublicAccessorDescriptor(key, descriptor) {
1892
- var _get2 = descriptor.get,
1893
- _set2 = descriptor.set,
1894
- enumerable = descriptor.enumerable,
1895
- configurable = descriptor.configurable;
1896
- if (!isFunction$1(_get2)) {
1897
- throw new Error();
1913
+ });
1914
+ return _this2;
1898
1915
  }
1899
- return {
1900
- get: function get() {
1901
- return _get2.call(this);
1902
- },
1903
- set: function set(newValue) {
1904
- getAssociatedVM(this);
1905
- if (_set2) {
1906
- _set2.call(this, newValue);
1907
- }
1908
- },
1909
- enumerable: enumerable,
1910
- configurable: configurable
1916
+ return _createClass(WireContextRegistrationEvent);
1917
+ }( /*#__PURE__*/_wrapNativeSuper(CustomEvent));
1918
+ function createFieldDataCallback(vm, name) {
1919
+ return function (value) {
1920
+ updateComponentValue(vm, name, value);
1911
1921
  };
1912
1922
  }
1913
-
1914
- /*
1915
- * Copyright (c) 2018, salesforce.com, inc.
1916
- * All rights reserved.
1917
- * SPDX-License-Identifier: MIT
1918
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1919
- */
1920
- function track(target) {
1921
- if (arguments.length === 1) {
1922
- return getReactiveProxy(target);
1923
- }
1924
- throw new Error();
1925
- }
1926
- function internalTrackDecorator(key) {
1927
- return {
1928
- get: function get() {
1929
- var vm = getAssociatedVM(this);
1930
- componentValueObserved(vm, key);
1931
- return vm.cmpFields[key];
1932
- },
1933
- set: function set(newValue) {
1934
- var vm = getAssociatedVM(this);
1935
- var reactiveOrAnyValue = getReactiveProxy(newValue);
1936
- updateComponentValue(vm, key, reactiveOrAnyValue);
1937
- },
1938
- enumerable: true,
1939
- configurable: true
1923
+ function createMethodDataCallback(vm, method) {
1924
+ return function (value) {
1925
+ // dispatching new value into the wired method
1926
+ runWithBoundaryProtection(vm, vm.owner, noop, function () {
1927
+ // job
1928
+ method.call(vm.component, value);
1929
+ }, noop);
1940
1930
  };
1941
1931
  }
1942
-
1943
- /*
1944
- * Copyright (c) 2018, salesforce.com, inc.
1945
- * All rights reserved.
1946
- * SPDX-License-Identifier: MIT
1947
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1948
- */
1949
- /**
1950
- * @wire decorator to wire fields and methods to a wire adapter in
1951
- * LWC Components. This function implements the internals of this
1952
- * decorator.
1953
- */
1954
- function wire(_adapter, _config) {
1955
- throw new Error();
1956
- }
1957
- function internalWireFieldDecorator(key) {
1932
+ function createConfigWatcher(component, configCallback, callbackWhenConfigIsReady) {
1933
+ var hasPendingConfig = false;
1934
+ // creating the reactive observer for reactive params when needed
1935
+ var ro = createReactiveObserver(function () {
1936
+ if (hasPendingConfig === false) {
1937
+ hasPendingConfig = true;
1938
+ // collect new config in the micro-task
1939
+ Promise.resolve().then(function () {
1940
+ hasPendingConfig = false;
1941
+ // resetting current reactive params
1942
+ ro.reset();
1943
+ // dispatching a new config due to a change in the configuration
1944
+ computeConfigAndUpdate();
1945
+ });
1946
+ }
1947
+ });
1948
+ var computeConfigAndUpdate = function computeConfigAndUpdate() {
1949
+ var config;
1950
+ ro.observe(function () {
1951
+ return config = configCallback(component);
1952
+ });
1953
+ // eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo
1954
+ // TODO: dev-mode validation of config based on the adapter.configSchema
1955
+ // @ts-ignore it is assigned in the observe() callback
1956
+ callbackWhenConfigIsReady(config);
1957
+ };
1958
1958
  return {
1959
- get: function get() {
1960
- var vm = getAssociatedVM(this);
1961
- componentValueObserved(vm, key);
1962
- return vm.cmpFields[key];
1963
- },
1964
- set: function set(value) {
1965
- var vm = getAssociatedVM(this);
1966
- /**
1967
- * Reactivity for wired fields is provided in wiring.
1968
- * We intentionally add reactivity here since this is just
1969
- * letting the author to do the wrong thing, but it will keep our
1970
- * system to be backward compatible.
1971
- */
1972
- updateComponentValue(vm, key, value);
1973
- },
1974
- enumerable: true,
1975
- configurable: true
1959
+ computeConfigAndUpdate: computeConfigAndUpdate,
1960
+ ro: ro
1976
1961
  };
1977
1962
  }
1978
- /**
1979
- * INTERNAL: This function can only be invoked by compiled code. The compiler
1980
- * will prevent this function from being imported by user-land code.
1981
- */
1982
- function registerDecorators(Ctor, meta) {
1983
- var proto = Ctor.prototype;
1984
- var publicProps = meta.publicProps,
1985
- publicMethods = meta.publicMethods,
1986
- wire = meta.wire,
1987
- track = meta.track,
1988
- fields = meta.fields;
1989
- var apiMethods = create(null);
1990
- var apiFields = create(null);
1991
- var wiredMethods = create(null);
1992
- var wiredFields = create(null);
1993
- var observedFields = create(null);
1994
- var apiFieldsConfig = create(null);
1995
- var descriptor;
1996
- if (!isUndefined$1(publicProps)) {
1997
- for (var fieldName in publicProps) {
1998
- var propConfig = publicProps[fieldName];
1999
- apiFieldsConfig[fieldName] = propConfig.config;
2000
- descriptor = getOwnPropertyDescriptor$1(proto, fieldName);
2001
- if (propConfig.config > 0) {
2002
- if (isUndefined$1(descriptor)) {
2003
- throw new Error();
2004
- }
2005
- descriptor = createPublicAccessorDescriptor(fieldName, descriptor);
2006
- } else {
2007
- // [W-9927596] If a component has both a public property and a private setter/getter
2008
- // with the same name, the property is defined as a public accessor. This branch is
2009
- // only here for backward compatibility reasons.
2010
- if (!isUndefined$1(descriptor) && !isUndefined$1(descriptor.get)) {
2011
- descriptor = createPublicAccessorDescriptor(fieldName, descriptor);
2012
- } else {
2013
- descriptor = createPublicPropertyDescriptor(fieldName);
2014
- }
2015
- }
2016
- apiFields[fieldName] = descriptor;
2017
- defineProperty(proto, fieldName, descriptor);
2018
- }
1963
+ function createContextWatcher(vm, wireDef, callbackWhenContextIsReady) {
1964
+ var adapter = wireDef.adapter;
1965
+ var adapterContextToken = getAdapterToken(adapter);
1966
+ if (isUndefined$1(adapterContextToken)) {
1967
+ return; // no provider found, nothing to be done
2019
1968
  }
2020
- if (!isUndefined$1(publicMethods)) {
2021
- forEach.call(publicMethods, function (methodName) {
2022
- descriptor = getOwnPropertyDescriptor$1(proto, methodName);
2023
- if (isUndefined$1(descriptor)) {
2024
- throw new Error();
1969
+
1970
+ var elm = vm.elm,
1971
+ _vm$context = vm.context,
1972
+ wiredConnecting = _vm$context.wiredConnecting,
1973
+ wiredDisconnecting = _vm$context.wiredDisconnecting,
1974
+ dispatchEvent = vm.renderer.dispatchEvent;
1975
+ // waiting for the component to be connected to formally request the context via the token
1976
+ ArrayPush$1.call(wiredConnecting, function () {
1977
+ // This event is responsible for connecting the host element with another
1978
+ // element in the composed path that is providing contextual data. The provider
1979
+ // must be listening for a special dom event with the name corresponding to the value of
1980
+ // `adapterContextToken`, which will remain secret and internal to this file only to
1981
+ // guarantee that the linkage can be forged.
1982
+ var contextRegistrationEvent = new WireContextRegistrationEvent(adapterContextToken, {
1983
+ setNewContext: function setNewContext(newContext) {
1984
+ // eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo
1985
+ // TODO: dev-mode validation of config based on the adapter.contextSchema
1986
+ callbackWhenContextIsReady(newContext);
1987
+ },
1988
+ setDisconnectedCallback: function setDisconnectedCallback(disconnectCallback) {
1989
+ // adds this callback into the disconnect bucket so it gets disconnected from parent
1990
+ // the the element hosting the wire is disconnected
1991
+ ArrayPush$1.call(wiredDisconnecting, disconnectCallback);
2025
1992
  }
2026
- apiMethods[methodName] = descriptor;
2027
1993
  });
2028
- }
1994
+ dispatchEvent(elm, contextRegistrationEvent);
1995
+ });
1996
+ }
1997
+ function createConnector(vm, name, wireDef) {
1998
+ var method = wireDef.method,
1999
+ adapter = wireDef.adapter,
2000
+ configCallback = wireDef.configCallback,
2001
+ dynamic = wireDef.dynamic;
2002
+ var debugInfo;
2003
+ var fieldOrMethodCallback = isUndefined$1(method) ? createFieldDataCallback(vm, name) : createMethodDataCallback(vm, method);
2004
+ var dataCallback = function dataCallback(value) {
2005
+ fieldOrMethodCallback(value);
2006
+ };
2007
+ var context;
2008
+ var connector;
2009
+ // Workaround to pass the component element associated to this wire adapter instance.
2010
+ defineProperty(dataCallback, DeprecatedWiredElementHost, {
2011
+ value: vm.elm
2012
+ });
2013
+ defineProperty(dataCallback, DeprecatedWiredParamsMeta, {
2014
+ value: dynamic
2015
+ });
2016
+ runWithBoundaryProtection(vm, vm, noop, function () {
2017
+ // job
2018
+ connector = new adapter(dataCallback);
2019
+ }, noop);
2020
+ var updateConnectorConfig = function updateConnectorConfig(config) {
2021
+ // every time the config is recomputed due to tracking,
2022
+ // this callback will be invoked with the new computed config
2023
+ runWithBoundaryProtection(vm, vm, noop, function () {
2024
+ // job
2025
+ if ("production" !== 'production') ;
2026
+ connector.update(config, context);
2027
+ }, noop);
2028
+ };
2029
+ // Computes the current wire config and calls the update method on the wire adapter.
2030
+ // If it has params, we will need to observe changes in the next tick.
2031
+ var _createConfigWatcher = createConfigWatcher(vm.component, configCallback, updateConnectorConfig),
2032
+ computeConfigAndUpdate = _createConfigWatcher.computeConfigAndUpdate,
2033
+ ro = _createConfigWatcher.ro;
2034
+ // if the adapter needs contextualization, we need to watch for new context and push it alongside the config
2035
+ if (!isUndefined$1(adapter.contextSchema)) {
2036
+ createContextWatcher(vm, wireDef, function (newContext) {
2037
+ // every time the context is pushed into this component,
2038
+ // this callback will be invoked with the new computed context
2039
+ if (context !== newContext) {
2040
+ context = newContext;
2041
+ // Note: when new context arrives, the config will be recomputed and pushed along side the new
2042
+ // context, this is to preserve the identity characteristics, config should not have identity
2043
+ // (ever), while context can have identity
2044
+ if (vm.state === 1 /* VMState.connected */) {
2045
+ computeConfigAndUpdate();
2046
+ }
2047
+ }
2048
+ });
2049
+ }
2050
+ return {
2051
+ // @ts-ignore the boundary protection executes sync, connector is always defined
2052
+ connector: connector,
2053
+ computeConfigAndUpdate: computeConfigAndUpdate,
2054
+ resetConfigWatcher: function resetConfigWatcher() {
2055
+ return ro.reset();
2056
+ }
2057
+ };
2058
+ }
2059
+ var AdapterToTokenMap = new Map();
2060
+ function getAdapterToken(adapter) {
2061
+ return AdapterToTokenMap.get(adapter);
2062
+ }
2063
+ function setAdapterToken(adapter, token) {
2064
+ AdapterToTokenMap.set(adapter, token);
2065
+ }
2066
+ function storeWiredMethodMeta(descriptor, adapter, configCallback, dynamic) {
2067
+ // support for callable adapters
2068
+ if (adapter.adapter) {
2069
+ adapter = adapter.adapter;
2070
+ }
2071
+ var method = descriptor.value;
2072
+ var def = {
2073
+ adapter: adapter,
2074
+ method: method,
2075
+ configCallback: configCallback,
2076
+ dynamic: dynamic
2077
+ };
2078
+ WireMetaMap.set(descriptor, def);
2079
+ }
2080
+ function storeWiredFieldMeta(descriptor, adapter, configCallback, dynamic) {
2081
+ // support for callable adapters
2082
+ if (adapter.adapter) {
2083
+ adapter = adapter.adapter;
2084
+ }
2085
+ var def = {
2086
+ adapter: adapter,
2087
+ configCallback: configCallback,
2088
+ dynamic: dynamic
2089
+ };
2090
+ WireMetaMap.set(descriptor, def);
2091
+ }
2092
+ function installWireAdapters(vm) {
2093
+ var context = vm.context,
2094
+ wire = vm.def.wire;
2095
+ var wiredConnecting = context.wiredConnecting = [];
2096
+ var wiredDisconnecting = context.wiredDisconnecting = [];
2097
+ for (var fieldNameOrMethod in wire) {
2098
+ var descriptor = wire[fieldNameOrMethod];
2099
+ var wireDef = WireMetaMap.get(descriptor);
2100
+ if (!isUndefined$1(wireDef)) {
2101
+ (function () {
2102
+ var _createConnector = createConnector(vm, fieldNameOrMethod, wireDef),
2103
+ connector = _createConnector.connector,
2104
+ computeConfigAndUpdate = _createConnector.computeConfigAndUpdate,
2105
+ resetConfigWatcher = _createConnector.resetConfigWatcher;
2106
+ var hasDynamicParams = wireDef.dynamic.length > 0;
2107
+ ArrayPush$1.call(wiredConnecting, function () {
2108
+ connector.connect();
2109
+ if (!lwcRuntimeFlags.ENABLE_WIRE_SYNC_EMIT) {
2110
+ if (hasDynamicParams) {
2111
+ Promise.resolve().then(computeConfigAndUpdate);
2112
+ return;
2113
+ }
2114
+ }
2115
+ computeConfigAndUpdate();
2116
+ });
2117
+ ArrayPush$1.call(wiredDisconnecting, function () {
2118
+ connector.disconnect();
2119
+ resetConfigWatcher();
2120
+ });
2121
+ })();
2122
+ }
2123
+ }
2124
+ }
2125
+ function connectWireAdapters(vm) {
2126
+ var wiredConnecting = vm.context.wiredConnecting;
2127
+ for (var _i8 = 0, len = wiredConnecting.length; _i8 < len; _i8 += 1) {
2128
+ wiredConnecting[_i8]();
2129
+ }
2130
+ }
2131
+ function disconnectWireAdapters(vm) {
2132
+ var wiredDisconnecting = vm.context.wiredDisconnecting;
2133
+ runWithBoundaryProtection(vm, vm, noop, function () {
2134
+ // job
2135
+ for (var _i9 = 0, len = wiredDisconnecting.length; _i9 < len; _i9 += 1) {
2136
+ wiredDisconnecting[_i9]();
2137
+ }
2138
+ }, noop);
2139
+ }
2140
+
2141
+ /*
2142
+ * Copyright (c) 2018, salesforce.com, inc.
2143
+ * All rights reserved.
2144
+ * SPDX-License-Identifier: MIT
2145
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2146
+ */
2147
+ function api$1() {
2148
+ throw new Error();
2149
+ }
2150
+ function createPublicPropertyDescriptor(key) {
2151
+ return {
2152
+ get: function get() {
2153
+ var vm = getAssociatedVM(this);
2154
+ if (isBeingConstructed(vm)) {
2155
+ return;
2156
+ }
2157
+ componentValueObserved(vm, key);
2158
+ return vm.cmpProps[key];
2159
+ },
2160
+ set: function set(newValue) {
2161
+ var vm = getAssociatedVM(this);
2162
+ vm.cmpProps[key] = newValue;
2163
+ componentValueMutated(vm, key);
2164
+ },
2165
+ enumerable: true,
2166
+ configurable: true
2167
+ };
2168
+ }
2169
+ function createPublicAccessorDescriptor(key, descriptor) {
2170
+ var _get2 = descriptor.get,
2171
+ _set2 = descriptor.set,
2172
+ enumerable = descriptor.enumerable,
2173
+ configurable = descriptor.configurable;
2174
+ if (!isFunction$1(_get2)) {
2175
+ throw new Error();
2176
+ }
2177
+ return {
2178
+ get: function get() {
2179
+ return _get2.call(this);
2180
+ },
2181
+ set: function set(newValue) {
2182
+ getAssociatedVM(this);
2183
+ if (_set2) {
2184
+ _set2.call(this, newValue);
2185
+ }
2186
+ },
2187
+ enumerable: enumerable,
2188
+ configurable: configurable
2189
+ };
2190
+ }
2191
+
2192
+ /*
2193
+ * Copyright (c) 2018, salesforce.com, inc.
2194
+ * All rights reserved.
2195
+ * SPDX-License-Identifier: MIT
2196
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2197
+ */
2198
+ function track(target) {
2199
+ if (arguments.length === 1) {
2200
+ return getReactiveProxy(target);
2201
+ }
2202
+ throw new Error();
2203
+ }
2204
+ function internalTrackDecorator(key) {
2205
+ return {
2206
+ get: function get() {
2207
+ var vm = getAssociatedVM(this);
2208
+ componentValueObserved(vm, key);
2209
+ return vm.cmpFields[key];
2210
+ },
2211
+ set: function set(newValue) {
2212
+ var vm = getAssociatedVM(this);
2213
+ var reactiveOrAnyValue = getReactiveProxy(newValue);
2214
+ updateComponentValue(vm, key, reactiveOrAnyValue);
2215
+ },
2216
+ enumerable: true,
2217
+ configurable: true
2218
+ };
2219
+ }
2220
+
2221
+ /*
2222
+ * Copyright (c) 2018, salesforce.com, inc.
2223
+ * All rights reserved.
2224
+ * SPDX-License-Identifier: MIT
2225
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2226
+ */
2227
+ /**
2228
+ * @wire decorator to wire fields and methods to a wire adapter in
2229
+ * LWC Components. This function implements the internals of this
2230
+ * decorator.
2231
+ */
2232
+ function wire(_adapter, _config) {
2233
+ throw new Error();
2234
+ }
2235
+ function internalWireFieldDecorator(key) {
2236
+ return {
2237
+ get: function get() {
2238
+ var vm = getAssociatedVM(this);
2239
+ componentValueObserved(vm, key);
2240
+ return vm.cmpFields[key];
2241
+ },
2242
+ set: function set(value) {
2243
+ var vm = getAssociatedVM(this);
2244
+ /**
2245
+ * Reactivity for wired fields is provided in wiring.
2246
+ * We intentionally add reactivity here since this is just
2247
+ * letting the author to do the wrong thing, but it will keep our
2248
+ * system to be backward compatible.
2249
+ */
2250
+ updateComponentValue(vm, key, value);
2251
+ },
2252
+ enumerable: true,
2253
+ configurable: true
2254
+ };
2255
+ }
2256
+ /**
2257
+ * INTERNAL: This function can only be invoked by compiled code. The compiler
2258
+ * will prevent this function from being imported by user-land code.
2259
+ */
2260
+ function registerDecorators(Ctor, meta) {
2261
+ var proto = Ctor.prototype;
2262
+ var publicProps = meta.publicProps,
2263
+ publicMethods = meta.publicMethods,
2264
+ wire = meta.wire,
2265
+ track = meta.track,
2266
+ fields = meta.fields;
2267
+ var apiMethods = create(null);
2268
+ var apiFields = create(null);
2269
+ var wiredMethods = create(null);
2270
+ var wiredFields = create(null);
2271
+ var observedFields = create(null);
2272
+ var apiFieldsConfig = create(null);
2273
+ var descriptor;
2274
+ if (!isUndefined$1(publicProps)) {
2275
+ for (var fieldName in publicProps) {
2276
+ var propConfig = publicProps[fieldName];
2277
+ apiFieldsConfig[fieldName] = propConfig.config;
2278
+ descriptor = getOwnPropertyDescriptor$1(proto, fieldName);
2279
+ if (propConfig.config > 0) {
2280
+ if (isUndefined$1(descriptor)) {
2281
+ throw new Error();
2282
+ }
2283
+ descriptor = createPublicAccessorDescriptor(fieldName, descriptor);
2284
+ } else {
2285
+ // [W-9927596] If a component has both a public property and a private setter/getter
2286
+ // with the same name, the property is defined as a public accessor. This branch is
2287
+ // only here for backward compatibility reasons.
2288
+ if (!isUndefined$1(descriptor) && !isUndefined$1(descriptor.get)) {
2289
+ descriptor = createPublicAccessorDescriptor(fieldName, descriptor);
2290
+ } else {
2291
+ descriptor = createPublicPropertyDescriptor(fieldName);
2292
+ }
2293
+ }
2294
+ apiFields[fieldName] = descriptor;
2295
+ defineProperty(proto, fieldName, descriptor);
2296
+ }
2297
+ }
2298
+ if (!isUndefined$1(publicMethods)) {
2299
+ forEach.call(publicMethods, function (methodName) {
2300
+ descriptor = getOwnPropertyDescriptor$1(proto, methodName);
2301
+ if (isUndefined$1(descriptor)) {
2302
+ throw new Error();
2303
+ }
2304
+ apiMethods[methodName] = descriptor;
2305
+ });
2306
+ }
2029
2307
  if (!isUndefined$1(wire)) {
2030
2308
  for (var fieldOrMethodName in wire) {
2031
2309
  var _wire$fieldOrMethodNa = wire[fieldOrMethodName],
@@ -2057,8 +2335,8 @@ var LWC = (function (exports) {
2057
2335
  }
2058
2336
  }
2059
2337
  if (!isUndefined$1(fields)) {
2060
- for (var _i8 = 0, n = fields.length; _i8 < n; _i8++) {
2061
- var _fieldName2 = fields[_i8];
2338
+ for (var _i10 = 0, n = fields.length; _i10 < n; _i10++) {
2339
+ var _fieldName2 = fields[_i10];
2062
2340
  descriptor = getOwnPropertyDescriptor$1(proto, _fieldName2);
2063
2341
  // [W-9927596] Only mark a field as observed whenever it isn't a duplicated public nor
2064
2342
  // tracked property. This is only here for backward compatibility purposes.
@@ -2209,10 +2487,10 @@ var LWC = (function (exports) {
2209
2487
  if (isFunction$1(SuperClass)) {
2210
2488
  HTMLBridgeElement = /*#__PURE__*/function (_SuperClass) {
2211
2489
  _inherits(HTMLBridgeElement, _SuperClass);
2212
- var _super3 = _createSuper(HTMLBridgeElement);
2490
+ var _super4 = _createSuper(HTMLBridgeElement);
2213
2491
  function HTMLBridgeElement() {
2214
2492
  _classCallCheck(this, HTMLBridgeElement);
2215
- return _super3.apply(this, arguments);
2493
+ return _super4.apply(this, arguments);
2216
2494
  }
2217
2495
  return _createClass(HTMLBridgeElement);
2218
2496
  }(SuperClass);
@@ -2239,8 +2517,8 @@ var LWC = (function (exports) {
2239
2517
  superObservedAttributes = _SuperClass$observedA === void 0 ? [] : _SuperClass$observedA;
2240
2518
  var descriptors = create(null);
2241
2519
  // expose getters and setters for each public props on the new Element Bridge
2242
- for (var _i9 = 0, len = props.length; _i9 < len; _i9 += 1) {
2243
- var _propName = props[_i9];
2520
+ for (var _i11 = 0, len = props.length; _i11 < len; _i11 += 1) {
2521
+ var _propName = props[_i11];
2244
2522
  attributeToPropMap[htmlPropertyToAttribute(_propName)] = _propName;
2245
2523
  descriptors[_propName] = {
2246
2524
  get: createGetter(_propName),
@@ -2250,8 +2528,8 @@ var LWC = (function (exports) {
2250
2528
  };
2251
2529
  }
2252
2530
  // expose public methods as props on the new Element Bridge
2253
- for (var _i10 = 0, _len = methods.length; _i10 < _len; _i10 += 1) {
2254
- var methodName = methods[_i10];
2531
+ for (var _i12 = 0, _len = methods.length; _i12 < _len; _i12 += 1) {
2532
+ var methodName = methods[_i12];
2255
2533
  descriptors[methodName] = {
2256
2534
  value: createMethodCaller(methodName),
2257
2535
  writable: true,
@@ -2525,6 +2803,7 @@ var LWC = (function (exports) {
2525
2803
  setAttribute = _vm$renderer.setAttribute;
2526
2804
  var newStylesheets = template.stylesheets,
2527
2805
  newStylesheetToken = template.stylesheetToken;
2806
+ var newVmStylesheets = vm.stylesheets;
2528
2807
  var isSyntheticShadow = renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */;
2529
2808
  var hasScopedStyles = context.hasScopedStyles;
2530
2809
  var newToken;
@@ -2544,7 +2823,9 @@ var LWC = (function (exports) {
2544
2823
  }
2545
2824
  // Apply the new template styling token to the host element, if the new template has any
2546
2825
  // associated stylesheets. In the case of light DOM, also ensure there is at least one scoped stylesheet.
2547
- if (!isUndefined$1(newStylesheets) && newStylesheets.length !== 0) {
2826
+ var hasNewStylesheets = hasStyles(newStylesheets);
2827
+ var hasNewVmStylesheets = hasStyles(newVmStylesheets);
2828
+ if (hasNewStylesheets || hasNewVmStylesheets) {
2548
2829
  newToken = newStylesheetToken;
2549
2830
  }
2550
2831
  // Set the new styling token on the host element
@@ -2566,8 +2847,8 @@ var LWC = (function (exports) {
2566
2847
  function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
2567
2848
  var content = [];
2568
2849
  var root;
2569
- for (var _i11 = 0; _i11 < stylesheets.length; _i11++) {
2570
- var stylesheet = stylesheets[_i11];
2850
+ for (var _i13 = 0; _i13 < stylesheets.length; _i13++) {
2851
+ var stylesheet = stylesheets[_i13];
2571
2852
  if (isArray$1(stylesheet)) {
2572
2853
  ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, stylesheetToken, vm));
2573
2854
  } else {
@@ -2606,10 +2887,15 @@ var LWC = (function (exports) {
2606
2887
  function getStylesheetsContent(vm, template) {
2607
2888
  var stylesheets = template.stylesheets,
2608
2889
  stylesheetToken = template.stylesheetToken;
2890
+ var vmStylesheets = vm.stylesheets;
2609
2891
  var content = [];
2610
- if (!isUndefined$1(stylesheets) && stylesheets.length !== 0) {
2892
+ if (hasStyles(stylesheets)) {
2611
2893
  content = evaluateStylesheetsContent(stylesheets, stylesheetToken, vm);
2612
2894
  }
2895
+ // VM (component) stylesheets apply after template stylesheets
2896
+ if (hasStyles(vmStylesheets)) {
2897
+ ArrayPush$1.apply(content, evaluateStylesheetsContent(vmStylesheets, stylesheetToken, vm));
2898
+ }
2613
2899
  return content;
2614
2900
  }
2615
2901
  // It might be worth caching this to avoid doing the lookup repeatedly, but
@@ -2644,8 +2930,9 @@ var LWC = (function (exports) {
2644
2930
  function getStylesheetTokenHost(vnode) {
2645
2931
  var _getComponentInternal = getComponentInternalDef(vnode.ctor),
2646
2932
  template = _getComponentInternal.template;
2933
+ var vm = vnode.vm;
2647
2934
  var stylesheetToken = template.stylesheetToken;
2648
- return !isUndefined$1(stylesheetToken) && computeHasScopedStyles(template) ? makeHostToken(stylesheetToken) : null;
2935
+ return !isUndefined$1(stylesheetToken) && computeHasScopedStyles(template, vm) ? makeHostToken(stylesheetToken) : null;
2649
2936
  }
2650
2937
  function getNearestNativeShadowComponent(vm) {
2651
2938
  var owner = getNearestShadowComponent(vm);
@@ -2661,8 +2948,8 @@ var LWC = (function (exports) {
2661
2948
  shadowMode = vm.shadowMode,
2662
2949
  insertStylesheet = vm.renderer.insertStylesheet;
2663
2950
  if (renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */) {
2664
- for (var _i12 = 0; _i12 < stylesheets.length; _i12++) {
2665
- insertStylesheet(stylesheets[_i12]);
2951
+ for (var _i14 = 0; _i14 < stylesheets.length; _i14++) {
2952
+ insertStylesheet(stylesheets[_i14]);
2666
2953
  }
2667
2954
  } else if (vm.hydrated) {
2668
2955
  // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
@@ -2675,8 +2962,8 @@ var LWC = (function (exports) {
2675
2962
  var root = getNearestNativeShadowComponent(vm);
2676
2963
  // null root means a global style
2677
2964
  var target = isNull(root) ? undefined : root.shadowRoot;
2678
- for (var _i13 = 0; _i13 < stylesheets.length; _i13++) {
2679
- insertStylesheet(stylesheets[_i13], target);
2965
+ for (var _i15 = 0; _i15 < stylesheets.length; _i15++) {
2966
+ insertStylesheet(stylesheets[_i15], target);
2680
2967
  }
2681
2968
  }
2682
2969
  return null;
@@ -2978,8 +3265,8 @@ var LWC = (function (exports) {
2978
3265
  return;
2979
3266
  }
2980
3267
  var setCSSStyleProperty = renderer.setCSSStyleProperty;
2981
- for (var _i14 = 0; _i14 < styleDecls.length; _i14++) {
2982
- var _styleDecls$_i = _slicedToArray(styleDecls[_i14], 3),
3268
+ for (var _i16 = 0; _i16 < styleDecls.length; _i16++) {
3269
+ var _styleDecls$_i = _slicedToArray(styleDecls[_i16], 3),
2983
3270
  prop = _styleDecls$_i[0],
2984
3271
  value = _styleDecls$_i[1],
2985
3272
  important = _styleDecls$_i[2];
@@ -3204,6 +3491,26 @@ var LWC = (function (exports) {
3204
3491
  // in fallback mode, the allocation will always set children to
3205
3492
  // empty and delegate the real allocation to the slot elements
3206
3493
  allocateChildren(n2, vm);
3494
+ // Solves an edge case with slotted VFragments in native shadow mode.
3495
+ //
3496
+ // During allocation, in native shadow, slotted VFragment nodes are flattened and their text delimiters are removed
3497
+ // to avoid interfering with native slot behavior. When this happens, if any of the fragments
3498
+ // were not stable, the children must go through the dynamic diffing algo.
3499
+ //
3500
+ // If the new children (n2.children) contain no VFragments, but the previous children (n1.children) were dynamic,
3501
+ // the new nodes must be marked dynamic so that all nodes are properly updated. The only indicator that the new
3502
+ // nodes need to be dynamic comes from the previous children, so we check that to determine whether we need to
3503
+ // mark the new children dynamic.
3504
+ //
3505
+ // Example:
3506
+ // n1.children: [div, VFragment('', div, null, ''), div] => [div, div, null, div]; // marked dynamic
3507
+ // n2.children: [div, null, div] => [div, null, div] // marked ???
3508
+ var shadowMode = vm.shadowMode,
3509
+ renderMode = vm.renderMode;
3510
+ if (shadowMode == 0 /* ShadowMode.Native */ && renderMode !== 0 /* RenderMode.Light */ && hasDynamicChildren(n1.children)) {
3511
+ // No-op if children has already been marked dynamic by 'allocateChildren()'.
3512
+ markAsDynamicChildren(n2.children);
3513
+ }
3207
3514
  }
3208
3515
  // in fallback mode, the children will be always empty, so, nothing
3209
3516
  // will happen, but in native, it does allocate the light dom
@@ -3351,18 +3658,63 @@ var LWC = (function (exports) {
3351
3658
  //
3352
3659
  // In case #2, we will always get a fresh VCustomElement.
3353
3660
  var children = vnode.aChildren || vnode.children;
3354
- vm.aChildren = children;
3355
3661
  var renderMode = vm.renderMode,
3356
3662
  shadowMode = vm.shadowMode;
3663
+ // If any of the children being allocated are VFragments, we remove the text delimiters and flatten all immediate
3664
+ // children VFragments to avoid them interfering with default slot behavior.
3665
+ var allocatedChildren = flattenFragmentsInChildren(children);
3666
+ vnode.children = allocatedChildren;
3667
+ vm.aChildren = allocatedChildren;
3357
3668
  if (shadowMode === 1 /* ShadowMode.Synthetic */ || renderMode === 0 /* RenderMode.Light */) {
3358
3669
  // slow path
3359
- allocateInSlot(vm, children, vnode.owner);
3670
+ allocateInSlot(vm, allocatedChildren, vnode.owner);
3360
3671
  // save the allocated children in case this vnode is reused.
3361
- vnode.aChildren = children;
3672
+ vnode.aChildren = allocatedChildren;
3362
3673
  // every child vnode is now allocated, and the host should receive none directly, it receives them via the shadow!
3363
3674
  vnode.children = EmptyArray;
3364
3675
  }
3365
3676
  }
3677
+ /**
3678
+ * Flattens the contents of all VFragments in an array of VNodes, removes the text delimiters on those VFragments, and
3679
+ * marks the resulting children array as dynamic. Uses a stack (array) to iteratively traverse the nested VFragments
3680
+ * and avoid the perf overhead of creating/destroying throwaway arrays/objects in a recursive approach.
3681
+ *
3682
+ * With the delimiters removed, the contents are marked dynamic so they are diffed correctly.
3683
+ *
3684
+ * This function is used for slotted VFragments to avoid the text delimiters interfering with slotting functionality.
3685
+ */
3686
+ function flattenFragmentsInChildren(children) {
3687
+ var flattenedChildren = [];
3688
+ // Initialize our stack with the direct children of the custom component and check whether we have a VFragment.
3689
+ // If no VFragment is found in children, we don't need to traverse anything or mark the children dynamic and can return early.
3690
+ var nodeStack = [];
3691
+ var fragmentFound = false;
3692
+ for (var _i17 = children.length - 1; _i17 > -1; _i17 -= 1) {
3693
+ var child = children[_i17];
3694
+ ArrayPush$1.call(nodeStack, child);
3695
+ fragmentFound = fragmentFound || !!(child && isVFragment(child));
3696
+ }
3697
+ if (!fragmentFound) {
3698
+ return children;
3699
+ }
3700
+ var currentNode;
3701
+ while (!isUndefined$1(currentNode = ArrayPop.call(nodeStack))) {
3702
+ if (!isNull(currentNode) && isVFragment(currentNode)) {
3703
+ var fChildren = currentNode.children;
3704
+ // Ignore the start and end text node delimiters
3705
+ for (var _i18 = fChildren.length - 2; _i18 > 0; _i18 -= 1) {
3706
+ ArrayPush$1.call(nodeStack, fChildren[_i18]);
3707
+ }
3708
+ } else {
3709
+ ArrayPush$1.call(flattenedChildren, currentNode);
3710
+ }
3711
+ }
3712
+ // We always mark the children as dynamic because nothing generates stable VFragments yet.
3713
+ // If/when stable VFragments are generated by the compiler, this code should be updated to
3714
+ // not mark dynamic if all flattened VFragments were stable.
3715
+ markAsDynamicChildren(flattenedChildren);
3716
+ return flattenedChildren;
3717
+ }
3366
3718
  function createViewModelHook(elm, vnode, renderer) {
3367
3719
  var vm = getAssociatedVMIfPresent(elm);
3368
3720
  // There is a possibility that a custom element is registered under tagName, in which case, the
@@ -3382,22 +3734,16 @@ var LWC = (function (exports) {
3382
3734
  });
3383
3735
  return vm;
3384
3736
  }
3385
- /**
3386
- * Collects all slots into a SlotSet, traversing through VFragment Nodes
3387
- */
3388
- function collectSlots(vm, children, cmpSlotsMapping) {
3737
+ function allocateInSlot(vm, children, owner) {
3389
3738
  var _a, _b;
3390
- for (var _i15 = 0, len = children.length; _i15 < len; _i15 += 1) {
3391
- var vnode = children[_i15];
3739
+ var oldSlotsMapping = vm.cmpSlots.slotAssignments;
3740
+ var cmpSlotsMapping = create(null);
3741
+ // Collect all slots into cmpSlotsMapping
3742
+ for (var _i19 = 0, len = children.length; _i19 < len; _i19 += 1) {
3743
+ var vnode = children[_i19];
3392
3744
  if (isNull(vnode)) {
3393
3745
  continue;
3394
3746
  }
3395
- // Dive further iff the content is wrapped in a VFragment
3396
- if (isVFragment(vnode)) {
3397
- // Remove the text delimiter nodes to avoid overriding default slot content
3398
- collectSlots(vm, vnode.children.slice(1, -1), cmpSlotsMapping);
3399
- continue;
3400
- }
3401
3747
  var slotName = '';
3402
3748
  if (isVBaseElement(vnode)) {
3403
3749
  slotName = (_b = (_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) !== null && _b !== void 0 ? _b : '';
@@ -3407,11 +3753,6 @@ var LWC = (function (exports) {
3407
3753
  var vnodes = cmpSlotsMapping[slotName] = cmpSlotsMapping[slotName] || [];
3408
3754
  ArrayPush$1.call(vnodes, vnode);
3409
3755
  }
3410
- }
3411
- function allocateInSlot(vm, children, owner) {
3412
- var oldSlotsMapping = vm.cmpSlots.slotAssignments;
3413
- var cmpSlotsMapping = create(null);
3414
- collectSlots(vm, children, cmpSlotsMapping);
3415
3756
  vm.cmpSlots = {
3416
3757
  owner: owner,
3417
3758
  slotAssignments: cmpSlotsMapping
@@ -3424,16 +3765,16 @@ var LWC = (function (exports) {
3424
3765
  markComponentAsDirty(vm);
3425
3766
  return;
3426
3767
  }
3427
- for (var _i16 = 0, len = oldKeys.length; _i16 < len; _i16 += 1) {
3428
- var key = oldKeys[_i16];
3768
+ for (var _i20 = 0, _len2 = oldKeys.length; _i20 < _len2; _i20 += 1) {
3769
+ var key = oldKeys[_i20];
3429
3770
  if (isUndefined$1(cmpSlotsMapping[key]) || oldSlotsMapping[key].length !== cmpSlotsMapping[key].length) {
3430
3771
  markComponentAsDirty(vm);
3431
3772
  return;
3432
3773
  }
3433
3774
  var oldVNodes = oldSlotsMapping[key];
3434
- var vnodes = cmpSlotsMapping[key];
3775
+ var _vnodes = cmpSlotsMapping[key];
3435
3776
  for (var j = 0, a = cmpSlotsMapping[key].length; j < a; j += 1) {
3436
- if (oldVNodes[j] !== vnodes[j]) {
3777
+ if (oldVNodes[j] !== _vnodes[j]) {
3437
3778
  markComponentAsDirty(vm);
3438
3779
  return;
3439
3780
  }
@@ -3442,14 +3783,14 @@ var LWC = (function (exports) {
3442
3783
  }
3443
3784
  }
3444
3785
  // Using a WeakMap instead of a WeakSet because this one works in IE11 :(
3445
- var FromIteration = new WeakMap();
3446
- // dynamic children means it was generated by an iteration
3447
- // in a template, and will require a more complex diffing algo.
3786
+ var DynamicChildren = new WeakMap();
3787
+ // dynamic children means it was either generated by an iteration in a template
3788
+ // or part of an unstable fragment, and will require a more complex diffing algo.
3448
3789
  function markAsDynamicChildren(children) {
3449
- FromIteration.set(children, 1);
3790
+ DynamicChildren.set(children, 1);
3450
3791
  }
3451
3792
  function hasDynamicChildren(children) {
3452
- return FromIteration.has(children);
3793
+ return DynamicChildren.has(children);
3453
3794
  }
3454
3795
  function createKeyToOldIdx(children, beginIdx, endIdx) {
3455
3796
  var map = {};
@@ -3548,11 +3889,11 @@ var LWC = (function (exports) {
3548
3889
  if (oldStartIdx > oldEndIdx) {
3549
3890
  // There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
3550
3891
  // already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
3551
- var _i17 = newEndIdx;
3892
+ var _i21 = newEndIdx;
3552
3893
  var n;
3553
3894
  do {
3554
- n = newCh[++_i17];
3555
- } while (!isVNode(n) && _i17 < newChEnd);
3895
+ n = newCh[++_i21];
3896
+ } while (!isVNode(n) && _i21 < newChEnd);
3556
3897
  before = isVNode(n) ? n.elm : null;
3557
3898
  mountVNodes(newCh, parent, renderer, before, newStartIdx, newEndIdx + 1);
3558
3899
  } else {
@@ -3577,9 +3918,9 @@ var LWC = (function (exports) {
3577
3918
  // if the old list is not empty, the new list MUST have the same
3578
3919
  // amount of nodes, that's why we call this static children
3579
3920
  var anchor = null;
3580
- for (var _i18 = c2Length - 1; _i18 >= 0; _i18 -= 1) {
3581
- var n1 = c1[_i18];
3582
- var n2 = c2[_i18];
3921
+ for (var _i22 = c2Length - 1; _i22 >= 0; _i22 -= 1) {
3922
+ var n1 = c1[_i22];
3923
+ var n2 = c2[_i22];
3583
3924
  if (n2 !== n1) {
3584
3925
  if (isVNode(n1)) {
3585
3926
  if (isVNode(n2)) {
@@ -3676,8 +4017,8 @@ var LWC = (function (exports) {
3676
4017
  if (!isUndefined$1(slotset) && !isUndefined$1(slotset.slotAssignments) && !isUndefined$1(slotset.slotAssignments[slotName]) && slotset.slotAssignments[slotName].length !== 0) {
3677
4018
  var newChildren = [];
3678
4019
  var slotAssignments = slotset.slotAssignments[slotName];
3679
- for (var _i19 = 0; _i19 < slotAssignments.length; _i19++) {
3680
- var vnode = slotAssignments[_i19];
4020
+ for (var _i23 = 0; _i23 < slotAssignments.length; _i23++) {
4021
+ var vnode = slotAssignments[_i23];
3681
4022
  if (!isNull(vnode)) {
3682
4023
  var assignedNodeIsScopedSlot = isVScopedSlotFragment(vnode);
3683
4024
  // The only sniff test for a scoped <slot> element is the presence of `slotData`
@@ -4027,7 +4368,7 @@ var LWC = (function (exports) {
4027
4368
  }
4028
4369
  function buildParseFragmentFn(createFragmentFn) {
4029
4370
  return function (strings) {
4030
- for (var _len2 = arguments.length, keys = new Array(_len2 > 1 ? _len2 - 1 : 0), _key3 = 1; _key3 < _len2; _key3++) {
4371
+ for (var _len3 = arguments.length, keys = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
4031
4372
  keys[_key3 - 1] = arguments[_key3];
4032
4373
  }
4033
4374
  var cache = create(null);
@@ -4056,23 +4397,23 @@ var LWC = (function (exports) {
4056
4397
  var classAttrToken = hasScopedStyles && hasStyleToken ? " class=\"".concat(stylesheetToken, "\"") : '';
4057
4398
  var attrToken = hasStyleToken && isSyntheticShadow ? ' ' + stylesheetToken : '';
4058
4399
  var htmlFragment = '';
4059
- for (var _i20 = 0, n = keys.length; _i20 < n; _i20++) {
4060
- switch (keys[_i20]) {
4400
+ for (var _i24 = 0, n = keys.length; _i24 < n; _i24++) {
4401
+ switch (keys[_i24]) {
4061
4402
  case 0:
4062
4403
  // styleToken in existing class attr
4063
- htmlFragment += strings[_i20] + classToken;
4404
+ htmlFragment += strings[_i24] + classToken;
4064
4405
  break;
4065
4406
  case 1:
4066
4407
  // styleToken for added class attr
4067
- htmlFragment += strings[_i20] + classAttrToken;
4408
+ htmlFragment += strings[_i24] + classAttrToken;
4068
4409
  break;
4069
4410
  case 2:
4070
4411
  // styleToken as attr
4071
- htmlFragment += strings[_i20] + attrToken;
4412
+ htmlFragment += strings[_i24] + attrToken;
4072
4413
  break;
4073
4414
  case 3:
4074
4415
  // ${1}${2}
4075
- htmlFragment += strings[_i20] + classAttrToken + attrToken;
4416
+ htmlFragment += strings[_i24] + classAttrToken + attrToken;
4076
4417
  break;
4077
4418
  }
4078
4419
  }
@@ -4128,7 +4469,7 @@ var LWC = (function (exports) {
4128
4469
  // Create a brand new template cache for the swapped templated.
4129
4470
  context.tplCache = create(null);
4130
4471
  // Set the computeHasScopedStyles property in the context, to avoid recomputing it repeatedly.
4131
- context.hasScopedStyles = computeHasScopedStyles(html);
4472
+ context.hasScopedStyles = computeHasScopedStyles(html, vm);
4132
4473
  // Update the scoping token on the host element.
4133
4474
  updateStylesheetToken(vm, html);
4134
4475
  // Evaluate, create stylesheet and cache the produced VNode for future
@@ -4160,17 +4501,24 @@ var LWC = (function (exports) {
4160
4501
  });
4161
4502
  return vnodes;
4162
4503
  }
4163
- function computeHasScopedStyles(template) {
4164
- var stylesheets = template.stylesheets;
4165
- if (!isUndefined$1(stylesheets)) {
4166
- for (var _i21 = 0; _i21 < stylesheets.length; _i21++) {
4167
- if (isTrue(stylesheets[_i21][KEY__SCOPED_CSS])) {
4504
+ function computeHasScopedStylesInStylesheets(stylesheets) {
4505
+ if (hasStyles(stylesheets)) {
4506
+ for (var _i25 = 0; _i25 < stylesheets.length; _i25++) {
4507
+ if (isTrue(stylesheets[_i25][KEY__SCOPED_CSS])) {
4168
4508
  return true;
4169
4509
  }
4170
4510
  }
4171
4511
  }
4172
4512
  return false;
4173
4513
  }
4514
+ function computeHasScopedStyles(template, vm) {
4515
+ var stylesheets = template.stylesheets;
4516
+ var vmStylesheets = !isUndefined$1(vm) ? vm.stylesheets : null;
4517
+ return computeHasScopedStylesInStylesheets(stylesheets) || computeHasScopedStylesInStylesheets(vmStylesheets);
4518
+ }
4519
+ function hasStyles(stylesheets) {
4520
+ return !isUndefined$1(stylesheets) && !isNull(stylesheets) && stylesheets.length > 0;
4521
+ }
4174
4522
  var vmBeingConstructed = null;
4175
4523
  function isBeingConstructed(vm) {
4176
4524
  return vmBeingConstructed === vm;
@@ -4261,8 +4609,8 @@ var LWC = (function (exports) {
4261
4609
  */
4262
4610
  function registerComponent(
4263
4611
  // We typically expect a LightningElementConstructor, but technically you can call this with anything
4264
- Ctor, _ref3) {
4265
- var tmpl = _ref3.tmpl;
4612
+ Ctor, _ref4) {
4613
+ var tmpl = _ref4.tmpl;
4266
4614
  if (isFunction$1(Ctor)) {
4267
4615
  signedTemplateMap.set(Ctor, tmpl);
4268
4616
  }
@@ -4322,8 +4670,8 @@ var LWC = (function (exports) {
4322
4670
  * subject to change or being removed.
4323
4671
  */
4324
4672
  function register(service) {
4325
- for (var _i22 = 0; _i22 < hooks.length; ++_i22) {
4326
- var hookName = hooks[_i22];
4673
+ for (var _i26 = 0; _i26 < hooks.length; ++_i26) {
4674
+ var hookName = hooks[_i26];
4327
4675
  if (hookName in service) {
4328
4676
  var l = Services[hookName];
4329
4677
  if (isUndefined$1(l)) {
@@ -4337,8 +4685,8 @@ var LWC = (function (exports) {
4337
4685
  var component = vm.component,
4338
4686
  def = vm.def,
4339
4687
  context = vm.context;
4340
- for (var _i23 = 0, len = cbs.length; _i23 < len; ++_i23) {
4341
- cbs[_i23].call(undefined, component, {}, def, context);
4688
+ for (var _i27 = 0, len = cbs.length; _i27 < len; ++_i27) {
4689
+ cbs[_i27].call(undefined, component, {}, def, context);
4342
4690
  }
4343
4691
  }
4344
4692
 
@@ -4451,6 +4799,7 @@ var LWC = (function (exports) {
4451
4799
  // Properties set right after VM creation.
4452
4800
  tro: null,
4453
4801
  shadowMode: null,
4802
+ stylesheets: null,
4454
4803
  // Properties set by the LightningElement constructor.
4455
4804
  component: null,
4456
4805
  shadowRoot: null,
@@ -4460,6 +4809,7 @@ var LWC = (function (exports) {
4460
4809
  getHook: getHook,
4461
4810
  renderer: renderer
4462
4811
  };
4812
+ vm.stylesheets = computeStylesheets(vm, def.ctor);
4463
4813
  vm.shadowMode = computeShadowMode(vm, renderer);
4464
4814
  vm.tro = getTemplateReactiveObserver(vm);
4465
4815
  // Create component instance associated to the vm and the element.
@@ -4468,7 +4818,39 @@ var LWC = (function (exports) {
4468
4818
  if (hasWireAdapters(vm)) {
4469
4819
  installWireAdapters(vm);
4470
4820
  }
4471
- return vm;
4821
+ return vm;
4822
+ }
4823
+ function validateComponentStylesheets(vm, stylesheets) {
4824
+ var valid = true;
4825
+ var validate = function validate(arrayOrStylesheet) {
4826
+ if (isArray$1(arrayOrStylesheet)) {
4827
+ for (var _i28 = 0; _i28 < arrayOrStylesheet.length; _i28++) {
4828
+ validate(arrayOrStylesheet[_i28]);
4829
+ }
4830
+ } else if (!isFunction$1(arrayOrStylesheet)) {
4831
+ // function assumed to be a stylesheet factory
4832
+ valid = false;
4833
+ }
4834
+ };
4835
+ if (!isArray$1(stylesheets)) {
4836
+ valid = false;
4837
+ } else {
4838
+ validate(stylesheets);
4839
+ }
4840
+ return valid;
4841
+ }
4842
+ // Validate and flatten any stylesheets defined as `static stylesheets`
4843
+ function computeStylesheets(vm, ctor) {
4844
+ if (lwcRuntimeFlags.ENABLE_PROGRAMMATIC_STYLESHEETS) {
4845
+ var stylesheets = ctor.stylesheets;
4846
+ if (!isUndefined$1(stylesheets)) {
4847
+ var valid = validateComponentStylesheets(vm, stylesheets);
4848
+ if (valid) {
4849
+ return flattenStylesheets(stylesheets);
4850
+ }
4851
+ }
4852
+ }
4853
+ return null;
4472
4854
  }
4473
4855
  function computeShadowMode(vm, renderer) {
4474
4856
  var def = vm.def;
@@ -4578,17 +4960,17 @@ var LWC = (function (exports) {
4578
4960
  return a.idx - b.idx;
4579
4961
  });
4580
4962
  rehydrateQueue = []; // reset to a new queue
4581
- for (var _i24 = 0, len = vms.length; _i24 < len; _i24 += 1) {
4582
- var vm = vms[_i24];
4963
+ for (var _i29 = 0, len = vms.length; _i29 < len; _i29 += 1) {
4964
+ var vm = vms[_i29];
4583
4965
  try {
4584
4966
  rehydrate(vm);
4585
4967
  } catch (error) {
4586
- if (_i24 + 1 < len) {
4968
+ if (_i29 + 1 < len) {
4587
4969
  // pieces of the queue are still pending to be rehydrated, those should have priority
4588
4970
  if (rehydrateQueue.length === 0) {
4589
4971
  addCallbackToNextTick(flushRehydrationQueue);
4590
4972
  }
4591
- ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i24 + 1));
4973
+ ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i29 + 1));
4592
4974
  }
4593
4975
  // we need to end the measure before throwing.
4594
4976
  logGlobalOperationEnd(8 /* OperationId.GlobalRehydrate */);
@@ -4654,8 +5036,8 @@ var LWC = (function (exports) {
4654
5036
  var vCustomElementCollection = vm.velements;
4655
5037
  // Reporting disconnection for every child in inverse order since they are
4656
5038
  // inserted in reserved order.
4657
- for (var _i25 = vCustomElementCollection.length - 1; _i25 >= 0; _i25 -= 1) {
4658
- var elm = vCustomElementCollection[_i25].elm;
5039
+ for (var _i30 = vCustomElementCollection.length - 1; _i30 >= 0; _i30 -= 1) {
5040
+ var elm = vCustomElementCollection[_i30].elm;
4659
5041
  // There are two cases where the element could be undefined:
4660
5042
  // * when there is an error during the construction phase, and an error
4661
5043
  // boundary picks it, there is a possibility that the VCustomElement
@@ -4686,8 +5068,8 @@ var LWC = (function (exports) {
4686
5068
  * defined on its shadow.
4687
5069
  */
4688
5070
  function recursivelyDisconnectChildren(vnodes) {
4689
- for (var _i26 = 0, len = vnodes.length; _i26 < len; _i26 += 1) {
4690
- var vnode = vnodes[_i26];
5071
+ for (var _i31 = 0, len = vnodes.length; _i31 < len; _i31 += 1) {
5072
+ var vnode = vnodes[_i31];
4691
5073
  if (!isNull(vnode) && !isUndefined$1(vnode.elm)) {
4692
5074
  switch (vnode.type) {
4693
5075
  case 2 /* VNodeType.Element */:
@@ -4711,8 +5093,8 @@ var LWC = (function (exports) {
4711
5093
  var children = vm.children,
4712
5094
  renderRoot = vm.renderRoot,
4713
5095
  remove = vm.renderer.remove;
4714
- for (var _i27 = 0, len = children.length; _i27 < len; _i27++) {
4715
- var child = children[_i27];
5096
+ for (var _i32 = 0, len = children.length; _i32 < len; _i32++) {
5097
+ var child = children[_i32];
4716
5098
  if (!isNull(child) && !isUndefined$1(child.elm)) {
4717
5099
  remove(child.elm, renderRoot);
4718
5100
  }
@@ -4772,254 +5154,153 @@ var LWC = (function (exports) {
4772
5154
  * SPDX-License-Identifier: MIT
4773
5155
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4774
5156
  */
4775
- var DeprecatedWiredElementHost = '$$DeprecatedWiredElementHostKey$$';
4776
- var DeprecatedWiredParamsMeta = '$$DeprecatedWiredParamsMetaKey$$';
4777
- var WireMetaMap = new Map();
4778
- var WireContextRegistrationEvent = /*#__PURE__*/function (_CustomEvent) {
4779
- _inherits(WireContextRegistrationEvent, _CustomEvent);
4780
- var _super4 = _createSuper(WireContextRegistrationEvent);
4781
- function WireContextRegistrationEvent(adapterToken, _ref4) {
4782
- var _this2;
4783
- var setNewContext = _ref4.setNewContext,
4784
- setDisconnectedCallback = _ref4.setDisconnectedCallback;
4785
- _classCallCheck(this, WireContextRegistrationEvent);
4786
- _this2 = _super4.call(this, adapterToken, {
4787
- bubbles: true,
4788
- composed: true
4789
- });
4790
- defineProperties(_assertThisInitialized(_this2), {
4791
- setNewContext: {
4792
- value: setNewContext
4793
- },
4794
- setDisconnectedCallback: {
4795
- value: setDisconnectedCallback
4796
- }
4797
- });
4798
- return _this2;
5157
+ //
5158
+ // The goal of this code is to detect invalid cross-root ARIA references in synthetic shadow DOM.
5159
+ // These invalid references should be fixed before the offending components can be migrated to native shadow DOM.
5160
+ // When invalid usage is detected, we warn in dev mode and call the reporting API if enabled.
5161
+ // See: https://lwc.dev/guide/accessibility#link-ids-and-aria-attributes-from-different-templates
5162
+ //
5163
+ // Use the unpatched native getElementById/querySelectorAll rather than the synthetic one
5164
+ var getElementById = _globalThis[KEY__NATIVE_GET_ELEMENT_BY_ID];
5165
+ var querySelectorAll = _globalThis[KEY__NATIVE_QUERY_SELECTOR_ALL];
5166
+ function isSyntheticShadowRootInstance(rootNode) {
5167
+ return rootNode !== document && isTrue(rootNode.synthetic);
5168
+ }
5169
+ function reportViolation(source, target, attrName) {
5170
+ // The vm is either for the source, the target, or both. Either one or both must be using synthetic
5171
+ // shadow for a violation to be detected.
5172
+ var vm = getAssociatedVMIfPresent(source.getRootNode().host);
5173
+ if (isUndefined$1(vm)) {
5174
+ vm = getAssociatedVMIfPresent(target.getRootNode().host);
5175
+ }
5176
+ if (isUndefined$1(vm)) {
5177
+ // vm should never be undefined here, but just to be safe, bail out and don't report
5178
+ return;
4799
5179
  }
4800
- return _createClass(WireContextRegistrationEvent);
4801
- }( /*#__PURE__*/_wrapNativeSuper(CustomEvent));
4802
- function createFieldDataCallback(vm, name) {
4803
- return function (value) {
4804
- updateComponentValue(vm, name, value);
4805
- };
4806
- }
4807
- function createMethodDataCallback(vm, method) {
4808
- return function (value) {
4809
- // dispatching new value into the wired method
4810
- runWithBoundaryProtection(vm, vm.owner, noop, function () {
4811
- // job
4812
- method.call(vm.component, value);
4813
- }, noop);
4814
- };
5180
+ report(0 /* ReportingEventId.CrossRootAriaInSyntheticShadow */, vm);
4815
5181
  }
4816
- function createConfigWatcher(component, configCallback, callbackWhenConfigIsReady) {
4817
- var hasPendingConfig = false;
4818
- // creating the reactive observer for reactive params when needed
4819
- var ro = createReactiveObserver(function () {
4820
- if (hasPendingConfig === false) {
4821
- hasPendingConfig = true;
4822
- // collect new config in the micro-task
4823
- Promise.resolve().then(function () {
4824
- hasPendingConfig = false;
4825
- // resetting current reactive params
4826
- ro.reset();
4827
- // dispatching a new config due to a change in the configuration
4828
- computeConfigAndUpdate();
4829
- });
4830
- }
4831
- });
4832
- var computeConfigAndUpdate = function computeConfigAndUpdate() {
4833
- var config;
4834
- ro.observe(function () {
4835
- return config = configCallback(component);
4836
- });
4837
- // eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo
4838
- // TODO: dev-mode validation of config based on the adapter.configSchema
4839
- // @ts-ignore it is assigned in the observe() callback
4840
- callbackWhenConfigIsReady(config);
4841
- };
4842
- return {
4843
- computeConfigAndUpdate: computeConfigAndUpdate,
4844
- ro: ro
4845
- };
5182
+ function parseIdRefAttributeValue(attrValue) {
5183
+ // split on whitespace and skip empty strings after splitting
5184
+ return isString(attrValue) ? ArrayFilter.call(StringSplit.call(attrValue, /\s+/), Boolean) : [];
4846
5185
  }
4847
- function createContextWatcher(vm, wireDef, callbackWhenContextIsReady) {
4848
- var adapter = wireDef.adapter;
4849
- var adapterContextToken = getAdapterToken(adapter);
4850
- if (isUndefined$1(adapterContextToken)) {
4851
- return; // no provider found, nothing to be done
5186
+ function detectSyntheticCrossRootAria(elm, attrName, attrValue) {
5187
+ var root = elm.getRootNode();
5188
+ if (!isSyntheticShadowRootInstance(root)) {
5189
+ return;
4852
5190
  }
4853
-
4854
- var elm = vm.elm,
4855
- _vm$context = vm.context,
4856
- wiredConnecting = _vm$context.wiredConnecting,
4857
- wiredDisconnecting = _vm$context.wiredDisconnecting,
4858
- dispatchEvent = vm.renderer.dispatchEvent;
4859
- // waiting for the component to be connected to formally request the context via the token
4860
- ArrayPush$1.call(wiredConnecting, function () {
4861
- // This event is responsible for connecting the host element with another
4862
- // element in the composed path that is providing contextual data. The provider
4863
- // must be listening for a special dom event with the name corresponding to the value of
4864
- // `adapterContextToken`, which will remain secret and internal to this file only to
4865
- // guarantee that the linkage can be forged.
4866
- var contextRegistrationEvent = new WireContextRegistrationEvent(adapterContextToken, {
4867
- setNewContext: function setNewContext(newContext) {
4868
- // eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo
4869
- // TODO: dev-mode validation of config based on the adapter.contextSchema
4870
- callbackWhenContextIsReady(newContext);
4871
- },
4872
- setDisconnectedCallback: function setDisconnectedCallback(disconnectCallback) {
4873
- // adds this callback into the disconnect bucket so it gets disconnected from parent
4874
- // the the element hosting the wire is disconnected
4875
- ArrayPush$1.call(wiredDisconnecting, disconnectCallback);
5191
+ if (attrName === 'id') {
5192
+ // elm is the target, find the source
5193
+ if (!isString(attrValue) || attrValue.length === 0) {
5194
+ // if our id is null or empty, nobody can reference us
5195
+ return;
5196
+ }
5197
+ var _iterator5 = _createForOfIteratorHelper(ID_REFERENCING_ATTRIBUTES_SET),
5198
+ _step5;
5199
+ try {
5200
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
5201
+ var idRefAttrName = _step5.value;
5202
+ // Query all global elements with this attribute. The attribute selector syntax `~=` is for values
5203
+ // that reference multiple IDs, separated by whitespace.
5204
+ var query = "[".concat(idRefAttrName, "~=\"").concat(CSS.escape(attrValue), "\"]");
5205
+ var sourceElements = querySelectorAll.call(document, query);
5206
+ for (var _i33 = 0; _i33 < sourceElements.length; _i33++) {
5207
+ var sourceElement = sourceElements[_i33];
5208
+ var sourceRoot = sourceElement.getRootNode();
5209
+ if (sourceRoot !== root) {
5210
+ reportViolation(sourceElement, elm, idRefAttrName);
5211
+ break;
5212
+ }
5213
+ }
4876
5214
  }
4877
- });
4878
- dispatchEvent(elm, contextRegistrationEvent);
4879
- });
4880
- }
4881
- function createConnector(vm, name, wireDef) {
4882
- var method = wireDef.method,
4883
- adapter = wireDef.adapter,
4884
- configCallback = wireDef.configCallback,
4885
- dynamic = wireDef.dynamic;
4886
- var debugInfo;
4887
- var fieldOrMethodCallback = isUndefined$1(method) ? createFieldDataCallback(vm, name) : createMethodDataCallback(vm, method);
4888
- var dataCallback = function dataCallback(value) {
4889
- fieldOrMethodCallback(value);
4890
- };
4891
- var context;
4892
- var connector;
4893
- // Workaround to pass the component element associated to this wire adapter instance.
4894
- defineProperty(dataCallback, DeprecatedWiredElementHost, {
4895
- value: vm.elm
4896
- });
4897
- defineProperty(dataCallback, DeprecatedWiredParamsMeta, {
4898
- value: dynamic
4899
- });
4900
- runWithBoundaryProtection(vm, vm, noop, function () {
4901
- // job
4902
- connector = new adapter(dataCallback);
4903
- }, noop);
4904
- var updateConnectorConfig = function updateConnectorConfig(config) {
4905
- // every time the config is recomputed due to tracking,
4906
- // this callback will be invoked with the new computed config
4907
- runWithBoundaryProtection(vm, vm, noop, function () {
4908
- // job
4909
- if ("production" !== 'production') ;
4910
- connector.update(config, context);
4911
- }, noop);
4912
- };
4913
- // Computes the current wire config and calls the update method on the wire adapter.
4914
- // If it has params, we will need to observe changes in the next tick.
4915
- var _createConfigWatcher = createConfigWatcher(vm.component, configCallback, updateConnectorConfig),
4916
- computeConfigAndUpdate = _createConfigWatcher.computeConfigAndUpdate,
4917
- ro = _createConfigWatcher.ro;
4918
- // if the adapter needs contextualization, we need to watch for new context and push it alongside the config
4919
- if (!isUndefined$1(adapter.contextSchema)) {
4920
- createContextWatcher(vm, wireDef, function (newContext) {
4921
- // every time the context is pushed into this component,
4922
- // this callback will be invoked with the new computed context
4923
- if (context !== newContext) {
4924
- context = newContext;
4925
- // Note: when new context arrives, the config will be recomputed and pushed along side the new
4926
- // context, this is to preserve the identity characteristics, config should not have identity
4927
- // (ever), while context can have identity
4928
- if (vm.state === 1 /* VMState.connected */) {
4929
- computeConfigAndUpdate();
5215
+ } catch (err) {
5216
+ _iterator5.e(err);
5217
+ } finally {
5218
+ _iterator5.f();
5219
+ }
5220
+ } else {
5221
+ // elm is the source, find the target
5222
+ var ids = parseIdRefAttributeValue(attrValue);
5223
+ var _iterator6 = _createForOfIteratorHelper(ids),
5224
+ _step6;
5225
+ try {
5226
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
5227
+ var id = _step6.value;
5228
+ var target = getElementById.call(document, id);
5229
+ if (!isNull(target)) {
5230
+ var targetRoot = target.getRootNode();
5231
+ if (targetRoot !== root) {
5232
+ // target element's shadow root is not the same as ours
5233
+ reportViolation(elm, target, attrName);
5234
+ }
4930
5235
  }
4931
5236
  }
4932
- });
4933
- }
4934
- return {
4935
- // @ts-ignore the boundary protection executes sync, connector is always defined
4936
- connector: connector,
4937
- computeConfigAndUpdate: computeConfigAndUpdate,
4938
- resetConfigWatcher: function resetConfigWatcher() {
4939
- return ro.reset();
5237
+ } catch (err) {
5238
+ _iterator6.e(err);
5239
+ } finally {
5240
+ _iterator6.f();
4940
5241
  }
4941
- };
4942
- }
4943
- var AdapterToTokenMap = new Map();
4944
- function getAdapterToken(adapter) {
4945
- return AdapterToTokenMap.get(adapter);
4946
- }
4947
- function setAdapterToken(adapter, token) {
4948
- AdapterToTokenMap.set(adapter, token);
4949
- }
4950
- function storeWiredMethodMeta(descriptor, adapter, configCallback, dynamic) {
4951
- // support for callable adapters
4952
- if (adapter.adapter) {
4953
- adapter = adapter.adapter;
4954
5242
  }
4955
- var method = descriptor.value;
4956
- var def = {
4957
- adapter: adapter,
4958
- method: method,
4959
- configCallback: configCallback,
4960
- dynamic: dynamic
4961
- };
4962
- WireMetaMap.set(descriptor, def);
4963
5243
  }
4964
- function storeWiredFieldMeta(descriptor, adapter, configCallback, dynamic) {
4965
- // support for callable adapters
4966
- if (adapter.adapter) {
4967
- adapter = adapter.adapter;
5244
+ var enabled = false;
5245
+ // We want to avoid patching globals whenever possible, so this should be tree-shaken out in prod-mode and if
5246
+ // reporting is not enabled. It should also only run once
5247
+ function enableDetection() {
5248
+ if (enabled) {
5249
+ return; // don't double-apply the patches
4968
5250
  }
4969
- var def = {
4970
- adapter: adapter,
4971
- configCallback: configCallback,
4972
- dynamic: dynamic
4973
- };
4974
- WireMetaMap.set(descriptor, def);
4975
- }
4976
- function installWireAdapters(vm) {
4977
- var context = vm.context,
4978
- wire = vm.def.wire;
4979
- var wiredConnecting = context.wiredConnecting = [];
4980
- var wiredDisconnecting = context.wiredDisconnecting = [];
4981
- for (var fieldNameOrMethod in wire) {
4982
- var descriptor = wire[fieldNameOrMethod];
4983
- var wireDef = WireMetaMap.get(descriptor);
4984
- if (!isUndefined$1(wireDef)) {
4985
- (function () {
4986
- var _createConnector = createConnector(vm, fieldNameOrMethod, wireDef),
4987
- connector = _createConnector.connector,
4988
- computeConfigAndUpdate = _createConnector.computeConfigAndUpdate,
4989
- resetConfigWatcher = _createConnector.resetConfigWatcher;
4990
- var hasDynamicParams = wireDef.dynamic.length > 0;
4991
- ArrayPush$1.call(wiredConnecting, function () {
4992
- connector.connect();
4993
- if (!lwcRuntimeFlags.ENABLE_WIRE_SYNC_EMIT) {
4994
- if (hasDynamicParams) {
4995
- Promise.resolve().then(computeConfigAndUpdate);
4996
- return;
4997
- }
4998
- }
4999
- computeConfigAndUpdate();
5000
- });
5001
- ArrayPush$1.call(wiredDisconnecting, function () {
5002
- connector.disconnect();
5003
- resetConfigWatcher();
5004
- });
5005
- })();
5251
+
5252
+ enabled = true;
5253
+ var _setAttribute = Element.prototype.setAttribute;
5254
+ // Detect calling `setAttribute` to set an idref or an id
5255
+ assign(Element.prototype, {
5256
+ setAttribute: function setAttribute(attrName, attrValue) {
5257
+ _setAttribute.call(this, attrName, attrValue);
5258
+ if (attrName === 'id' || ID_REFERENCING_ATTRIBUTES_SET.has(attrName)) {
5259
+ detectSyntheticCrossRootAria(this, attrName, attrValue);
5260
+ }
5261
+ }
5262
+ });
5263
+ // Detect `elm.id = 'foo'`
5264
+ var idDescriptor = getOwnPropertyDescriptor$1(Element.prototype, 'id');
5265
+ if (!isUndefined$1(idDescriptor)) {
5266
+ var _get3 = idDescriptor.get,
5267
+ _set3 = idDescriptor.set;
5268
+ // These should always be a getter and a setter, but if someone is monkeying with the global descriptor, ignore it
5269
+ if (isFunction$1(_get3) && isFunction$1(_set3)) {
5270
+ defineProperty(Element.prototype, 'id', {
5271
+ get: function get() {
5272
+ return _get3.call(this);
5273
+ },
5274
+ set: function set(value) {
5275
+ _set3.call(this, value);
5276
+ detectSyntheticCrossRootAria(this, 'id', value);
5277
+ },
5278
+ // On the default descriptor for 'id', enumerable and configurable are true
5279
+ enumerable: true,
5280
+ configurable: true
5281
+ });
5006
5282
  }
5007
5283
  }
5008
5284
  }
5009
- function connectWireAdapters(vm) {
5010
- var wiredConnecting = vm.context.wiredConnecting;
5011
- for (var _i28 = 0, len = wiredConnecting.length; _i28 < len; _i28 += 1) {
5012
- wiredConnecting[_i28]();
5013
- }
5285
+ // Our detection logic relies on some modern browser features. We can just skip reporting the data
5286
+ // for unsupported browsers
5287
+ function supportsCssEscape() {
5288
+ return typeof CSS !== 'undefined' && isFunction$1(CSS.escape);
5014
5289
  }
5015
- function disconnectWireAdapters(vm) {
5016
- var wiredDisconnecting = vm.context.wiredDisconnecting;
5017
- runWithBoundaryProtection(vm, vm, noop, function () {
5018
- // job
5019
- for (var _i29 = 0, len = wiredDisconnecting.length; _i29 < len; _i29 += 1) {
5020
- wiredDisconnecting[_i29]();
5021
- }
5022
- }, noop);
5290
+ // If this page is not using synthetic shadow, then we don't need to install detection. Note
5291
+ // that we are assuming synthetic shadow is loaded before LWC.
5292
+ function isSyntheticShadowLoaded() {
5293
+ // We should probably be calling `renderer.isSyntheticShadowDefined`, but 1) we don't have access to the renderer,
5294
+ // and 2) this code needs to run in @lwc/engine-core, so it can access `logWarn()` and `report()`.
5295
+ return hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN);
5296
+ }
5297
+ // Detecting cross-root ARIA in synthetic shadow only makes sense for the browser
5298
+ if (supportsCssEscape() && isSyntheticShadowLoaded()) {
5299
+ // Always run detection in dev mode, so we can at least print to the console
5300
+ {
5301
+ // In prod mode, only enable detection if reporting is enabled
5302
+ onReportingEnabled(enableDetection);
5303
+ }
5023
5304
  }
5024
5305
 
5025
5306
  /*
@@ -5227,8 +5508,8 @@ var LWC = (function (exports) {
5227
5508
  var nextNode = node;
5228
5509
  var anchor = null;
5229
5510
  var renderer = owner.renderer;
5230
- for (var _i30 = 0; _i30 < children.length; _i30++) {
5231
- var childVnode = children[_i30];
5511
+ for (var _i34 = 0; _i34 < children.length; _i34++) {
5512
+ var childVnode = children[_i34];
5232
5513
  if (!isNull(childVnode)) {
5233
5514
  if (nextNode) {
5234
5515
  nextNode = hydrateNode(nextNode, childVnode, renderer);
@@ -5289,8 +5570,8 @@ var LWC = (function (exports) {
5289
5570
  var nodesAreCompatible = true;
5290
5571
  // Validate attributes, though we could always recovery from those by running the update mods.
5291
5572
  // Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
5292
- for (var _i31 = 0, _Object$entries = Object.entries(attrs); _i31 < _Object$entries.length; _i31++) {
5293
- var _Object$entries$_i = _slicedToArray(_Object$entries[_i31], 2),
5573
+ for (var _i35 = 0, _Object$entries = Object.entries(attrs); _i35 < _Object$entries.length; _i35++) {
5574
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i35], 2),
5294
5575
  attrName = _Object$entries$_i[0],
5295
5576
  attrValue = _Object$entries$_i[1];
5296
5577
  vnode.owner;
@@ -5377,8 +5658,8 @@ var LWC = (function (exports) {
5377
5658
  var parsedVnodeStyle = parseStyleText(elmStyle);
5378
5659
  var expectedStyle = [];
5379
5660
  // styleMap is used when style is set to static value.
5380
- for (var _i32 = 0, n = styleDecls.length; _i32 < n; _i32++) {
5381
- var _styleDecls$_i2 = _slicedToArray(styleDecls[_i32], 3),
5661
+ for (var _i36 = 0, n = styleDecls.length; _i36 < n; _i36++) {
5662
+ var _styleDecls$_i2 = _slicedToArray(styleDecls[_i36], 3),
5382
5663
  prop = _styleDecls$_i2[0],
5383
5664
  value = _styleDecls$_i2[1],
5384
5665
  important = _styleDecls$_i2[2];
@@ -5452,8 +5733,8 @@ var LWC = (function (exports) {
5452
5733
  // Deep-traverse an array (of arrays) of stylesheet factory functions, and call the callback for every array/function
5453
5734
  function traverseStylesheets(stylesheets, callback) {
5454
5735
  callback(stylesheets);
5455
- for (var _i33 = 0; _i33 < stylesheets.length; _i33++) {
5456
- var stylesheet = stylesheets[_i33];
5736
+ for (var _i37 = 0; _i37 < stylesheets.length; _i37++) {
5737
+ var stylesheet = stylesheets[_i37];
5457
5738
  if (isArray$1(stylesheet)) {
5458
5739
  traverseStylesheets(stylesheet, callback);
5459
5740
  } else {
@@ -6114,17 +6395,17 @@ var LWC = (function (exports) {
6114
6395
  function flushPendingWhenDefinedCallbacks(tagName, ctor) {
6115
6396
  var resolvers = pendingWhenDefinedCallbacks.get(tagName);
6116
6397
  if (!isUndefined$1(resolvers)) {
6117
- var _iterator7 = _createForOfIteratorHelper(resolvers),
6118
- _step7;
6398
+ var _iterator10 = _createForOfIteratorHelper(resolvers),
6399
+ _step10;
6119
6400
  try {
6120
- for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
6121
- var resolver = _step7.value;
6401
+ for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
6402
+ var resolver = _step10.value;
6122
6403
  resolver(ctor);
6123
6404
  }
6124
6405
  } catch (err) {
6125
- _iterator7.e(err);
6406
+ _iterator10.e(err);
6126
6407
  } finally {
6127
- _iterator7.f();
6408
+ _iterator10.f();
6128
6409
  }
6129
6410
  }
6130
6411
  pendingWhenDefinedCallbacks.delete(tagName);
@@ -6174,11 +6455,11 @@ var LWC = (function (exports) {
6174
6455
  var awaiting = awaitingUpgrade.get(tagName);
6175
6456
  if (!isUndefined$1(awaiting)) {
6176
6457
  awaitingUpgrade.delete(tagName);
6177
- var _iterator8 = _createForOfIteratorHelper(awaiting),
6178
- _step8;
6458
+ var _iterator11 = _createForOfIteratorHelper(awaiting),
6459
+ _step11;
6179
6460
  try {
6180
- for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
6181
- var element = _step8.value;
6461
+ for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
6462
+ var element = _step11.value;
6182
6463
  var registeredDefinition = pendingRegistryForElement.get(element);
6183
6464
  // At this point, registeredDefinition should never be undefined because awaitingUpgrade
6184
6465
  // is only populated when we haven't run internalUpgrade yet, and we only populate
@@ -6190,9 +6471,9 @@ var LWC = (function (exports) {
6190
6471
  }
6191
6472
  }
6192
6473
  } catch (err) {
6193
- _iterator8.e(err);
6474
+ _iterator11.e(err);
6194
6475
  } finally {
6195
- _iterator8.f();
6476
+ _iterator11.f();
6196
6477
  }
6197
6478
  }
6198
6479
  // If anyone called customElements.whenDefined() and is still waiting for a promise resolution, resolve now
@@ -6469,7 +6750,7 @@ var LWC = (function (exports) {
6469
6750
  function isNull(obj) {
6470
6751
  return obj === null;
6471
6752
  }
6472
- /** version: 2.33.0 */
6753
+ /** version: 2.35.0 */
6473
6754
 
6474
6755
  /*
6475
6756
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6528,17 +6809,17 @@ var LWC = (function (exports) {
6528
6809
  exports.createFragment = function (html) {
6529
6810
  var wrapperTags = topLevelWrappingMap[getTagName(html)];
6530
6811
  if (!isUndefined(wrapperTags)) {
6531
- var _iterator9 = _createForOfIteratorHelper(wrapperTags),
6532
- _step9;
6812
+ var _iterator12 = _createForOfIteratorHelper(wrapperTags),
6813
+ _step12;
6533
6814
  try {
6534
- for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
6535
- var wrapperTag = _step9.value;
6815
+ for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
6816
+ var wrapperTag = _step12.value;
6536
6817
  html = "<".concat(wrapperTag, ">").concat(html, "</").concat(wrapperTag, ">");
6537
6818
  }
6538
6819
  } catch (err) {
6539
- _iterator9.e(err);
6820
+ _iterator12.e(err);
6540
6821
  } finally {
6541
- _iterator9.f();
6822
+ _iterator12.f();
6542
6823
  }
6543
6824
  }
6544
6825
  // For IE11, the document title must not be undefined, but it can be an empty string
@@ -6547,7 +6828,7 @@ var LWC = (function (exports) {
6547
6828
  doc.body.innerHTML = html;
6548
6829
  var content = doc.body;
6549
6830
  if (!isUndefined(wrapperTags)) {
6550
- for (var _i34 = 0; _i34 < wrapperTags.length; _i34++) {
6831
+ for (var _i38 = 0; _i38 < wrapperTags.length; _i38++) {
6551
6832
  content = content.firstChild;
6552
6833
  }
6553
6834
  }
@@ -6740,8 +7021,8 @@ var LWC = (function (exports) {
6740
7021
  tagName: element.tagName.toLowerCase(),
6741
7022
  hydrated: true
6742
7023
  });
6743
- for (var _i35 = 0, _Object$entries2 = Object.entries(props); _i35 < _Object$entries2.length; _i35++) {
6744
- var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i35], 2),
7024
+ for (var _i39 = 0, _Object$entries2 = Object.entries(props); _i39 < _Object$entries2.length; _i39++) {
7025
+ var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i39], 2),
6745
7026
  key = _Object$entries2$_i[0],
6746
7027
  value = _Object$entries2$_i[1];
6747
7028
  element[key] = value;
@@ -7028,10 +7309,11 @@ var LWC = (function (exports) {
7028
7309
  });
7029
7310
  freeze(LightningElement);
7030
7311
  seal(LightningElement.prototype);
7031
- /* version: 2.33.0 */
7312
+ /* version: 2.35.0 */
7032
7313
 
7033
7314
  exports.LightningElement = LightningElement;
7034
7315
  exports.__unstable__ProfilerControl = profilerControl;
7316
+ exports.__unstable__ReportingControl = reportingControl;
7035
7317
  exports.api = api$1;
7036
7318
  exports.buildCustomElementConstructor = deprecatedBuildCustomElementConstructor;
7037
7319
  exports.createContextProvider = createContextProvider;