lwc 2.33.0 → 2.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/engine-dom/esm/es2017/engine-dom.js +166 -42
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +166 -42
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +170 -39
  5. package/dist/engine-dom/iife/es5/engine-dom.js +204 -91
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +217 -88
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +166 -42
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +170 -39
  11. package/dist/engine-dom/umd/es5/engine-dom.js +204 -91
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +217 -88
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +158 -39
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +158 -39
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +3 -3
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +3 -3
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +3 -3
  20. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +3 -3
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +3 -3
  22. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +3 -3
  23. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +3 -3
  24. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +3 -3
  25. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +3 -3
  26. package/dist/wire-service/esm/es2017/wire-service.js +2 -2
  27. package/dist/wire-service/iife/es2017/wire-service.js +2 -2
  28. package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
  29. package/dist/wire-service/iife/es5/wire-service.js +2 -2
  30. package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
  31. package/dist/wire-service/umd/es2017/wire-service.js +2 -2
  32. package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
  33. package/dist/wire-service/umd/es5/wire-service.js +2 -2
  34. package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
  35. package/package.json +7 -7
@@ -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,
@@ -331,7 +332,7 @@ var LWC = (function (exports) {
331
332
  CACHED_ATTRIBUTE_PROPERTY_MAPPING.set(attrName, propertyName);
332
333
  return propertyName;
333
334
  }
334
- /** version: 2.33.0 */
335
+ /** version: 2.34.0 */
335
336
 
336
337
  /**
337
338
  * Copyright (C) 2018 salesforce.com, inc.
@@ -353,7 +354,8 @@ var LWC = (function (exports) {
353
354
  DISABLE_LIGHT_DOM_UNSCOPED_CSS: null,
354
355
  ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY: null,
355
356
  ENABLE_FROZEN_TEMPLATE: null,
356
- DISABLE_ARIA_REFLECTION_POLYFILL: null
357
+ DISABLE_ARIA_REFLECTION_POLYFILL: null,
358
+ ENABLE_PROGRAMMATIC_STYLESHEETS: null
357
359
  };
358
360
  if (!_globalThis.lwcRuntimeFlags) {
359
361
  Object.defineProperty(_globalThis, 'lwcRuntimeFlags', {
@@ -401,7 +403,7 @@ var LWC = (function (exports) {
401
403
  */
402
404
  function setFeatureFlagForTest(name, value) {
403
405
  }
404
- /** version: 2.33.0 */
406
+ /** version: 2.34.0 */
405
407
 
406
408
  /**
407
409
  * Copyright (C) 2018 salesforce.com, inc.
@@ -465,7 +467,7 @@ var LWC = (function (exports) {
465
467
  }
466
468
  }
467
469
  }
468
- /** version: 2.33.0 */
470
+ /** version: 2.34.0 */
469
471
 
470
472
  /*
471
473
  * Copyright (c) 2018, salesforce.com, inc.
@@ -548,6 +550,26 @@ var LWC = (function (exports) {
548
550
  }
549
551
  return result;
550
552
  }
553
+ function flattenStylesheets(stylesheets) {
554
+ var list = [];
555
+ var _iterator2 = _createForOfIteratorHelper(stylesheets),
556
+ _step2;
557
+ 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();
570
+ }
571
+ return list;
572
+ }
551
573
  // Set a ref (lwc:ref) on a VM, from a template API
552
574
  function setRefVNode(vm, ref, vnode) {
553
575
  // If this method is called, then vm.refVNodes is set as the template has refs.
@@ -791,6 +813,9 @@ var LWC = (function (exports) {
791
813
  // Global HTML Attributes & Properties
792
814
  // https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes
793
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.
794
819
  assign(create(null), {
795
820
  accessKey: {
796
821
  attribute: 'accesskey'
@@ -2525,6 +2550,7 @@ var LWC = (function (exports) {
2525
2550
  setAttribute = _vm$renderer.setAttribute;
2526
2551
  var newStylesheets = template.stylesheets,
2527
2552
  newStylesheetToken = template.stylesheetToken;
2553
+ var newVmStylesheets = vm.stylesheets;
2528
2554
  var isSyntheticShadow = renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */;
2529
2555
  var hasScopedStyles = context.hasScopedStyles;
2530
2556
  var newToken;
@@ -2544,7 +2570,9 @@ var LWC = (function (exports) {
2544
2570
  }
2545
2571
  // Apply the new template styling token to the host element, if the new template has any
2546
2572
  // 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) {
2573
+ var hasNewStylesheets = hasStyles(newStylesheets);
2574
+ var hasNewVmStylesheets = hasStyles(newVmStylesheets);
2575
+ if (hasNewStylesheets || hasNewVmStylesheets) {
2548
2576
  newToken = newStylesheetToken;
2549
2577
  }
2550
2578
  // Set the new styling token on the host element
@@ -2606,10 +2634,15 @@ var LWC = (function (exports) {
2606
2634
  function getStylesheetsContent(vm, template) {
2607
2635
  var stylesheets = template.stylesheets,
2608
2636
  stylesheetToken = template.stylesheetToken;
2637
+ var vmStylesheets = vm.stylesheets;
2609
2638
  var content = [];
2610
- if (!isUndefined$1(stylesheets) && stylesheets.length !== 0) {
2639
+ if (hasStyles(stylesheets)) {
2611
2640
  content = evaluateStylesheetsContent(stylesheets, stylesheetToken, vm);
2612
2641
  }
2642
+ // VM (component) stylesheets apply after template stylesheets
2643
+ if (hasStyles(vmStylesheets)) {
2644
+ ArrayPush$1.apply(content, evaluateStylesheetsContent(vmStylesheets, stylesheetToken, vm));
2645
+ }
2613
2646
  return content;
2614
2647
  }
2615
2648
  // It might be worth caching this to avoid doing the lookup repeatedly, but
@@ -2644,8 +2677,9 @@ var LWC = (function (exports) {
2644
2677
  function getStylesheetTokenHost(vnode) {
2645
2678
  var _getComponentInternal = getComponentInternalDef(vnode.ctor),
2646
2679
  template = _getComponentInternal.template;
2680
+ var vm = vnode.vm;
2647
2681
  var stylesheetToken = template.stylesheetToken;
2648
- return !isUndefined$1(stylesheetToken) && computeHasScopedStyles(template) ? makeHostToken(stylesheetToken) : null;
2682
+ return !isUndefined$1(stylesheetToken) && computeHasScopedStyles(template, vm) ? makeHostToken(stylesheetToken) : null;
2649
2683
  }
2650
2684
  function getNearestNativeShadowComponent(vm) {
2651
2685
  var owner = getNearestShadowComponent(vm);
@@ -3204,6 +3238,26 @@ var LWC = (function (exports) {
3204
3238
  // in fallback mode, the allocation will always set children to
3205
3239
  // empty and delegate the real allocation to the slot elements
3206
3240
  allocateChildren(n2, vm);
3241
+ // Solves an edge case with slotted VFragments in native shadow mode.
3242
+ //
3243
+ // During allocation, in native shadow, slotted VFragment nodes are flattened and their text delimiters are removed
3244
+ // to avoid interfering with native slot behavior. When this happens, if any of the fragments
3245
+ // were not stable, the children must go through the dynamic diffing algo.
3246
+ //
3247
+ // If the new children (n2.children) contain no VFragments, but the previous children (n1.children) were dynamic,
3248
+ // the new nodes must be marked dynamic so that all nodes are properly updated. The only indicator that the new
3249
+ // nodes need to be dynamic comes from the previous children, so we check that to determine whether we need to
3250
+ // mark the new children dynamic.
3251
+ //
3252
+ // Example:
3253
+ // n1.children: [div, VFragment('', div, null, ''), div] => [div, div, null, div]; // marked dynamic
3254
+ // n2.children: [div, null, div] => [div, null, div] // marked ???
3255
+ var shadowMode = vm.shadowMode,
3256
+ renderMode = vm.renderMode;
3257
+ if (shadowMode == 0 /* ShadowMode.Native */ && renderMode !== 0 /* RenderMode.Light */ && hasDynamicChildren(n1.children)) {
3258
+ // No-op if children has already been marked dynamic by 'allocateChildren()'.
3259
+ markAsDynamicChildren(n2.children);
3260
+ }
3207
3261
  }
3208
3262
  // in fallback mode, the children will be always empty, so, nothing
3209
3263
  // will happen, but in native, it does allocate the light dom
@@ -3351,18 +3405,63 @@ var LWC = (function (exports) {
3351
3405
  //
3352
3406
  // In case #2, we will always get a fresh VCustomElement.
3353
3407
  var children = vnode.aChildren || vnode.children;
3354
- vm.aChildren = children;
3355
3408
  var renderMode = vm.renderMode,
3356
3409
  shadowMode = vm.shadowMode;
3410
+ // If any of the children being allocated are VFragments, we remove the text delimiters and flatten all immediate
3411
+ // children VFragments to avoid them interfering with default slot behavior.
3412
+ var allocatedChildren = flattenFragmentsInChildren(children);
3413
+ vnode.children = allocatedChildren;
3414
+ vm.aChildren = allocatedChildren;
3357
3415
  if (shadowMode === 1 /* ShadowMode.Synthetic */ || renderMode === 0 /* RenderMode.Light */) {
3358
3416
  // slow path
3359
- allocateInSlot(vm, children, vnode.owner);
3417
+ allocateInSlot(vm, allocatedChildren, vnode.owner);
3360
3418
  // save the allocated children in case this vnode is reused.
3361
- vnode.aChildren = children;
3419
+ vnode.aChildren = allocatedChildren;
3362
3420
  // every child vnode is now allocated, and the host should receive none directly, it receives them via the shadow!
3363
3421
  vnode.children = EmptyArray;
3364
3422
  }
3365
3423
  }
3424
+ /**
3425
+ * Flattens the contents of all VFragments in an array of VNodes, removes the text delimiters on those VFragments, and
3426
+ * marks the resulting children array as dynamic. Uses a stack (array) to iteratively traverse the nested VFragments
3427
+ * and avoid the perf overhead of creating/destroying throwaway arrays/objects in a recursive approach.
3428
+ *
3429
+ * With the delimiters removed, the contents are marked dynamic so they are diffed correctly.
3430
+ *
3431
+ * This function is used for slotted VFragments to avoid the text delimiters interfering with slotting functionality.
3432
+ */
3433
+ function flattenFragmentsInChildren(children) {
3434
+ var flattenedChildren = [];
3435
+ // Initialize our stack with the direct children of the custom component and check whether we have a VFragment.
3436
+ // If no VFragment is found in children, we don't need to traverse anything or mark the children dynamic and can return early.
3437
+ var nodeStack = [];
3438
+ var fragmentFound = false;
3439
+ for (var _i15 = children.length - 1; _i15 > -1; _i15 -= 1) {
3440
+ var child = children[_i15];
3441
+ ArrayPush$1.call(nodeStack, child);
3442
+ fragmentFound = fragmentFound || !!(child && isVFragment(child));
3443
+ }
3444
+ if (!fragmentFound) {
3445
+ return children;
3446
+ }
3447
+ var currentNode;
3448
+ while (!isUndefined$1(currentNode = ArrayPop.call(nodeStack))) {
3449
+ if (!isNull(currentNode) && isVFragment(currentNode)) {
3450
+ var fChildren = currentNode.children;
3451
+ // 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]);
3454
+ }
3455
+ } else {
3456
+ ArrayPush$1.call(flattenedChildren, currentNode);
3457
+ }
3458
+ }
3459
+ // We always mark the children as dynamic because nothing generates stable VFragments yet.
3460
+ // If/when stable VFragments are generated by the compiler, this code should be updated to
3461
+ // not mark dynamic if all flattened VFragments were stable.
3462
+ markAsDynamicChildren(flattenedChildren);
3463
+ return flattenedChildren;
3464
+ }
3366
3465
  function createViewModelHook(elm, vnode, renderer) {
3367
3466
  var vm = getAssociatedVMIfPresent(elm);
3368
3467
  // There is a possibility that a custom element is registered under tagName, in which case, the
@@ -3382,22 +3481,16 @@ var LWC = (function (exports) {
3382
3481
  });
3383
3482
  return vm;
3384
3483
  }
3385
- /**
3386
- * Collects all slots into a SlotSet, traversing through VFragment Nodes
3387
- */
3388
- function collectSlots(vm, children, cmpSlotsMapping) {
3484
+ function allocateInSlot(vm, children, owner) {
3389
3485
  var _a, _b;
3390
- for (var _i15 = 0, len = children.length; _i15 < len; _i15 += 1) {
3391
- var vnode = children[_i15];
3486
+ var oldSlotsMapping = vm.cmpSlots.slotAssignments;
3487
+ var cmpSlotsMapping = create(null);
3488
+ // Collect all slots into cmpSlotsMapping
3489
+ for (var _i17 = 0, len = children.length; _i17 < len; _i17 += 1) {
3490
+ var vnode = children[_i17];
3392
3491
  if (isNull(vnode)) {
3393
3492
  continue;
3394
3493
  }
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
3494
  var slotName = '';
3402
3495
  if (isVBaseElement(vnode)) {
3403
3496
  slotName = (_b = (_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) !== null && _b !== void 0 ? _b : '';
@@ -3407,11 +3500,6 @@ var LWC = (function (exports) {
3407
3500
  var vnodes = cmpSlotsMapping[slotName] = cmpSlotsMapping[slotName] || [];
3408
3501
  ArrayPush$1.call(vnodes, vnode);
3409
3502
  }
3410
- }
3411
- function allocateInSlot(vm, children, owner) {
3412
- var oldSlotsMapping = vm.cmpSlots.slotAssignments;
3413
- var cmpSlotsMapping = create(null);
3414
- collectSlots(vm, children, cmpSlotsMapping);
3415
3503
  vm.cmpSlots = {
3416
3504
  owner: owner,
3417
3505
  slotAssignments: cmpSlotsMapping
@@ -3424,16 +3512,16 @@ var LWC = (function (exports) {
3424
3512
  markComponentAsDirty(vm);
3425
3513
  return;
3426
3514
  }
3427
- for (var _i16 = 0, len = oldKeys.length; _i16 < len; _i16 += 1) {
3428
- var key = oldKeys[_i16];
3515
+ for (var _i18 = 0, _len2 = oldKeys.length; _i18 < _len2; _i18 += 1) {
3516
+ var key = oldKeys[_i18];
3429
3517
  if (isUndefined$1(cmpSlotsMapping[key]) || oldSlotsMapping[key].length !== cmpSlotsMapping[key].length) {
3430
3518
  markComponentAsDirty(vm);
3431
3519
  return;
3432
3520
  }
3433
3521
  var oldVNodes = oldSlotsMapping[key];
3434
- var vnodes = cmpSlotsMapping[key];
3522
+ var _vnodes = cmpSlotsMapping[key];
3435
3523
  for (var j = 0, a = cmpSlotsMapping[key].length; j < a; j += 1) {
3436
- if (oldVNodes[j] !== vnodes[j]) {
3524
+ if (oldVNodes[j] !== _vnodes[j]) {
3437
3525
  markComponentAsDirty(vm);
3438
3526
  return;
3439
3527
  }
@@ -3442,14 +3530,14 @@ var LWC = (function (exports) {
3442
3530
  }
3443
3531
  }
3444
3532
  // 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.
3533
+ var DynamicChildren = new WeakMap();
3534
+ // dynamic children means it was either generated by an iteration in a template
3535
+ // or part of an unstable fragment, and will require a more complex diffing algo.
3448
3536
  function markAsDynamicChildren(children) {
3449
- FromIteration.set(children, 1);
3537
+ DynamicChildren.set(children, 1);
3450
3538
  }
3451
3539
  function hasDynamicChildren(children) {
3452
- return FromIteration.has(children);
3540
+ return DynamicChildren.has(children);
3453
3541
  }
3454
3542
  function createKeyToOldIdx(children, beginIdx, endIdx) {
3455
3543
  var map = {};
@@ -3548,11 +3636,11 @@ var LWC = (function (exports) {
3548
3636
  if (oldStartIdx > oldEndIdx) {
3549
3637
  // There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
3550
3638
  // already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
3551
- var _i17 = newEndIdx;
3639
+ var _i19 = newEndIdx;
3552
3640
  var n;
3553
3641
  do {
3554
- n = newCh[++_i17];
3555
- } while (!isVNode(n) && _i17 < newChEnd);
3642
+ n = newCh[++_i19];
3643
+ } while (!isVNode(n) && _i19 < newChEnd);
3556
3644
  before = isVNode(n) ? n.elm : null;
3557
3645
  mountVNodes(newCh, parent, renderer, before, newStartIdx, newEndIdx + 1);
3558
3646
  } else {
@@ -3577,9 +3665,9 @@ var LWC = (function (exports) {
3577
3665
  // if the old list is not empty, the new list MUST have the same
3578
3666
  // amount of nodes, that's why we call this static children
3579
3667
  var anchor = null;
3580
- for (var _i18 = c2Length - 1; _i18 >= 0; _i18 -= 1) {
3581
- var n1 = c1[_i18];
3582
- var n2 = c2[_i18];
3668
+ for (var _i20 = c2Length - 1; _i20 >= 0; _i20 -= 1) {
3669
+ var n1 = c1[_i20];
3670
+ var n2 = c2[_i20];
3583
3671
  if (n2 !== n1) {
3584
3672
  if (isVNode(n1)) {
3585
3673
  if (isVNode(n2)) {
@@ -3676,8 +3764,8 @@ var LWC = (function (exports) {
3676
3764
  if (!isUndefined$1(slotset) && !isUndefined$1(slotset.slotAssignments) && !isUndefined$1(slotset.slotAssignments[slotName]) && slotset.slotAssignments[slotName].length !== 0) {
3677
3765
  var newChildren = [];
3678
3766
  var slotAssignments = slotset.slotAssignments[slotName];
3679
- for (var _i19 = 0; _i19 < slotAssignments.length; _i19++) {
3680
- var vnode = slotAssignments[_i19];
3767
+ for (var _i21 = 0; _i21 < slotAssignments.length; _i21++) {
3768
+ var vnode = slotAssignments[_i21];
3681
3769
  if (!isNull(vnode)) {
3682
3770
  var assignedNodeIsScopedSlot = isVScopedSlotFragment(vnode);
3683
3771
  // The only sniff test for a scoped <slot> element is the presence of `slotData`
@@ -4027,7 +4115,7 @@ var LWC = (function (exports) {
4027
4115
  }
4028
4116
  function buildParseFragmentFn(createFragmentFn) {
4029
4117
  return function (strings) {
4030
- for (var _len2 = arguments.length, keys = new Array(_len2 > 1 ? _len2 - 1 : 0), _key3 = 1; _key3 < _len2; _key3++) {
4118
+ for (var _len3 = arguments.length, keys = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
4031
4119
  keys[_key3 - 1] = arguments[_key3];
4032
4120
  }
4033
4121
  var cache = create(null);
@@ -4056,23 +4144,23 @@ var LWC = (function (exports) {
4056
4144
  var classAttrToken = hasScopedStyles && hasStyleToken ? " class=\"".concat(stylesheetToken, "\"") : '';
4057
4145
  var attrToken = hasStyleToken && isSyntheticShadow ? ' ' + stylesheetToken : '';
4058
4146
  var htmlFragment = '';
4059
- for (var _i20 = 0, n = keys.length; _i20 < n; _i20++) {
4060
- switch (keys[_i20]) {
4147
+ for (var _i22 = 0, n = keys.length; _i22 < n; _i22++) {
4148
+ switch (keys[_i22]) {
4061
4149
  case 0:
4062
4150
  // styleToken in existing class attr
4063
- htmlFragment += strings[_i20] + classToken;
4151
+ htmlFragment += strings[_i22] + classToken;
4064
4152
  break;
4065
4153
  case 1:
4066
4154
  // styleToken for added class attr
4067
- htmlFragment += strings[_i20] + classAttrToken;
4155
+ htmlFragment += strings[_i22] + classAttrToken;
4068
4156
  break;
4069
4157
  case 2:
4070
4158
  // styleToken as attr
4071
- htmlFragment += strings[_i20] + attrToken;
4159
+ htmlFragment += strings[_i22] + attrToken;
4072
4160
  break;
4073
4161
  case 3:
4074
4162
  // ${1}${2}
4075
- htmlFragment += strings[_i20] + classAttrToken + attrToken;
4163
+ htmlFragment += strings[_i22] + classAttrToken + attrToken;
4076
4164
  break;
4077
4165
  }
4078
4166
  }
@@ -4128,7 +4216,7 @@ var LWC = (function (exports) {
4128
4216
  // Create a brand new template cache for the swapped templated.
4129
4217
  context.tplCache = create(null);
4130
4218
  // Set the computeHasScopedStyles property in the context, to avoid recomputing it repeatedly.
4131
- context.hasScopedStyles = computeHasScopedStyles(html);
4219
+ context.hasScopedStyles = computeHasScopedStyles(html, vm);
4132
4220
  // Update the scoping token on the host element.
4133
4221
  updateStylesheetToken(vm, html);
4134
4222
  // Evaluate, create stylesheet and cache the produced VNode for future
@@ -4160,17 +4248,24 @@ var LWC = (function (exports) {
4160
4248
  });
4161
4249
  return vnodes;
4162
4250
  }
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])) {
4251
+ function computeHasScopedStylesInStylesheets(stylesheets) {
4252
+ if (hasStyles(stylesheets)) {
4253
+ for (var _i23 = 0; _i23 < stylesheets.length; _i23++) {
4254
+ if (isTrue(stylesheets[_i23][KEY__SCOPED_CSS])) {
4168
4255
  return true;
4169
4256
  }
4170
4257
  }
4171
4258
  }
4172
4259
  return false;
4173
4260
  }
4261
+ function computeHasScopedStyles(template, vm) {
4262
+ var stylesheets = template.stylesheets;
4263
+ var vmStylesheets = !isUndefined$1(vm) ? vm.stylesheets : null;
4264
+ return computeHasScopedStylesInStylesheets(stylesheets) || computeHasScopedStylesInStylesheets(vmStylesheets);
4265
+ }
4266
+ function hasStyles(stylesheets) {
4267
+ return !isUndefined$1(stylesheets) && !isNull(stylesheets) && stylesheets.length > 0;
4268
+ }
4174
4269
  var vmBeingConstructed = null;
4175
4270
  function isBeingConstructed(vm) {
4176
4271
  return vmBeingConstructed === vm;
@@ -4322,8 +4417,8 @@ var LWC = (function (exports) {
4322
4417
  * subject to change or being removed.
4323
4418
  */
4324
4419
  function register(service) {
4325
- for (var _i22 = 0; _i22 < hooks.length; ++_i22) {
4326
- var hookName = hooks[_i22];
4420
+ for (var _i24 = 0; _i24 < hooks.length; ++_i24) {
4421
+ var hookName = hooks[_i24];
4327
4422
  if (hookName in service) {
4328
4423
  var l = Services[hookName];
4329
4424
  if (isUndefined$1(l)) {
@@ -4337,8 +4432,8 @@ var LWC = (function (exports) {
4337
4432
  var component = vm.component,
4338
4433
  def = vm.def,
4339
4434
  context = vm.context;
4340
- for (var _i23 = 0, len = cbs.length; _i23 < len; ++_i23) {
4341
- cbs[_i23].call(undefined, component, {}, def, context);
4435
+ for (var _i25 = 0, len = cbs.length; _i25 < len; ++_i25) {
4436
+ cbs[_i25].call(undefined, component, {}, def, context);
4342
4437
  }
4343
4438
  }
4344
4439
 
@@ -4451,6 +4546,7 @@ var LWC = (function (exports) {
4451
4546
  // Properties set right after VM creation.
4452
4547
  tro: null,
4453
4548
  shadowMode: null,
4549
+ stylesheets: null,
4454
4550
  // Properties set by the LightningElement constructor.
4455
4551
  component: null,
4456
4552
  shadowRoot: null,
@@ -4460,6 +4556,7 @@ var LWC = (function (exports) {
4460
4556
  getHook: getHook,
4461
4557
  renderer: renderer
4462
4558
  };
4559
+ vm.stylesheets = computeStylesheets(vm, def.ctor);
4463
4560
  vm.shadowMode = computeShadowMode(vm, renderer);
4464
4561
  vm.tro = getTemplateReactiveObserver(vm);
4465
4562
  // Create component instance associated to the vm and the element.
@@ -4470,6 +4567,38 @@ var LWC = (function (exports) {
4470
4567
  }
4471
4568
  return vm;
4472
4569
  }
4570
+ function validateComponentStylesheets(vm, stylesheets) {
4571
+ var valid = true;
4572
+ var validate = function validate(arrayOrStylesheet) {
4573
+ if (isArray$1(arrayOrStylesheet)) {
4574
+ for (var _i26 = 0; _i26 < arrayOrStylesheet.length; _i26++) {
4575
+ validate(arrayOrStylesheet[_i26]);
4576
+ }
4577
+ } else if (!isFunction$1(arrayOrStylesheet)) {
4578
+ // function assumed to be a stylesheet factory
4579
+ valid = false;
4580
+ }
4581
+ };
4582
+ if (!isArray$1(stylesheets)) {
4583
+ valid = false;
4584
+ } else {
4585
+ validate(stylesheets);
4586
+ }
4587
+ return valid;
4588
+ }
4589
+ // Validate and flatten any stylesheets defined as `static stylesheets`
4590
+ function computeStylesheets(vm, ctor) {
4591
+ if (lwcRuntimeFlags.ENABLE_PROGRAMMATIC_STYLESHEETS) {
4592
+ var stylesheets = ctor.stylesheets;
4593
+ if (!isUndefined$1(stylesheets)) {
4594
+ var valid = validateComponentStylesheets(vm, stylesheets);
4595
+ if (valid) {
4596
+ return flattenStylesheets(stylesheets);
4597
+ }
4598
+ }
4599
+ }
4600
+ return null;
4601
+ }
4473
4602
  function computeShadowMode(vm, renderer) {
4474
4603
  var def = vm.def;
4475
4604
  var isSyntheticShadowDefined = renderer.isSyntheticShadowDefined,
@@ -4578,17 +4707,17 @@ var LWC = (function (exports) {
4578
4707
  return a.idx - b.idx;
4579
4708
  });
4580
4709
  rehydrateQueue = []; // reset to a new queue
4581
- for (var _i24 = 0, len = vms.length; _i24 < len; _i24 += 1) {
4582
- var vm = vms[_i24];
4710
+ for (var _i27 = 0, len = vms.length; _i27 < len; _i27 += 1) {
4711
+ var vm = vms[_i27];
4583
4712
  try {
4584
4713
  rehydrate(vm);
4585
4714
  } catch (error) {
4586
- if (_i24 + 1 < len) {
4715
+ if (_i27 + 1 < len) {
4587
4716
  // pieces of the queue are still pending to be rehydrated, those should have priority
4588
4717
  if (rehydrateQueue.length === 0) {
4589
4718
  addCallbackToNextTick(flushRehydrationQueue);
4590
4719
  }
4591
- ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i24 + 1));
4720
+ ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i27 + 1));
4592
4721
  }
4593
4722
  // we need to end the measure before throwing.
4594
4723
  logGlobalOperationEnd(8 /* OperationId.GlobalRehydrate */);
@@ -4654,8 +4783,8 @@ var LWC = (function (exports) {
4654
4783
  var vCustomElementCollection = vm.velements;
4655
4784
  // Reporting disconnection for every child in inverse order since they are
4656
4785
  // inserted in reserved order.
4657
- for (var _i25 = vCustomElementCollection.length - 1; _i25 >= 0; _i25 -= 1) {
4658
- var elm = vCustomElementCollection[_i25].elm;
4786
+ for (var _i28 = vCustomElementCollection.length - 1; _i28 >= 0; _i28 -= 1) {
4787
+ var elm = vCustomElementCollection[_i28].elm;
4659
4788
  // There are two cases where the element could be undefined:
4660
4789
  // * when there is an error during the construction phase, and an error
4661
4790
  // boundary picks it, there is a possibility that the VCustomElement
@@ -4686,8 +4815,8 @@ var LWC = (function (exports) {
4686
4815
  * defined on its shadow.
4687
4816
  */
4688
4817
  function recursivelyDisconnectChildren(vnodes) {
4689
- for (var _i26 = 0, len = vnodes.length; _i26 < len; _i26 += 1) {
4690
- var vnode = vnodes[_i26];
4818
+ for (var _i29 = 0, len = vnodes.length; _i29 < len; _i29 += 1) {
4819
+ var vnode = vnodes[_i29];
4691
4820
  if (!isNull(vnode) && !isUndefined$1(vnode.elm)) {
4692
4821
  switch (vnode.type) {
4693
4822
  case 2 /* VNodeType.Element */:
@@ -4711,8 +4840,8 @@ var LWC = (function (exports) {
4711
4840
  var children = vm.children,
4712
4841
  renderRoot = vm.renderRoot,
4713
4842
  remove = vm.renderer.remove;
4714
- for (var _i27 = 0, len = children.length; _i27 < len; _i27++) {
4715
- var child = children[_i27];
4843
+ for (var _i30 = 0, len = children.length; _i30 < len; _i30++) {
4844
+ var child = children[_i30];
4716
4845
  if (!isNull(child) && !isUndefined$1(child.elm)) {
4717
4846
  remove(child.elm, renderRoot);
4718
4847
  }
@@ -5008,16 +5137,16 @@ var LWC = (function (exports) {
5008
5137
  }
5009
5138
  function connectWireAdapters(vm) {
5010
5139
  var wiredConnecting = vm.context.wiredConnecting;
5011
- for (var _i28 = 0, len = wiredConnecting.length; _i28 < len; _i28 += 1) {
5012
- wiredConnecting[_i28]();
5140
+ for (var _i31 = 0, len = wiredConnecting.length; _i31 < len; _i31 += 1) {
5141
+ wiredConnecting[_i31]();
5013
5142
  }
5014
5143
  }
5015
5144
  function disconnectWireAdapters(vm) {
5016
5145
  var wiredDisconnecting = vm.context.wiredDisconnecting;
5017
5146
  runWithBoundaryProtection(vm, vm, noop, function () {
5018
5147
  // job
5019
- for (var _i29 = 0, len = wiredDisconnecting.length; _i29 < len; _i29 += 1) {
5020
- wiredDisconnecting[_i29]();
5148
+ for (var _i32 = 0, len = wiredDisconnecting.length; _i32 < len; _i32 += 1) {
5149
+ wiredDisconnecting[_i32]();
5021
5150
  }
5022
5151
  }, noop);
5023
5152
  }
@@ -5227,8 +5356,8 @@ var LWC = (function (exports) {
5227
5356
  var nextNode = node;
5228
5357
  var anchor = null;
5229
5358
  var renderer = owner.renderer;
5230
- for (var _i30 = 0; _i30 < children.length; _i30++) {
5231
- var childVnode = children[_i30];
5359
+ for (var _i33 = 0; _i33 < children.length; _i33++) {
5360
+ var childVnode = children[_i33];
5232
5361
  if (!isNull(childVnode)) {
5233
5362
  if (nextNode) {
5234
5363
  nextNode = hydrateNode(nextNode, childVnode, renderer);
@@ -5289,8 +5418,8 @@ var LWC = (function (exports) {
5289
5418
  var nodesAreCompatible = true;
5290
5419
  // Validate attributes, though we could always recovery from those by running the update mods.
5291
5420
  // 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),
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),
5294
5423
  attrName = _Object$entries$_i[0],
5295
5424
  attrValue = _Object$entries$_i[1];
5296
5425
  vnode.owner;
@@ -5377,8 +5506,8 @@ var LWC = (function (exports) {
5377
5506
  var parsedVnodeStyle = parseStyleText(elmStyle);
5378
5507
  var expectedStyle = [];
5379
5508
  // 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),
5509
+ for (var _i35 = 0, n = styleDecls.length; _i35 < n; _i35++) {
5510
+ var _styleDecls$_i2 = _slicedToArray(styleDecls[_i35], 3),
5382
5511
  prop = _styleDecls$_i2[0],
5383
5512
  value = _styleDecls$_i2[1],
5384
5513
  important = _styleDecls$_i2[2];
@@ -5452,8 +5581,8 @@ var LWC = (function (exports) {
5452
5581
  // Deep-traverse an array (of arrays) of stylesheet factory functions, and call the callback for every array/function
5453
5582
  function traverseStylesheets(stylesheets, callback) {
5454
5583
  callback(stylesheets);
5455
- for (var _i33 = 0; _i33 < stylesheets.length; _i33++) {
5456
- var stylesheet = stylesheets[_i33];
5584
+ for (var _i36 = 0; _i36 < stylesheets.length; _i36++) {
5585
+ var stylesheet = stylesheets[_i36];
5457
5586
  if (isArray$1(stylesheet)) {
5458
5587
  traverseStylesheets(stylesheet, callback);
5459
5588
  } else {
@@ -6469,7 +6598,7 @@ var LWC = (function (exports) {
6469
6598
  function isNull(obj) {
6470
6599
  return obj === null;
6471
6600
  }
6472
- /** version: 2.33.0 */
6601
+ /** version: 2.34.0 */
6473
6602
 
6474
6603
  /*
6475
6604
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6547,7 +6676,7 @@ var LWC = (function (exports) {
6547
6676
  doc.body.innerHTML = html;
6548
6677
  var content = doc.body;
6549
6678
  if (!isUndefined(wrapperTags)) {
6550
- for (var _i34 = 0; _i34 < wrapperTags.length; _i34++) {
6679
+ for (var _i37 = 0; _i37 < wrapperTags.length; _i37++) {
6551
6680
  content = content.firstChild;
6552
6681
  }
6553
6682
  }
@@ -6740,8 +6869,8 @@ var LWC = (function (exports) {
6740
6869
  tagName: element.tagName.toLowerCase(),
6741
6870
  hydrated: true
6742
6871
  });
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),
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),
6745
6874
  key = _Object$entries2$_i[0],
6746
6875
  value = _Object$entries2$_i[1];
6747
6876
  element[key] = value;
@@ -7028,7 +7157,7 @@ var LWC = (function (exports) {
7028
7157
  });
7029
7158
  freeze(LightningElement);
7030
7159
  seal(LightningElement.prototype);
7031
- /* version: 2.33.0 */
7160
+ /* version: 2.34.0 */
7032
7161
 
7033
7162
  exports.LightningElement = LightningElement;
7034
7163
  exports.__unstable__ProfilerControl = profilerControl;