lwc 2.34.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 +742 -493
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +742 -492
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +777 -641
  5. package/dist/engine-dom/iife/es5/engine-dom.js +882 -618
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +732 -579
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +742 -492
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +777 -641
  11. package/dist/engine-dom/umd/es5/engine-dom.js +882 -618
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +732 -579
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +635 -603
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +635 -603
  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; }
@@ -100,6 +100,7 @@ var LWC = (function (exports) {
100
100
  var _String$prototype = String.prototype,
101
101
  StringCharCodeAt = _String$prototype.charCodeAt,
102
102
  StringReplace = _String$prototype.replace,
103
+ StringSplit = _String$prototype.split,
103
104
  StringSlice = _String$prototype.slice,
104
105
  StringToLowerCase = _String$prototype.toLowerCase;
105
106
  function isUndefined$1(obj) {
@@ -192,6 +193,9 @@ var LWC = (function (exports) {
192
193
  }(),
193
194
  AriaAttrNameToPropNameMap = _ref.AriaAttrNameToPropNameMap,
194
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']);
195
199
 
196
200
  /*
197
201
  * Copyright (c) 2018, salesforce.com, inc.
@@ -245,6 +249,8 @@ var LWC = (function (exports) {
245
249
  var KEY__SHADOW_TOKEN = '$shadowToken$';
246
250
  var KEY__SYNTHETIC_MODE = '$$lwc-synthetic-mode';
247
251
  var KEY__SCOPED_CSS = '$scoped$';
252
+ var KEY__NATIVE_GET_ELEMENT_BY_ID = '$nativeGetElementById$';
253
+ var KEY__NATIVE_QUERY_SELECTOR_ALL = '$nativeQuerySelectorAll$';
248
254
  var XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
249
255
  var SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
250
256
  var XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
@@ -332,7 +338,7 @@ var LWC = (function (exports) {
332
338
  CACHED_ATTRIBUTE_PROPERTY_MAPPING.set(attrName, propertyName);
333
339
  return propertyName;
334
340
  }
335
- /** version: 2.34.0 */
341
+ /** version: 2.35.0 */
336
342
 
337
343
  /**
338
344
  * Copyright (C) 2018 salesforce.com, inc.
@@ -403,7 +409,7 @@ var LWC = (function (exports) {
403
409
  */
404
410
  function setFeatureFlagForTest(name, value) {
405
411
  }
406
- /** version: 2.34.0 */
412
+ /** version: 2.35.0 */
407
413
 
408
414
  /**
409
415
  * Copyright (C) 2018 salesforce.com, inc.
@@ -467,7 +473,7 @@ var LWC = (function (exports) {
467
473
  }
468
474
  }
469
475
  }
470
- /** version: 2.34.0 */
476
+ /** version: 2.35.0 */
471
477
 
472
478
  /*
473
479
  * Copyright (c) 2018, salesforce.com, inc.
@@ -487,99 +493,153 @@ var LWC = (function (exports) {
487
493
  * SPDX-License-Identifier: MIT
488
494
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
489
495
  */
490
- var nextTickCallbackQueue = [];
491
- var SPACE_CHAR = 32;
492
- var EmptyObject = seal(create(null));
493
- var EmptyArray = seal([]);
494
- function flushCallbackQueue() {
495
- var callbacks = nextTickCallbackQueue;
496
- nextTickCallbackQueue = []; // reset to a new queue
497
- for (var _i3 = 0, len = callbacks.length; _i3 < len; _i3 += 1) {
498
- 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);
499
556
  }
500
557
  }
501
- function addCallbackToNextTick(callback) {
502
- if (nextTickCallbackQueue.length === 0) {
503
- 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);
504
566
  }
505
- ArrayPush$1.call(nextTickCallbackQueue, callback);
506
567
  }
507
- function guid() {
508
- function s4() {
509
- 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';
510
586
  }
511
- return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
587
+ return ArrayJoin.call(stack, '\n');
512
588
  }
513
- // Borrowed from Vue template compiler.
514
- // https://github.com/vuejs/vue/blob/531371b818b0e31a989a06df43789728f23dc4e8/src/platforms/web/util/style.js#L5-L16
515
- var DECLARATION_DELIMITER = /;(?![^(]*\))/g;
516
- var PROPERTY_DELIMITER = /:(.+)/;
517
- function parseStyleText(cssText) {
518
- var styleMap = {};
519
- var declarations = cssText.split(DECLARATION_DELIMITER);
520
- var _iterator = _createForOfIteratorHelper(declarations),
521
- _step;
522
- try {
523
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
524
- var declaration = _step.value;
525
- if (declaration) {
526
- var _declaration$split = declaration.split(PROPERTY_DELIMITER),
527
- _declaration$split2 = _slicedToArray(_declaration$split, 2),
528
- prop = _declaration$split2[0],
529
- value = _declaration$split2[1];
530
- if (prop !== undefined && value !== undefined) {
531
- styleMap[prop.trim()] = value.trim();
532
- }
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;
533
611
  }
534
- }
535
- } catch (err) {
536
- _iterator.e(err);
537
- } finally {
538
- _iterator.f();
612
+ });
539
613
  }
540
- return styleMap;
541
614
  }
542
- // Make a shallow copy of an object but omit the given key
543
- function cloneAndOmitKey(object, keyToOmit) {
544
- var result = {};
545
- for (var _i4 = 0, _Object$keys = Object.keys(object); _i4 < _Object$keys.length; _i4++) {
546
- var key = _Object$keys[_i4];
547
- if (key !== keyToOmit) {
548
- 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;
549
631
  }
632
+ alreadyLoggedMessages.add(msg);
550
633
  }
551
- return result;
552
- }
553
- function flattenStylesheets(stylesheets) {
554
- var list = [];
555
- var _iterator2 = _createForOfIteratorHelper(stylesheets),
556
- _step2;
557
634
  try {
558
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
559
- var stylesheet = _step2.value;
560
- if (!Array.isArray(stylesheet)) {
561
- list.push(stylesheet);
562
- } else {
563
- list.push.apply(list, _toConsumableArray(flattenStylesheets(stylesheet)));
564
- }
565
- }
566
- } catch (err) {
567
- _iterator2.e(err);
568
- } finally {
569
- _iterator2.f();
635
+ throw new Error(msg);
636
+ } catch (e) {
637
+ /* eslint-disable-next-line no-console */
638
+ console[method](e);
570
639
  }
571
- return list;
572
640
  }
573
- // Set a ref (lwc:ref) on a VM, from a template API
574
- function setRefVNode(vm, ref, vnode) {
575
- // If this method is called, then vm.refVNodes is set as the template has refs.
576
- // If not, then something went wrong and we threw an error above.
577
- var refVNodes = vm.refVNodes;
578
- // In cases of conflict (two elements with the same ref), prefer, the last one,
579
- // in depth-first traversal order.
580
- if (!(ref in refVNodes) || refVNodes[ref].key < vnode.key) {
581
- refVNodes[ref] = vnode;
582
- }
641
+ function logError(message, vm) {
642
+ log('error', message, vm, false);
583
643
  }
584
644
 
585
645
  /*
@@ -604,8 +664,8 @@ var LWC = (function (exports) {
604
664
  if (!isUndefined$1(reactiveRecord)) {
605
665
  var reactiveObservers = reactiveRecord[key];
606
666
  if (!isUndefined$1(reactiveObservers)) {
607
- for (var _i5 = 0, len = reactiveObservers.length; _i5 < len; _i5 += 1) {
608
- var ro = reactiveObservers[_i5];
667
+ for (var _i3 = 0, len = reactiveObservers.length; _i3 < len; _i3 += 1) {
668
+ var ro = reactiveObservers[_i3];
609
669
  ro.notify();
610
670
  }
611
671
  }
@@ -664,9 +724,9 @@ var LWC = (function (exports) {
664
724
  var listeners = this.listeners;
665
725
  var len = listeners.length;
666
726
  if (len > 0) {
667
- for (var _i6 = 0; _i6 < len; _i6 += 1) {
668
- var set = listeners[_i6];
669
- 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);
670
730
  ArraySplice.call(set, pos, 1);
671
731
  }
672
732
  listeners.length = 0;
@@ -711,67 +771,99 @@ var LWC = (function (exports) {
711
771
  * SPDX-License-Identifier: MIT
712
772
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
713
773
  */
714
- function getComponentTag(vm) {
715
- 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
+ }
716
784
  }
717
- // TODO [#1695]: Unify getComponentStack and getErrorComponentStack
718
- function getComponentStack(vm) {
719
- var stack = [];
720
- var prefix = '';
721
- while (!isNull(vm.owner)) {
722
- ArrayPush$1.call(stack, prefix + getComponentTag(vm));
723
- vm = vm.owner;
724
- prefix += '\t';
785
+ function addCallbackToNextTick(callback) {
786
+ if (nextTickCallbackQueue.length === 0) {
787
+ Promise.resolve().then(flushCallbackQueue);
725
788
  }
726
- return ArrayJoin.call(stack, '\n');
789
+ ArrayPush$1.call(nextTickCallbackQueue, callback);
727
790
  }
728
- function getErrorComponentStack(vm) {
729
- var wcStack = [];
730
- var currentVm = vm;
731
- while (!isNull(currentVm)) {
732
- ArrayPush$1.call(wcStack, getComponentTag(currentVm));
733
- currentVm = currentVm.owner;
791
+ function guid() {
792
+ function s4() {
793
+ return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
734
794
  }
735
- return wcStack.reverse().join('\n\t');
795
+ return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
736
796
  }
737
-
738
- /*
739
- * Copyright (c) 2018, salesforce.com, inc.
740
- * All rights reserved.
741
- * SPDX-License-Identifier: MIT
742
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
743
- */
744
- function addErrorComponentStack(vm, error) {
745
- if (!isFrozen(error) && isUndefined$1(error.wcStack)) {
746
- var wcStack = getErrorComponentStack(vm);
747
- defineProperty(error, 'wcStack', {
748
- get: function get() {
749
- 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
+ }
750
817
  }
751
- });
818
+ }
819
+ } catch (err) {
820
+ _iterator2.e(err);
821
+ } finally {
822
+ _iterator2.f();
752
823
  }
824
+ return styleMap;
753
825
  }
754
-
755
- /*
756
- * Copyright (c) 2018, salesforce.com, inc.
757
- * All rights reserved.
758
- * SPDX-License-Identifier: MIT
759
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
760
- */
761
- function log(method, message, vm) {
762
- var msg = "[LWC ".concat(method, "]: ").concat(message);
763
- if (!isUndefined$1(vm)) {
764
- 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
+ }
765
834
  }
835
+ return result;
836
+ }
837
+ function flattenStylesheets(stylesheets) {
838
+ var list = [];
839
+ var _iterator3 = _createForOfIteratorHelper(stylesheets),
840
+ _step3;
766
841
  try {
767
- throw new Error(msg);
768
- } catch (e) {
769
- /* eslint-disable-next-line no-console */
770
- 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();
771
854
  }
855
+ return list;
772
856
  }
773
- function logError(message, vm) {
774
- 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
+ }
775
867
  }
776
868
 
777
869
  /*
@@ -792,116 +884,21 @@ var LWC = (function (exports) {
792
884
  * Copyright (c) 2018, salesforce.com, inc.
793
885
  * All rights reserved.
794
886
  * SPDX-License-Identifier: MIT
795
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
796
- */
797
- // This is a temporary workaround to get the @lwc/engine-server to evaluate in node without having
798
- // to inject at runtime.
799
- var HTMLElementConstructor = typeof HTMLElement !== 'undefined' ? HTMLElement : function () {};
800
- var HTMLElementPrototype = HTMLElementConstructor.prototype;
801
-
802
- /*
803
- * Copyright (c) 2018, salesforce.com, inc.
804
- * All rights reserved.
805
- * SPDX-License-Identifier: MIT
806
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
807
- */
808
- // These properties get added to LWCElement.prototype publicProps automatically
809
- var defaultDefHTMLPropertyNames = ['accessKey', 'dir', 'draggable', 'hidden', 'id', 'lang', 'spellcheck', 'tabIndex', 'title'];
810
- function offsetPropertyErrorMessage(name) {
811
- 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.");
812
- }
813
- // Global HTML Attributes & Properties
814
- // https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes
815
- // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement
816
- //
817
- // If you update this list, check for test files that recapitulate the same list. Searching the codebase
818
- // for e.g. "dropzone" should suffice.
819
- assign(create(null), {
820
- accessKey: {
821
- attribute: 'accesskey'
822
- },
823
- accessKeyLabel: {
824
- readOnly: true
825
- },
826
- className: {
827
- attribute: 'class',
828
- 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.'
829
- },
830
- contentEditable: {
831
- attribute: 'contenteditable'
832
- },
833
- dataset: {
834
- readOnly: true,
835
- 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."
836
- },
837
- dir: {
838
- attribute: 'dir'
839
- },
840
- draggable: {
841
- attribute: 'draggable'
842
- },
843
- dropzone: {
844
- attribute: 'dropzone',
845
- readOnly: true
846
- },
847
- hidden: {
848
- attribute: 'hidden'
849
- },
850
- id: {
851
- attribute: 'id'
852
- },
853
- inputMode: {
854
- attribute: 'inputmode'
855
- },
856
- lang: {
857
- attribute: 'lang'
858
- },
859
- slot: {
860
- attribute: 'slot',
861
- error: 'Using the `slot` property is an anti-pattern.'
862
- },
863
- spellcheck: {
864
- attribute: 'spellcheck'
865
- },
866
- style: {
867
- attribute: 'style'
868
- },
869
- tabIndex: {
870
- attribute: 'tabindex'
871
- },
872
- title: {
873
- attribute: 'title'
874
- },
875
- translate: {
876
- attribute: 'translate'
877
- },
878
- // additional "global attributes" that are not present in the link above.
879
- isContentEditable: {
880
- readOnly: true
881
- },
882
- offsetHeight: {
883
- readOnly: true,
884
- error: offsetPropertyErrorMessage('offsetHeight')
885
- },
886
- offsetLeft: {
887
- readOnly: true,
888
- error: offsetPropertyErrorMessage('offsetLeft')
889
- },
890
- offsetParent: {
891
- readOnly: true
892
- },
893
- offsetTop: {
894
- readOnly: true,
895
- error: offsetPropertyErrorMessage('offsetTop')
896
- },
897
- offsetWidth: {
898
- readOnly: true,
899
- error: offsetPropertyErrorMessage('offsetWidth')
900
- },
901
- role: {
902
- attribute: 'role'
903
- }
904
- });
887
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
888
+ */
889
+ // This is a temporary workaround to get the @lwc/engine-server to evaluate in node without having
890
+ // to inject at runtime.
891
+ var HTMLElementConstructor = typeof HTMLElement !== 'undefined' ? HTMLElement : function () {};
892
+ var HTMLElementPrototype = HTMLElementConstructor.prototype;
893
+
894
+ /*
895
+ * Copyright (c) 2018, salesforce.com, inc.
896
+ * All rights reserved.
897
+ * SPDX-License-Identifier: MIT
898
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
899
+ */
900
+ // These properties get added to LWCElement.prototype publicProps automatically
901
+ var defaultDefHTMLPropertyNames = ['accessKey', 'dir', 'draggable', 'hidden', 'id', 'lang', 'spellcheck', 'tabIndex', 'title'];
905
902
  var controlledElement = null;
906
903
  var controlledAttributeName;
907
904
  function isAttributeLocked(elm, attrName) {
@@ -1755,17 +1752,17 @@ var LWC = (function (exports) {
1755
1752
  var refs = refsCache.get(refVNodes);
1756
1753
  if (isUndefined$1(refs)) {
1757
1754
  refs = create(null);
1758
- var _iterator3 = _createForOfIteratorHelper(keys(refVNodes)),
1759
- _step3;
1755
+ var _iterator4 = _createForOfIteratorHelper(keys(refVNodes)),
1756
+ _step4;
1760
1757
  try {
1761
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
1762
- var key = _step3.value;
1758
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
1759
+ var key = _step4.value;
1763
1760
  refs[key] = refVNodes[key].elm;
1764
1761
  }
1765
1762
  } catch (err) {
1766
- _iterator3.e(err);
1763
+ _iterator4.e(err);
1767
1764
  } finally {
1768
- _iterator3.f();
1765
+ _iterator4.f();
1769
1766
  }
1770
1767
  freeze(refs);
1771
1768
  refsCache.set(refVNodes, refs);
@@ -1885,6 +1882,262 @@ var LWC = (function (exports) {
1885
1882
  };
1886
1883
  }
1887
1884
 
1885
+ /*
1886
+ * Copyright (c) 2018, salesforce.com, inc.
1887
+ * All rights reserved.
1888
+ * SPDX-License-Identifier: MIT
1889
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1890
+ */
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
1912
+ }
1913
+ });
1914
+ return _this2;
1915
+ }
1916
+ return _createClass(WireContextRegistrationEvent);
1917
+ }( /*#__PURE__*/_wrapNativeSuper(CustomEvent));
1918
+ function createFieldDataCallback(vm, name) {
1919
+ return function (value) {
1920
+ updateComponentValue(vm, name, value);
1921
+ };
1922
+ }
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);
1930
+ };
1931
+ }
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
+ return {
1959
+ computeConfigAndUpdate: computeConfigAndUpdate,
1960
+ ro: ro
1961
+ };
1962
+ }
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
1968
+ }
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);
1992
+ }
1993
+ });
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
+
1888
2141
  /*
1889
2142
  * Copyright (c) 2018, salesforce.com, inc.
1890
2143
  * All rights reserved.
@@ -2082,8 +2335,8 @@ var LWC = (function (exports) {
2082
2335
  }
2083
2336
  }
2084
2337
  if (!isUndefined$1(fields)) {
2085
- for (var _i8 = 0, n = fields.length; _i8 < n; _i8++) {
2086
- var _fieldName2 = fields[_i8];
2338
+ for (var _i10 = 0, n = fields.length; _i10 < n; _i10++) {
2339
+ var _fieldName2 = fields[_i10];
2087
2340
  descriptor = getOwnPropertyDescriptor$1(proto, _fieldName2);
2088
2341
  // [W-9927596] Only mark a field as observed whenever it isn't a duplicated public nor
2089
2342
  // tracked property. This is only here for backward compatibility purposes.
@@ -2234,10 +2487,10 @@ var LWC = (function (exports) {
2234
2487
  if (isFunction$1(SuperClass)) {
2235
2488
  HTMLBridgeElement = /*#__PURE__*/function (_SuperClass) {
2236
2489
  _inherits(HTMLBridgeElement, _SuperClass);
2237
- var _super3 = _createSuper(HTMLBridgeElement);
2490
+ var _super4 = _createSuper(HTMLBridgeElement);
2238
2491
  function HTMLBridgeElement() {
2239
2492
  _classCallCheck(this, HTMLBridgeElement);
2240
- return _super3.apply(this, arguments);
2493
+ return _super4.apply(this, arguments);
2241
2494
  }
2242
2495
  return _createClass(HTMLBridgeElement);
2243
2496
  }(SuperClass);
@@ -2264,8 +2517,8 @@ var LWC = (function (exports) {
2264
2517
  superObservedAttributes = _SuperClass$observedA === void 0 ? [] : _SuperClass$observedA;
2265
2518
  var descriptors = create(null);
2266
2519
  // expose getters and setters for each public props on the new Element Bridge
2267
- for (var _i9 = 0, len = props.length; _i9 < len; _i9 += 1) {
2268
- var _propName = props[_i9];
2520
+ for (var _i11 = 0, len = props.length; _i11 < len; _i11 += 1) {
2521
+ var _propName = props[_i11];
2269
2522
  attributeToPropMap[htmlPropertyToAttribute(_propName)] = _propName;
2270
2523
  descriptors[_propName] = {
2271
2524
  get: createGetter(_propName),
@@ -2275,8 +2528,8 @@ var LWC = (function (exports) {
2275
2528
  };
2276
2529
  }
2277
2530
  // expose public methods as props on the new Element Bridge
2278
- for (var _i10 = 0, _len = methods.length; _i10 < _len; _i10 += 1) {
2279
- var methodName = methods[_i10];
2531
+ for (var _i12 = 0, _len = methods.length; _i12 < _len; _i12 += 1) {
2532
+ var methodName = methods[_i12];
2280
2533
  descriptors[methodName] = {
2281
2534
  value: createMethodCaller(methodName),
2282
2535
  writable: true,
@@ -2594,8 +2847,8 @@ var LWC = (function (exports) {
2594
2847
  function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
2595
2848
  var content = [];
2596
2849
  var root;
2597
- for (var _i11 = 0; _i11 < stylesheets.length; _i11++) {
2598
- var stylesheet = stylesheets[_i11];
2850
+ for (var _i13 = 0; _i13 < stylesheets.length; _i13++) {
2851
+ var stylesheet = stylesheets[_i13];
2599
2852
  if (isArray$1(stylesheet)) {
2600
2853
  ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, stylesheetToken, vm));
2601
2854
  } else {
@@ -2695,8 +2948,8 @@ var LWC = (function (exports) {
2695
2948
  shadowMode = vm.shadowMode,
2696
2949
  insertStylesheet = vm.renderer.insertStylesheet;
2697
2950
  if (renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */) {
2698
- for (var _i12 = 0; _i12 < stylesheets.length; _i12++) {
2699
- insertStylesheet(stylesheets[_i12]);
2951
+ for (var _i14 = 0; _i14 < stylesheets.length; _i14++) {
2952
+ insertStylesheet(stylesheets[_i14]);
2700
2953
  }
2701
2954
  } else if (vm.hydrated) {
2702
2955
  // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
@@ -2709,8 +2962,8 @@ var LWC = (function (exports) {
2709
2962
  var root = getNearestNativeShadowComponent(vm);
2710
2963
  // null root means a global style
2711
2964
  var target = isNull(root) ? undefined : root.shadowRoot;
2712
- for (var _i13 = 0; _i13 < stylesheets.length; _i13++) {
2713
- insertStylesheet(stylesheets[_i13], target);
2965
+ for (var _i15 = 0; _i15 < stylesheets.length; _i15++) {
2966
+ insertStylesheet(stylesheets[_i15], target);
2714
2967
  }
2715
2968
  }
2716
2969
  return null;
@@ -3012,8 +3265,8 @@ var LWC = (function (exports) {
3012
3265
  return;
3013
3266
  }
3014
3267
  var setCSSStyleProperty = renderer.setCSSStyleProperty;
3015
- for (var _i14 = 0; _i14 < styleDecls.length; _i14++) {
3016
- var _styleDecls$_i = _slicedToArray(styleDecls[_i14], 3),
3268
+ for (var _i16 = 0; _i16 < styleDecls.length; _i16++) {
3269
+ var _styleDecls$_i = _slicedToArray(styleDecls[_i16], 3),
3017
3270
  prop = _styleDecls$_i[0],
3018
3271
  value = _styleDecls$_i[1],
3019
3272
  important = _styleDecls$_i[2];
@@ -3436,8 +3689,8 @@ var LWC = (function (exports) {
3436
3689
  // If no VFragment is found in children, we don't need to traverse anything or mark the children dynamic and can return early.
3437
3690
  var nodeStack = [];
3438
3691
  var fragmentFound = false;
3439
- for (var _i15 = children.length - 1; _i15 > -1; _i15 -= 1) {
3440
- var child = children[_i15];
3692
+ for (var _i17 = children.length - 1; _i17 > -1; _i17 -= 1) {
3693
+ var child = children[_i17];
3441
3694
  ArrayPush$1.call(nodeStack, child);
3442
3695
  fragmentFound = fragmentFound || !!(child && isVFragment(child));
3443
3696
  }
@@ -3449,8 +3702,8 @@ var LWC = (function (exports) {
3449
3702
  if (!isNull(currentNode) && isVFragment(currentNode)) {
3450
3703
  var fChildren = currentNode.children;
3451
3704
  // Ignore the start and end text node delimiters
3452
- for (var _i16 = fChildren.length - 2; _i16 > 0; _i16 -= 1) {
3453
- ArrayPush$1.call(nodeStack, fChildren[_i16]);
3705
+ for (var _i18 = fChildren.length - 2; _i18 > 0; _i18 -= 1) {
3706
+ ArrayPush$1.call(nodeStack, fChildren[_i18]);
3454
3707
  }
3455
3708
  } else {
3456
3709
  ArrayPush$1.call(flattenedChildren, currentNode);
@@ -3486,8 +3739,8 @@ var LWC = (function (exports) {
3486
3739
  var oldSlotsMapping = vm.cmpSlots.slotAssignments;
3487
3740
  var cmpSlotsMapping = create(null);
3488
3741
  // Collect all slots into cmpSlotsMapping
3489
- for (var _i17 = 0, len = children.length; _i17 < len; _i17 += 1) {
3490
- var vnode = children[_i17];
3742
+ for (var _i19 = 0, len = children.length; _i19 < len; _i19 += 1) {
3743
+ var vnode = children[_i19];
3491
3744
  if (isNull(vnode)) {
3492
3745
  continue;
3493
3746
  }
@@ -3512,8 +3765,8 @@ var LWC = (function (exports) {
3512
3765
  markComponentAsDirty(vm);
3513
3766
  return;
3514
3767
  }
3515
- for (var _i18 = 0, _len2 = oldKeys.length; _i18 < _len2; _i18 += 1) {
3516
- var key = oldKeys[_i18];
3768
+ for (var _i20 = 0, _len2 = oldKeys.length; _i20 < _len2; _i20 += 1) {
3769
+ var key = oldKeys[_i20];
3517
3770
  if (isUndefined$1(cmpSlotsMapping[key]) || oldSlotsMapping[key].length !== cmpSlotsMapping[key].length) {
3518
3771
  markComponentAsDirty(vm);
3519
3772
  return;
@@ -3636,11 +3889,11 @@ var LWC = (function (exports) {
3636
3889
  if (oldStartIdx > oldEndIdx) {
3637
3890
  // There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
3638
3891
  // already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
3639
- var _i19 = newEndIdx;
3892
+ var _i21 = newEndIdx;
3640
3893
  var n;
3641
3894
  do {
3642
- n = newCh[++_i19];
3643
- } while (!isVNode(n) && _i19 < newChEnd);
3895
+ n = newCh[++_i21];
3896
+ } while (!isVNode(n) && _i21 < newChEnd);
3644
3897
  before = isVNode(n) ? n.elm : null;
3645
3898
  mountVNodes(newCh, parent, renderer, before, newStartIdx, newEndIdx + 1);
3646
3899
  } else {
@@ -3665,9 +3918,9 @@ var LWC = (function (exports) {
3665
3918
  // if the old list is not empty, the new list MUST have the same
3666
3919
  // amount of nodes, that's why we call this static children
3667
3920
  var anchor = null;
3668
- for (var _i20 = c2Length - 1; _i20 >= 0; _i20 -= 1) {
3669
- var n1 = c1[_i20];
3670
- var n2 = c2[_i20];
3921
+ for (var _i22 = c2Length - 1; _i22 >= 0; _i22 -= 1) {
3922
+ var n1 = c1[_i22];
3923
+ var n2 = c2[_i22];
3671
3924
  if (n2 !== n1) {
3672
3925
  if (isVNode(n1)) {
3673
3926
  if (isVNode(n2)) {
@@ -3764,8 +4017,8 @@ var LWC = (function (exports) {
3764
4017
  if (!isUndefined$1(slotset) && !isUndefined$1(slotset.slotAssignments) && !isUndefined$1(slotset.slotAssignments[slotName]) && slotset.slotAssignments[slotName].length !== 0) {
3765
4018
  var newChildren = [];
3766
4019
  var slotAssignments = slotset.slotAssignments[slotName];
3767
- for (var _i21 = 0; _i21 < slotAssignments.length; _i21++) {
3768
- var vnode = slotAssignments[_i21];
4020
+ for (var _i23 = 0; _i23 < slotAssignments.length; _i23++) {
4021
+ var vnode = slotAssignments[_i23];
3769
4022
  if (!isNull(vnode)) {
3770
4023
  var assignedNodeIsScopedSlot = isVScopedSlotFragment(vnode);
3771
4024
  // The only sniff test for a scoped <slot> element is the presence of `slotData`
@@ -4144,23 +4397,23 @@ var LWC = (function (exports) {
4144
4397
  var classAttrToken = hasScopedStyles && hasStyleToken ? " class=\"".concat(stylesheetToken, "\"") : '';
4145
4398
  var attrToken = hasStyleToken && isSyntheticShadow ? ' ' + stylesheetToken : '';
4146
4399
  var htmlFragment = '';
4147
- for (var _i22 = 0, n = keys.length; _i22 < n; _i22++) {
4148
- switch (keys[_i22]) {
4400
+ for (var _i24 = 0, n = keys.length; _i24 < n; _i24++) {
4401
+ switch (keys[_i24]) {
4149
4402
  case 0:
4150
4403
  // styleToken in existing class attr
4151
- htmlFragment += strings[_i22] + classToken;
4404
+ htmlFragment += strings[_i24] + classToken;
4152
4405
  break;
4153
4406
  case 1:
4154
4407
  // styleToken for added class attr
4155
- htmlFragment += strings[_i22] + classAttrToken;
4408
+ htmlFragment += strings[_i24] + classAttrToken;
4156
4409
  break;
4157
4410
  case 2:
4158
4411
  // styleToken as attr
4159
- htmlFragment += strings[_i22] + attrToken;
4412
+ htmlFragment += strings[_i24] + attrToken;
4160
4413
  break;
4161
4414
  case 3:
4162
4415
  // ${1}${2}
4163
- htmlFragment += strings[_i22] + classAttrToken + attrToken;
4416
+ htmlFragment += strings[_i24] + classAttrToken + attrToken;
4164
4417
  break;
4165
4418
  }
4166
4419
  }
@@ -4250,8 +4503,8 @@ var LWC = (function (exports) {
4250
4503
  }
4251
4504
  function computeHasScopedStylesInStylesheets(stylesheets) {
4252
4505
  if (hasStyles(stylesheets)) {
4253
- for (var _i23 = 0; _i23 < stylesheets.length; _i23++) {
4254
- if (isTrue(stylesheets[_i23][KEY__SCOPED_CSS])) {
4506
+ for (var _i25 = 0; _i25 < stylesheets.length; _i25++) {
4507
+ if (isTrue(stylesheets[_i25][KEY__SCOPED_CSS])) {
4255
4508
  return true;
4256
4509
  }
4257
4510
  }
@@ -4356,8 +4609,8 @@ var LWC = (function (exports) {
4356
4609
  */
4357
4610
  function registerComponent(
4358
4611
  // We typically expect a LightningElementConstructor, but technically you can call this with anything
4359
- Ctor, _ref3) {
4360
- var tmpl = _ref3.tmpl;
4612
+ Ctor, _ref4) {
4613
+ var tmpl = _ref4.tmpl;
4361
4614
  if (isFunction$1(Ctor)) {
4362
4615
  signedTemplateMap.set(Ctor, tmpl);
4363
4616
  }
@@ -4417,8 +4670,8 @@ var LWC = (function (exports) {
4417
4670
  * subject to change or being removed.
4418
4671
  */
4419
4672
  function register(service) {
4420
- for (var _i24 = 0; _i24 < hooks.length; ++_i24) {
4421
- var hookName = hooks[_i24];
4673
+ for (var _i26 = 0; _i26 < hooks.length; ++_i26) {
4674
+ var hookName = hooks[_i26];
4422
4675
  if (hookName in service) {
4423
4676
  var l = Services[hookName];
4424
4677
  if (isUndefined$1(l)) {
@@ -4432,8 +4685,8 @@ var LWC = (function (exports) {
4432
4685
  var component = vm.component,
4433
4686
  def = vm.def,
4434
4687
  context = vm.context;
4435
- for (var _i25 = 0, len = cbs.length; _i25 < len; ++_i25) {
4436
- cbs[_i25].call(undefined, component, {}, def, context);
4688
+ for (var _i27 = 0, len = cbs.length; _i27 < len; ++_i27) {
4689
+ cbs[_i27].call(undefined, component, {}, def, context);
4437
4690
  }
4438
4691
  }
4439
4692
 
@@ -4571,8 +4824,8 @@ var LWC = (function (exports) {
4571
4824
  var valid = true;
4572
4825
  var validate = function validate(arrayOrStylesheet) {
4573
4826
  if (isArray$1(arrayOrStylesheet)) {
4574
- for (var _i26 = 0; _i26 < arrayOrStylesheet.length; _i26++) {
4575
- validate(arrayOrStylesheet[_i26]);
4827
+ for (var _i28 = 0; _i28 < arrayOrStylesheet.length; _i28++) {
4828
+ validate(arrayOrStylesheet[_i28]);
4576
4829
  }
4577
4830
  } else if (!isFunction$1(arrayOrStylesheet)) {
4578
4831
  // function assumed to be a stylesheet factory
@@ -4707,17 +4960,17 @@ var LWC = (function (exports) {
4707
4960
  return a.idx - b.idx;
4708
4961
  });
4709
4962
  rehydrateQueue = []; // reset to a new queue
4710
- for (var _i27 = 0, len = vms.length; _i27 < len; _i27 += 1) {
4711
- var vm = vms[_i27];
4963
+ for (var _i29 = 0, len = vms.length; _i29 < len; _i29 += 1) {
4964
+ var vm = vms[_i29];
4712
4965
  try {
4713
4966
  rehydrate(vm);
4714
4967
  } catch (error) {
4715
- if (_i27 + 1 < len) {
4968
+ if (_i29 + 1 < len) {
4716
4969
  // pieces of the queue are still pending to be rehydrated, those should have priority
4717
4970
  if (rehydrateQueue.length === 0) {
4718
4971
  addCallbackToNextTick(flushRehydrationQueue);
4719
4972
  }
4720
- ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i27 + 1));
4973
+ ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i29 + 1));
4721
4974
  }
4722
4975
  // we need to end the measure before throwing.
4723
4976
  logGlobalOperationEnd(8 /* OperationId.GlobalRehydrate */);
@@ -4783,8 +5036,8 @@ var LWC = (function (exports) {
4783
5036
  var vCustomElementCollection = vm.velements;
4784
5037
  // Reporting disconnection for every child in inverse order since they are
4785
5038
  // inserted in reserved order.
4786
- for (var _i28 = vCustomElementCollection.length - 1; _i28 >= 0; _i28 -= 1) {
4787
- var elm = vCustomElementCollection[_i28].elm;
5039
+ for (var _i30 = vCustomElementCollection.length - 1; _i30 >= 0; _i30 -= 1) {
5040
+ var elm = vCustomElementCollection[_i30].elm;
4788
5041
  // There are two cases where the element could be undefined:
4789
5042
  // * when there is an error during the construction phase, and an error
4790
5043
  // boundary picks it, there is a possibility that the VCustomElement
@@ -4815,8 +5068,8 @@ var LWC = (function (exports) {
4815
5068
  * defined on its shadow.
4816
5069
  */
4817
5070
  function recursivelyDisconnectChildren(vnodes) {
4818
- for (var _i29 = 0, len = vnodes.length; _i29 < len; _i29 += 1) {
4819
- var vnode = vnodes[_i29];
5071
+ for (var _i31 = 0, len = vnodes.length; _i31 < len; _i31 += 1) {
5072
+ var vnode = vnodes[_i31];
4820
5073
  if (!isNull(vnode) && !isUndefined$1(vnode.elm)) {
4821
5074
  switch (vnode.type) {
4822
5075
  case 2 /* VNodeType.Element */:
@@ -4840,8 +5093,8 @@ var LWC = (function (exports) {
4840
5093
  var children = vm.children,
4841
5094
  renderRoot = vm.renderRoot,
4842
5095
  remove = vm.renderer.remove;
4843
- for (var _i30 = 0, len = children.length; _i30 < len; _i30++) {
4844
- var child = children[_i30];
5096
+ for (var _i32 = 0, len = children.length; _i32 < len; _i32++) {
5097
+ var child = children[_i32];
4845
5098
  if (!isNull(child) && !isUndefined$1(child.elm)) {
4846
5099
  remove(child.elm, renderRoot);
4847
5100
  }
@@ -4901,254 +5154,153 @@ var LWC = (function (exports) {
4901
5154
  * SPDX-License-Identifier: MIT
4902
5155
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4903
5156
  */
4904
- var DeprecatedWiredElementHost = '$$DeprecatedWiredElementHostKey$$';
4905
- var DeprecatedWiredParamsMeta = '$$DeprecatedWiredParamsMetaKey$$';
4906
- var WireMetaMap = new Map();
4907
- var WireContextRegistrationEvent = /*#__PURE__*/function (_CustomEvent) {
4908
- _inherits(WireContextRegistrationEvent, _CustomEvent);
4909
- var _super4 = _createSuper(WireContextRegistrationEvent);
4910
- function WireContextRegistrationEvent(adapterToken, _ref4) {
4911
- var _this2;
4912
- var setNewContext = _ref4.setNewContext,
4913
- setDisconnectedCallback = _ref4.setDisconnectedCallback;
4914
- _classCallCheck(this, WireContextRegistrationEvent);
4915
- _this2 = _super4.call(this, adapterToken, {
4916
- bubbles: true,
4917
- composed: true
4918
- });
4919
- defineProperties(_assertThisInitialized(_this2), {
4920
- setNewContext: {
4921
- value: setNewContext
4922
- },
4923
- setDisconnectedCallback: {
4924
- value: setDisconnectedCallback
4925
- }
4926
- });
4927
- 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;
4928
5179
  }
4929
- return _createClass(WireContextRegistrationEvent);
4930
- }( /*#__PURE__*/_wrapNativeSuper(CustomEvent));
4931
- function createFieldDataCallback(vm, name) {
4932
- return function (value) {
4933
- updateComponentValue(vm, name, value);
4934
- };
4935
- }
4936
- function createMethodDataCallback(vm, method) {
4937
- return function (value) {
4938
- // dispatching new value into the wired method
4939
- runWithBoundaryProtection(vm, vm.owner, noop, function () {
4940
- // job
4941
- method.call(vm.component, value);
4942
- }, noop);
4943
- };
5180
+ report(0 /* ReportingEventId.CrossRootAriaInSyntheticShadow */, vm);
4944
5181
  }
4945
- function createConfigWatcher(component, configCallback, callbackWhenConfigIsReady) {
4946
- var hasPendingConfig = false;
4947
- // creating the reactive observer for reactive params when needed
4948
- var ro = createReactiveObserver(function () {
4949
- if (hasPendingConfig === false) {
4950
- hasPendingConfig = true;
4951
- // collect new config in the micro-task
4952
- Promise.resolve().then(function () {
4953
- hasPendingConfig = false;
4954
- // resetting current reactive params
4955
- ro.reset();
4956
- // dispatching a new config due to a change in the configuration
4957
- computeConfigAndUpdate();
4958
- });
4959
- }
4960
- });
4961
- var computeConfigAndUpdate = function computeConfigAndUpdate() {
4962
- var config;
4963
- ro.observe(function () {
4964
- return config = configCallback(component);
4965
- });
4966
- // eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo
4967
- // TODO: dev-mode validation of config based on the adapter.configSchema
4968
- // @ts-ignore it is assigned in the observe() callback
4969
- callbackWhenConfigIsReady(config);
4970
- };
4971
- return {
4972
- computeConfigAndUpdate: computeConfigAndUpdate,
4973
- ro: ro
4974
- };
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) : [];
4975
5185
  }
4976
- function createContextWatcher(vm, wireDef, callbackWhenContextIsReady) {
4977
- var adapter = wireDef.adapter;
4978
- var adapterContextToken = getAdapterToken(adapter);
4979
- if (isUndefined$1(adapterContextToken)) {
4980
- 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;
4981
5190
  }
4982
-
4983
- var elm = vm.elm,
4984
- _vm$context = vm.context,
4985
- wiredConnecting = _vm$context.wiredConnecting,
4986
- wiredDisconnecting = _vm$context.wiredDisconnecting,
4987
- dispatchEvent = vm.renderer.dispatchEvent;
4988
- // waiting for the component to be connected to formally request the context via the token
4989
- ArrayPush$1.call(wiredConnecting, function () {
4990
- // This event is responsible for connecting the host element with another
4991
- // element in the composed path that is providing contextual data. The provider
4992
- // must be listening for a special dom event with the name corresponding to the value of
4993
- // `adapterContextToken`, which will remain secret and internal to this file only to
4994
- // guarantee that the linkage can be forged.
4995
- var contextRegistrationEvent = new WireContextRegistrationEvent(adapterContextToken, {
4996
- setNewContext: function setNewContext(newContext) {
4997
- // eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo
4998
- // TODO: dev-mode validation of config based on the adapter.contextSchema
4999
- callbackWhenContextIsReady(newContext);
5000
- },
5001
- setDisconnectedCallback: function setDisconnectedCallback(disconnectCallback) {
5002
- // adds this callback into the disconnect bucket so it gets disconnected from parent
5003
- // the the element hosting the wire is disconnected
5004
- 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
+ }
5005
5214
  }
5006
- });
5007
- dispatchEvent(elm, contextRegistrationEvent);
5008
- });
5009
- }
5010
- function createConnector(vm, name, wireDef) {
5011
- var method = wireDef.method,
5012
- adapter = wireDef.adapter,
5013
- configCallback = wireDef.configCallback,
5014
- dynamic = wireDef.dynamic;
5015
- var debugInfo;
5016
- var fieldOrMethodCallback = isUndefined$1(method) ? createFieldDataCallback(vm, name) : createMethodDataCallback(vm, method);
5017
- var dataCallback = function dataCallback(value) {
5018
- fieldOrMethodCallback(value);
5019
- };
5020
- var context;
5021
- var connector;
5022
- // Workaround to pass the component element associated to this wire adapter instance.
5023
- defineProperty(dataCallback, DeprecatedWiredElementHost, {
5024
- value: vm.elm
5025
- });
5026
- defineProperty(dataCallback, DeprecatedWiredParamsMeta, {
5027
- value: dynamic
5028
- });
5029
- runWithBoundaryProtection(vm, vm, noop, function () {
5030
- // job
5031
- connector = new adapter(dataCallback);
5032
- }, noop);
5033
- var updateConnectorConfig = function updateConnectorConfig(config) {
5034
- // every time the config is recomputed due to tracking,
5035
- // this callback will be invoked with the new computed config
5036
- runWithBoundaryProtection(vm, vm, noop, function () {
5037
- // job
5038
- if ("production" !== 'production') ;
5039
- connector.update(config, context);
5040
- }, noop);
5041
- };
5042
- // Computes the current wire config and calls the update method on the wire adapter.
5043
- // If it has params, we will need to observe changes in the next tick.
5044
- var _createConfigWatcher = createConfigWatcher(vm.component, configCallback, updateConnectorConfig),
5045
- computeConfigAndUpdate = _createConfigWatcher.computeConfigAndUpdate,
5046
- ro = _createConfigWatcher.ro;
5047
- // if the adapter needs contextualization, we need to watch for new context and push it alongside the config
5048
- if (!isUndefined$1(adapter.contextSchema)) {
5049
- createContextWatcher(vm, wireDef, function (newContext) {
5050
- // every time the context is pushed into this component,
5051
- // this callback will be invoked with the new computed context
5052
- if (context !== newContext) {
5053
- context = newContext;
5054
- // Note: when new context arrives, the config will be recomputed and pushed along side the new
5055
- // context, this is to preserve the identity characteristics, config should not have identity
5056
- // (ever), while context can have identity
5057
- if (vm.state === 1 /* VMState.connected */) {
5058
- 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
+ }
5059
5235
  }
5060
5236
  }
5061
- });
5062
- }
5063
- return {
5064
- // @ts-ignore the boundary protection executes sync, connector is always defined
5065
- connector: connector,
5066
- computeConfigAndUpdate: computeConfigAndUpdate,
5067
- resetConfigWatcher: function resetConfigWatcher() {
5068
- return ro.reset();
5237
+ } catch (err) {
5238
+ _iterator6.e(err);
5239
+ } finally {
5240
+ _iterator6.f();
5069
5241
  }
5070
- };
5071
- }
5072
- var AdapterToTokenMap = new Map();
5073
- function getAdapterToken(adapter) {
5074
- return AdapterToTokenMap.get(adapter);
5075
- }
5076
- function setAdapterToken(adapter, token) {
5077
- AdapterToTokenMap.set(adapter, token);
5078
- }
5079
- function storeWiredMethodMeta(descriptor, adapter, configCallback, dynamic) {
5080
- // support for callable adapters
5081
- if (adapter.adapter) {
5082
- adapter = adapter.adapter;
5083
5242
  }
5084
- var method = descriptor.value;
5085
- var def = {
5086
- adapter: adapter,
5087
- method: method,
5088
- configCallback: configCallback,
5089
- dynamic: dynamic
5090
- };
5091
- WireMetaMap.set(descriptor, def);
5092
5243
  }
5093
- function storeWiredFieldMeta(descriptor, adapter, configCallback, dynamic) {
5094
- // support for callable adapters
5095
- if (adapter.adapter) {
5096
- 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
5097
5250
  }
5098
- var def = {
5099
- adapter: adapter,
5100
- configCallback: configCallback,
5101
- dynamic: dynamic
5102
- };
5103
- WireMetaMap.set(descriptor, def);
5104
- }
5105
- function installWireAdapters(vm) {
5106
- var context = vm.context,
5107
- wire = vm.def.wire;
5108
- var wiredConnecting = context.wiredConnecting = [];
5109
- var wiredDisconnecting = context.wiredDisconnecting = [];
5110
- for (var fieldNameOrMethod in wire) {
5111
- var descriptor = wire[fieldNameOrMethod];
5112
- var wireDef = WireMetaMap.get(descriptor);
5113
- if (!isUndefined$1(wireDef)) {
5114
- (function () {
5115
- var _createConnector = createConnector(vm, fieldNameOrMethod, wireDef),
5116
- connector = _createConnector.connector,
5117
- computeConfigAndUpdate = _createConnector.computeConfigAndUpdate,
5118
- resetConfigWatcher = _createConnector.resetConfigWatcher;
5119
- var hasDynamicParams = wireDef.dynamic.length > 0;
5120
- ArrayPush$1.call(wiredConnecting, function () {
5121
- connector.connect();
5122
- if (!lwcRuntimeFlags.ENABLE_WIRE_SYNC_EMIT) {
5123
- if (hasDynamicParams) {
5124
- Promise.resolve().then(computeConfigAndUpdate);
5125
- return;
5126
- }
5127
- }
5128
- computeConfigAndUpdate();
5129
- });
5130
- ArrayPush$1.call(wiredDisconnecting, function () {
5131
- connector.disconnect();
5132
- resetConfigWatcher();
5133
- });
5134
- })();
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
+ });
5135
5282
  }
5136
5283
  }
5137
5284
  }
5138
- function connectWireAdapters(vm) {
5139
- var wiredConnecting = vm.context.wiredConnecting;
5140
- for (var _i31 = 0, len = wiredConnecting.length; _i31 < len; _i31 += 1) {
5141
- wiredConnecting[_i31]();
5142
- }
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);
5143
5289
  }
5144
- function disconnectWireAdapters(vm) {
5145
- var wiredDisconnecting = vm.context.wiredDisconnecting;
5146
- runWithBoundaryProtection(vm, vm, noop, function () {
5147
- // job
5148
- for (var _i32 = 0, len = wiredDisconnecting.length; _i32 < len; _i32 += 1) {
5149
- wiredDisconnecting[_i32]();
5150
- }
5151
- }, 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
+ }
5152
5304
  }
5153
5305
 
5154
5306
  /*
@@ -5356,8 +5508,8 @@ var LWC = (function (exports) {
5356
5508
  var nextNode = node;
5357
5509
  var anchor = null;
5358
5510
  var renderer = owner.renderer;
5359
- for (var _i33 = 0; _i33 < children.length; _i33++) {
5360
- var childVnode = children[_i33];
5511
+ for (var _i34 = 0; _i34 < children.length; _i34++) {
5512
+ var childVnode = children[_i34];
5361
5513
  if (!isNull(childVnode)) {
5362
5514
  if (nextNode) {
5363
5515
  nextNode = hydrateNode(nextNode, childVnode, renderer);
@@ -5418,8 +5570,8 @@ var LWC = (function (exports) {
5418
5570
  var nodesAreCompatible = true;
5419
5571
  // Validate attributes, though we could always recovery from those by running the update mods.
5420
5572
  // Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
5421
- for (var _i34 = 0, _Object$entries = Object.entries(attrs); _i34 < _Object$entries.length; _i34++) {
5422
- var _Object$entries$_i = _slicedToArray(_Object$entries[_i34], 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),
5423
5575
  attrName = _Object$entries$_i[0],
5424
5576
  attrValue = _Object$entries$_i[1];
5425
5577
  vnode.owner;
@@ -5506,8 +5658,8 @@ var LWC = (function (exports) {
5506
5658
  var parsedVnodeStyle = parseStyleText(elmStyle);
5507
5659
  var expectedStyle = [];
5508
5660
  // styleMap is used when style is set to static value.
5509
- for (var _i35 = 0, n = styleDecls.length; _i35 < n; _i35++) {
5510
- var _styleDecls$_i2 = _slicedToArray(styleDecls[_i35], 3),
5661
+ for (var _i36 = 0, n = styleDecls.length; _i36 < n; _i36++) {
5662
+ var _styleDecls$_i2 = _slicedToArray(styleDecls[_i36], 3),
5511
5663
  prop = _styleDecls$_i2[0],
5512
5664
  value = _styleDecls$_i2[1],
5513
5665
  important = _styleDecls$_i2[2];
@@ -5581,8 +5733,8 @@ var LWC = (function (exports) {
5581
5733
  // Deep-traverse an array (of arrays) of stylesheet factory functions, and call the callback for every array/function
5582
5734
  function traverseStylesheets(stylesheets, callback) {
5583
5735
  callback(stylesheets);
5584
- for (var _i36 = 0; _i36 < stylesheets.length; _i36++) {
5585
- var stylesheet = stylesheets[_i36];
5736
+ for (var _i37 = 0; _i37 < stylesheets.length; _i37++) {
5737
+ var stylesheet = stylesheets[_i37];
5586
5738
  if (isArray$1(stylesheet)) {
5587
5739
  traverseStylesheets(stylesheet, callback);
5588
5740
  } else {
@@ -6243,17 +6395,17 @@ var LWC = (function (exports) {
6243
6395
  function flushPendingWhenDefinedCallbacks(tagName, ctor) {
6244
6396
  var resolvers = pendingWhenDefinedCallbacks.get(tagName);
6245
6397
  if (!isUndefined$1(resolvers)) {
6246
- var _iterator7 = _createForOfIteratorHelper(resolvers),
6247
- _step7;
6398
+ var _iterator10 = _createForOfIteratorHelper(resolvers),
6399
+ _step10;
6248
6400
  try {
6249
- for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
6250
- var resolver = _step7.value;
6401
+ for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
6402
+ var resolver = _step10.value;
6251
6403
  resolver(ctor);
6252
6404
  }
6253
6405
  } catch (err) {
6254
- _iterator7.e(err);
6406
+ _iterator10.e(err);
6255
6407
  } finally {
6256
- _iterator7.f();
6408
+ _iterator10.f();
6257
6409
  }
6258
6410
  }
6259
6411
  pendingWhenDefinedCallbacks.delete(tagName);
@@ -6303,11 +6455,11 @@ var LWC = (function (exports) {
6303
6455
  var awaiting = awaitingUpgrade.get(tagName);
6304
6456
  if (!isUndefined$1(awaiting)) {
6305
6457
  awaitingUpgrade.delete(tagName);
6306
- var _iterator8 = _createForOfIteratorHelper(awaiting),
6307
- _step8;
6458
+ var _iterator11 = _createForOfIteratorHelper(awaiting),
6459
+ _step11;
6308
6460
  try {
6309
- for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
6310
- var element = _step8.value;
6461
+ for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
6462
+ var element = _step11.value;
6311
6463
  var registeredDefinition = pendingRegistryForElement.get(element);
6312
6464
  // At this point, registeredDefinition should never be undefined because awaitingUpgrade
6313
6465
  // is only populated when we haven't run internalUpgrade yet, and we only populate
@@ -6319,9 +6471,9 @@ var LWC = (function (exports) {
6319
6471
  }
6320
6472
  }
6321
6473
  } catch (err) {
6322
- _iterator8.e(err);
6474
+ _iterator11.e(err);
6323
6475
  } finally {
6324
- _iterator8.f();
6476
+ _iterator11.f();
6325
6477
  }
6326
6478
  }
6327
6479
  // If anyone called customElements.whenDefined() and is still waiting for a promise resolution, resolve now
@@ -6598,7 +6750,7 @@ var LWC = (function (exports) {
6598
6750
  function isNull(obj) {
6599
6751
  return obj === null;
6600
6752
  }
6601
- /** version: 2.34.0 */
6753
+ /** version: 2.35.0 */
6602
6754
 
6603
6755
  /*
6604
6756
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6657,17 +6809,17 @@ var LWC = (function (exports) {
6657
6809
  exports.createFragment = function (html) {
6658
6810
  var wrapperTags = topLevelWrappingMap[getTagName(html)];
6659
6811
  if (!isUndefined(wrapperTags)) {
6660
- var _iterator9 = _createForOfIteratorHelper(wrapperTags),
6661
- _step9;
6812
+ var _iterator12 = _createForOfIteratorHelper(wrapperTags),
6813
+ _step12;
6662
6814
  try {
6663
- for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
6664
- var wrapperTag = _step9.value;
6815
+ for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
6816
+ var wrapperTag = _step12.value;
6665
6817
  html = "<".concat(wrapperTag, ">").concat(html, "</").concat(wrapperTag, ">");
6666
6818
  }
6667
6819
  } catch (err) {
6668
- _iterator9.e(err);
6820
+ _iterator12.e(err);
6669
6821
  } finally {
6670
- _iterator9.f();
6822
+ _iterator12.f();
6671
6823
  }
6672
6824
  }
6673
6825
  // For IE11, the document title must not be undefined, but it can be an empty string
@@ -6676,7 +6828,7 @@ var LWC = (function (exports) {
6676
6828
  doc.body.innerHTML = html;
6677
6829
  var content = doc.body;
6678
6830
  if (!isUndefined(wrapperTags)) {
6679
- for (var _i37 = 0; _i37 < wrapperTags.length; _i37++) {
6831
+ for (var _i38 = 0; _i38 < wrapperTags.length; _i38++) {
6680
6832
  content = content.firstChild;
6681
6833
  }
6682
6834
  }
@@ -6869,8 +7021,8 @@ var LWC = (function (exports) {
6869
7021
  tagName: element.tagName.toLowerCase(),
6870
7022
  hydrated: true
6871
7023
  });
6872
- for (var _i38 = 0, _Object$entries2 = Object.entries(props); _i38 < _Object$entries2.length; _i38++) {
6873
- var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i38], 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),
6874
7026
  key = _Object$entries2$_i[0],
6875
7027
  value = _Object$entries2$_i[1];
6876
7028
  element[key] = value;
@@ -7157,10 +7309,11 @@ var LWC = (function (exports) {
7157
7309
  });
7158
7310
  freeze(LightningElement);
7159
7311
  seal(LightningElement.prototype);
7160
- /* version: 2.34.0 */
7312
+ /* version: 2.35.0 */
7161
7313
 
7162
7314
  exports.LightningElement = LightningElement;
7163
7315
  exports.__unstable__ProfilerControl = profilerControl;
7316
+ exports.__unstable__ReportingControl = reportingControl;
7164
7317
  exports.api = api$1;
7165
7318
  exports.buildCustomElementConstructor = deprecatedBuildCustomElementConstructor;
7166
7319
  exports.createContextProvider = createContextProvider;