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
@@ -93,6 +93,7 @@
93
93
  ArrayIndexOf = _Array$prototype.indexOf,
94
94
  ArrayJoin = _Array$prototype.join,
95
95
  ArrayMap = _Array$prototype.map,
96
+ ArrayPop = _Array$prototype.pop,
96
97
  ArrayPush$1 = _Array$prototype.push,
97
98
  ArraySlice = _Array$prototype.slice,
98
99
  ArraySplice = _Array$prototype.splice,
@@ -334,7 +335,7 @@
334
335
  CACHED_ATTRIBUTE_PROPERTY_MAPPING.set(attrName, propertyName);
335
336
  return propertyName;
336
337
  }
337
- /** version: 2.33.0 */
338
+ /** version: 2.34.0 */
338
339
 
339
340
  /**
340
341
  * Copyright (C) 2018 salesforce.com, inc.
@@ -356,7 +357,8 @@
356
357
  DISABLE_LIGHT_DOM_UNSCOPED_CSS: null,
357
358
  ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY: null,
358
359
  ENABLE_FROZEN_TEMPLATE: null,
359
- DISABLE_ARIA_REFLECTION_POLYFILL: null
360
+ DISABLE_ARIA_REFLECTION_POLYFILL: null,
361
+ ENABLE_PROGRAMMATIC_STYLESHEETS: null
360
362
  };
361
363
  if (!_globalThis.lwcRuntimeFlags) {
362
364
  Object.defineProperty(_globalThis, 'lwcRuntimeFlags', {
@@ -404,7 +406,7 @@
404
406
  */
405
407
  function setFeatureFlagForTest(name, value) {
406
408
  }
407
- /** version: 2.33.0 */
409
+ /** version: 2.34.0 */
408
410
 
409
411
  /**
410
412
  * Copyright (C) 2018 salesforce.com, inc.
@@ -468,7 +470,7 @@
468
470
  }
469
471
  }
470
472
  }
471
- /** version: 2.33.0 */
473
+ /** version: 2.34.0 */
472
474
 
473
475
  /*
474
476
  * Copyright (c) 2018, salesforce.com, inc.
@@ -551,6 +553,26 @@
551
553
  }
552
554
  return result;
553
555
  }
556
+ function flattenStylesheets(stylesheets) {
557
+ var list = [];
558
+ var _iterator2 = _createForOfIteratorHelper(stylesheets),
559
+ _step2;
560
+ try {
561
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
562
+ var stylesheet = _step2.value;
563
+ if (!Array.isArray(stylesheet)) {
564
+ list.push(stylesheet);
565
+ } else {
566
+ list.push.apply(list, _toConsumableArray(flattenStylesheets(stylesheet)));
567
+ }
568
+ }
569
+ } catch (err) {
570
+ _iterator2.e(err);
571
+ } finally {
572
+ _iterator2.f();
573
+ }
574
+ return list;
575
+ }
554
576
  // Set a ref (lwc:ref) on a VM, from a template API
555
577
  function setRefVNode(vm, ref, vnode) {
556
578
  // If this method is called, then vm.refVNodes is set as the template has refs.
@@ -794,6 +816,9 @@
794
816
  // Global HTML Attributes & Properties
795
817
  // https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes
796
818
  // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement
819
+ //
820
+ // If you update this list, check for test files that recapitulate the same list. Searching the codebase
821
+ // for e.g. "dropzone" should suffice.
797
822
  assign(create(null), {
798
823
  accessKey: {
799
824
  attribute: 'accesskey'
@@ -2528,6 +2553,7 @@
2528
2553
  setAttribute = _vm$renderer.setAttribute;
2529
2554
  var newStylesheets = template.stylesheets,
2530
2555
  newStylesheetToken = template.stylesheetToken;
2556
+ var newVmStylesheets = vm.stylesheets;
2531
2557
  var isSyntheticShadow = renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */;
2532
2558
  var hasScopedStyles = context.hasScopedStyles;
2533
2559
  var newToken;
@@ -2547,7 +2573,9 @@
2547
2573
  }
2548
2574
  // Apply the new template styling token to the host element, if the new template has any
2549
2575
  // associated stylesheets. In the case of light DOM, also ensure there is at least one scoped stylesheet.
2550
- if (!isUndefined$1(newStylesheets) && newStylesheets.length !== 0) {
2576
+ var hasNewStylesheets = hasStyles(newStylesheets);
2577
+ var hasNewVmStylesheets = hasStyles(newVmStylesheets);
2578
+ if (hasNewStylesheets || hasNewVmStylesheets) {
2551
2579
  newToken = newStylesheetToken;
2552
2580
  }
2553
2581
  // Set the new styling token on the host element
@@ -2609,10 +2637,15 @@
2609
2637
  function getStylesheetsContent(vm, template) {
2610
2638
  var stylesheets = template.stylesheets,
2611
2639
  stylesheetToken = template.stylesheetToken;
2640
+ var vmStylesheets = vm.stylesheets;
2612
2641
  var content = [];
2613
- if (!isUndefined$1(stylesheets) && stylesheets.length !== 0) {
2642
+ if (hasStyles(stylesheets)) {
2614
2643
  content = evaluateStylesheetsContent(stylesheets, stylesheetToken, vm);
2615
2644
  }
2645
+ // VM (component) stylesheets apply after template stylesheets
2646
+ if (hasStyles(vmStylesheets)) {
2647
+ ArrayPush$1.apply(content, evaluateStylesheetsContent(vmStylesheets, stylesheetToken, vm));
2648
+ }
2616
2649
  return content;
2617
2650
  }
2618
2651
  // It might be worth caching this to avoid doing the lookup repeatedly, but
@@ -2647,8 +2680,9 @@
2647
2680
  function getStylesheetTokenHost(vnode) {
2648
2681
  var _getComponentInternal = getComponentInternalDef(vnode.ctor),
2649
2682
  template = _getComponentInternal.template;
2683
+ var vm = vnode.vm;
2650
2684
  var stylesheetToken = template.stylesheetToken;
2651
- return !isUndefined$1(stylesheetToken) && computeHasScopedStyles(template) ? makeHostToken(stylesheetToken) : null;
2685
+ return !isUndefined$1(stylesheetToken) && computeHasScopedStyles(template, vm) ? makeHostToken(stylesheetToken) : null;
2652
2686
  }
2653
2687
  function getNearestNativeShadowComponent(vm) {
2654
2688
  var owner = getNearestShadowComponent(vm);
@@ -3207,6 +3241,26 @@
3207
3241
  // in fallback mode, the allocation will always set children to
3208
3242
  // empty and delegate the real allocation to the slot elements
3209
3243
  allocateChildren(n2, vm);
3244
+ // Solves an edge case with slotted VFragments in native shadow mode.
3245
+ //
3246
+ // During allocation, in native shadow, slotted VFragment nodes are flattened and their text delimiters are removed
3247
+ // to avoid interfering with native slot behavior. When this happens, if any of the fragments
3248
+ // were not stable, the children must go through the dynamic diffing algo.
3249
+ //
3250
+ // If the new children (n2.children) contain no VFragments, but the previous children (n1.children) were dynamic,
3251
+ // the new nodes must be marked dynamic so that all nodes are properly updated. The only indicator that the new
3252
+ // nodes need to be dynamic comes from the previous children, so we check that to determine whether we need to
3253
+ // mark the new children dynamic.
3254
+ //
3255
+ // Example:
3256
+ // n1.children: [div, VFragment('', div, null, ''), div] => [div, div, null, div]; // marked dynamic
3257
+ // n2.children: [div, null, div] => [div, null, div] // marked ???
3258
+ var shadowMode = vm.shadowMode,
3259
+ renderMode = vm.renderMode;
3260
+ if (shadowMode == 0 /* ShadowMode.Native */ && renderMode !== 0 /* RenderMode.Light */ && hasDynamicChildren(n1.children)) {
3261
+ // No-op if children has already been marked dynamic by 'allocateChildren()'.
3262
+ markAsDynamicChildren(n2.children);
3263
+ }
3210
3264
  }
3211
3265
  // in fallback mode, the children will be always empty, so, nothing
3212
3266
  // will happen, but in native, it does allocate the light dom
@@ -3354,18 +3408,63 @@
3354
3408
  //
3355
3409
  // In case #2, we will always get a fresh VCustomElement.
3356
3410
  var children = vnode.aChildren || vnode.children;
3357
- vm.aChildren = children;
3358
3411
  var renderMode = vm.renderMode,
3359
3412
  shadowMode = vm.shadowMode;
3413
+ // If any of the children being allocated are VFragments, we remove the text delimiters and flatten all immediate
3414
+ // children VFragments to avoid them interfering with default slot behavior.
3415
+ var allocatedChildren = flattenFragmentsInChildren(children);
3416
+ vnode.children = allocatedChildren;
3417
+ vm.aChildren = allocatedChildren;
3360
3418
  if (shadowMode === 1 /* ShadowMode.Synthetic */ || renderMode === 0 /* RenderMode.Light */) {
3361
3419
  // slow path
3362
- allocateInSlot(vm, children, vnode.owner);
3420
+ allocateInSlot(vm, allocatedChildren, vnode.owner);
3363
3421
  // save the allocated children in case this vnode is reused.
3364
- vnode.aChildren = children;
3422
+ vnode.aChildren = allocatedChildren;
3365
3423
  // every child vnode is now allocated, and the host should receive none directly, it receives them via the shadow!
3366
3424
  vnode.children = EmptyArray;
3367
3425
  }
3368
3426
  }
3427
+ /**
3428
+ * Flattens the contents of all VFragments in an array of VNodes, removes the text delimiters on those VFragments, and
3429
+ * marks the resulting children array as dynamic. Uses a stack (array) to iteratively traverse the nested VFragments
3430
+ * and avoid the perf overhead of creating/destroying throwaway arrays/objects in a recursive approach.
3431
+ *
3432
+ * With the delimiters removed, the contents are marked dynamic so they are diffed correctly.
3433
+ *
3434
+ * This function is used for slotted VFragments to avoid the text delimiters interfering with slotting functionality.
3435
+ */
3436
+ function flattenFragmentsInChildren(children) {
3437
+ var flattenedChildren = [];
3438
+ // Initialize our stack with the direct children of the custom component and check whether we have a VFragment.
3439
+ // If no VFragment is found in children, we don't need to traverse anything or mark the children dynamic and can return early.
3440
+ var nodeStack = [];
3441
+ var fragmentFound = false;
3442
+ for (var _i15 = children.length - 1; _i15 > -1; _i15 -= 1) {
3443
+ var child = children[_i15];
3444
+ ArrayPush$1.call(nodeStack, child);
3445
+ fragmentFound = fragmentFound || !!(child && isVFragment(child));
3446
+ }
3447
+ if (!fragmentFound) {
3448
+ return children;
3449
+ }
3450
+ var currentNode;
3451
+ while (!isUndefined$1(currentNode = ArrayPop.call(nodeStack))) {
3452
+ if (!isNull(currentNode) && isVFragment(currentNode)) {
3453
+ var fChildren = currentNode.children;
3454
+ // Ignore the start and end text node delimiters
3455
+ for (var _i16 = fChildren.length - 2; _i16 > 0; _i16 -= 1) {
3456
+ ArrayPush$1.call(nodeStack, fChildren[_i16]);
3457
+ }
3458
+ } else {
3459
+ ArrayPush$1.call(flattenedChildren, currentNode);
3460
+ }
3461
+ }
3462
+ // We always mark the children as dynamic because nothing generates stable VFragments yet.
3463
+ // If/when stable VFragments are generated by the compiler, this code should be updated to
3464
+ // not mark dynamic if all flattened VFragments were stable.
3465
+ markAsDynamicChildren(flattenedChildren);
3466
+ return flattenedChildren;
3467
+ }
3369
3468
  function createViewModelHook(elm, vnode, renderer) {
3370
3469
  var vm = getAssociatedVMIfPresent(elm);
3371
3470
  // There is a possibility that a custom element is registered under tagName, in which case, the
@@ -3385,22 +3484,16 @@
3385
3484
  });
3386
3485
  return vm;
3387
3486
  }
3388
- /**
3389
- * Collects all slots into a SlotSet, traversing through VFragment Nodes
3390
- */
3391
- function collectSlots(vm, children, cmpSlotsMapping) {
3487
+ function allocateInSlot(vm, children, owner) {
3392
3488
  var _a, _b;
3393
- for (var _i15 = 0, len = children.length; _i15 < len; _i15 += 1) {
3394
- var vnode = children[_i15];
3489
+ var oldSlotsMapping = vm.cmpSlots.slotAssignments;
3490
+ var cmpSlotsMapping = create(null);
3491
+ // Collect all slots into cmpSlotsMapping
3492
+ for (var _i17 = 0, len = children.length; _i17 < len; _i17 += 1) {
3493
+ var vnode = children[_i17];
3395
3494
  if (isNull(vnode)) {
3396
3495
  continue;
3397
3496
  }
3398
- // Dive further iff the content is wrapped in a VFragment
3399
- if (isVFragment(vnode)) {
3400
- // Remove the text delimiter nodes to avoid overriding default slot content
3401
- collectSlots(vm, vnode.children.slice(1, -1), cmpSlotsMapping);
3402
- continue;
3403
- }
3404
3497
  var slotName = '';
3405
3498
  if (isVBaseElement(vnode)) {
3406
3499
  slotName = (_b = (_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) !== null && _b !== void 0 ? _b : '';
@@ -3410,11 +3503,6 @@
3410
3503
  var vnodes = cmpSlotsMapping[slotName] = cmpSlotsMapping[slotName] || [];
3411
3504
  ArrayPush$1.call(vnodes, vnode);
3412
3505
  }
3413
- }
3414
- function allocateInSlot(vm, children, owner) {
3415
- var oldSlotsMapping = vm.cmpSlots.slotAssignments;
3416
- var cmpSlotsMapping = create(null);
3417
- collectSlots(vm, children, cmpSlotsMapping);
3418
3506
  vm.cmpSlots = {
3419
3507
  owner: owner,
3420
3508
  slotAssignments: cmpSlotsMapping
@@ -3427,16 +3515,16 @@
3427
3515
  markComponentAsDirty(vm);
3428
3516
  return;
3429
3517
  }
3430
- for (var _i16 = 0, len = oldKeys.length; _i16 < len; _i16 += 1) {
3431
- var key = oldKeys[_i16];
3518
+ for (var _i18 = 0, _len2 = oldKeys.length; _i18 < _len2; _i18 += 1) {
3519
+ var key = oldKeys[_i18];
3432
3520
  if (isUndefined$1(cmpSlotsMapping[key]) || oldSlotsMapping[key].length !== cmpSlotsMapping[key].length) {
3433
3521
  markComponentAsDirty(vm);
3434
3522
  return;
3435
3523
  }
3436
3524
  var oldVNodes = oldSlotsMapping[key];
3437
- var vnodes = cmpSlotsMapping[key];
3525
+ var _vnodes = cmpSlotsMapping[key];
3438
3526
  for (var j = 0, a = cmpSlotsMapping[key].length; j < a; j += 1) {
3439
- if (oldVNodes[j] !== vnodes[j]) {
3527
+ if (oldVNodes[j] !== _vnodes[j]) {
3440
3528
  markComponentAsDirty(vm);
3441
3529
  return;
3442
3530
  }
@@ -3445,14 +3533,14 @@
3445
3533
  }
3446
3534
  }
3447
3535
  // Using a WeakMap instead of a WeakSet because this one works in IE11 :(
3448
- var FromIteration = new WeakMap();
3449
- // dynamic children means it was generated by an iteration
3450
- // in a template, and will require a more complex diffing algo.
3536
+ var DynamicChildren = new WeakMap();
3537
+ // dynamic children means it was either generated by an iteration in a template
3538
+ // or part of an unstable fragment, and will require a more complex diffing algo.
3451
3539
  function markAsDynamicChildren(children) {
3452
- FromIteration.set(children, 1);
3540
+ DynamicChildren.set(children, 1);
3453
3541
  }
3454
3542
  function hasDynamicChildren(children) {
3455
- return FromIteration.has(children);
3543
+ return DynamicChildren.has(children);
3456
3544
  }
3457
3545
  function createKeyToOldIdx(children, beginIdx, endIdx) {
3458
3546
  var map = {};
@@ -3551,11 +3639,11 @@
3551
3639
  if (oldStartIdx > oldEndIdx) {
3552
3640
  // There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
3553
3641
  // already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
3554
- var _i17 = newEndIdx;
3642
+ var _i19 = newEndIdx;
3555
3643
  var n;
3556
3644
  do {
3557
- n = newCh[++_i17];
3558
- } while (!isVNode(n) && _i17 < newChEnd);
3645
+ n = newCh[++_i19];
3646
+ } while (!isVNode(n) && _i19 < newChEnd);
3559
3647
  before = isVNode(n) ? n.elm : null;
3560
3648
  mountVNodes(newCh, parent, renderer, before, newStartIdx, newEndIdx + 1);
3561
3649
  } else {
@@ -3580,9 +3668,9 @@
3580
3668
  // if the old list is not empty, the new list MUST have the same
3581
3669
  // amount of nodes, that's why we call this static children
3582
3670
  var anchor = null;
3583
- for (var _i18 = c2Length - 1; _i18 >= 0; _i18 -= 1) {
3584
- var n1 = c1[_i18];
3585
- var n2 = c2[_i18];
3671
+ for (var _i20 = c2Length - 1; _i20 >= 0; _i20 -= 1) {
3672
+ var n1 = c1[_i20];
3673
+ var n2 = c2[_i20];
3586
3674
  if (n2 !== n1) {
3587
3675
  if (isVNode(n1)) {
3588
3676
  if (isVNode(n2)) {
@@ -3679,8 +3767,8 @@
3679
3767
  if (!isUndefined$1(slotset) && !isUndefined$1(slotset.slotAssignments) && !isUndefined$1(slotset.slotAssignments[slotName]) && slotset.slotAssignments[slotName].length !== 0) {
3680
3768
  var newChildren = [];
3681
3769
  var slotAssignments = slotset.slotAssignments[slotName];
3682
- for (var _i19 = 0; _i19 < slotAssignments.length; _i19++) {
3683
- var vnode = slotAssignments[_i19];
3770
+ for (var _i21 = 0; _i21 < slotAssignments.length; _i21++) {
3771
+ var vnode = slotAssignments[_i21];
3684
3772
  if (!isNull(vnode)) {
3685
3773
  var assignedNodeIsScopedSlot = isVScopedSlotFragment(vnode);
3686
3774
  // The only sniff test for a scoped <slot> element is the presence of `slotData`
@@ -4030,7 +4118,7 @@
4030
4118
  }
4031
4119
  function buildParseFragmentFn(createFragmentFn) {
4032
4120
  return function (strings) {
4033
- for (var _len2 = arguments.length, keys = new Array(_len2 > 1 ? _len2 - 1 : 0), _key3 = 1; _key3 < _len2; _key3++) {
4121
+ for (var _len3 = arguments.length, keys = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
4034
4122
  keys[_key3 - 1] = arguments[_key3];
4035
4123
  }
4036
4124
  var cache = create(null);
@@ -4059,23 +4147,23 @@
4059
4147
  var classAttrToken = hasScopedStyles && hasStyleToken ? " class=\"".concat(stylesheetToken, "\"") : '';
4060
4148
  var attrToken = hasStyleToken && isSyntheticShadow ? ' ' + stylesheetToken : '';
4061
4149
  var htmlFragment = '';
4062
- for (var _i20 = 0, n = keys.length; _i20 < n; _i20++) {
4063
- switch (keys[_i20]) {
4150
+ for (var _i22 = 0, n = keys.length; _i22 < n; _i22++) {
4151
+ switch (keys[_i22]) {
4064
4152
  case 0:
4065
4153
  // styleToken in existing class attr
4066
- htmlFragment += strings[_i20] + classToken;
4154
+ htmlFragment += strings[_i22] + classToken;
4067
4155
  break;
4068
4156
  case 1:
4069
4157
  // styleToken for added class attr
4070
- htmlFragment += strings[_i20] + classAttrToken;
4158
+ htmlFragment += strings[_i22] + classAttrToken;
4071
4159
  break;
4072
4160
  case 2:
4073
4161
  // styleToken as attr
4074
- htmlFragment += strings[_i20] + attrToken;
4162
+ htmlFragment += strings[_i22] + attrToken;
4075
4163
  break;
4076
4164
  case 3:
4077
4165
  // ${1}${2}
4078
- htmlFragment += strings[_i20] + classAttrToken + attrToken;
4166
+ htmlFragment += strings[_i22] + classAttrToken + attrToken;
4079
4167
  break;
4080
4168
  }
4081
4169
  }
@@ -4131,7 +4219,7 @@
4131
4219
  // Create a brand new template cache for the swapped templated.
4132
4220
  context.tplCache = create(null);
4133
4221
  // Set the computeHasScopedStyles property in the context, to avoid recomputing it repeatedly.
4134
- context.hasScopedStyles = computeHasScopedStyles(html);
4222
+ context.hasScopedStyles = computeHasScopedStyles(html, vm);
4135
4223
  // Update the scoping token on the host element.
4136
4224
  updateStylesheetToken(vm, html);
4137
4225
  // Evaluate, create stylesheet and cache the produced VNode for future
@@ -4163,17 +4251,24 @@
4163
4251
  });
4164
4252
  return vnodes;
4165
4253
  }
4166
- function computeHasScopedStyles(template) {
4167
- var stylesheets = template.stylesheets;
4168
- if (!isUndefined$1(stylesheets)) {
4169
- for (var _i21 = 0; _i21 < stylesheets.length; _i21++) {
4170
- if (isTrue(stylesheets[_i21][KEY__SCOPED_CSS])) {
4254
+ function computeHasScopedStylesInStylesheets(stylesheets) {
4255
+ if (hasStyles(stylesheets)) {
4256
+ for (var _i23 = 0; _i23 < stylesheets.length; _i23++) {
4257
+ if (isTrue(stylesheets[_i23][KEY__SCOPED_CSS])) {
4171
4258
  return true;
4172
4259
  }
4173
4260
  }
4174
4261
  }
4175
4262
  return false;
4176
4263
  }
4264
+ function computeHasScopedStyles(template, vm) {
4265
+ var stylesheets = template.stylesheets;
4266
+ var vmStylesheets = !isUndefined$1(vm) ? vm.stylesheets : null;
4267
+ return computeHasScopedStylesInStylesheets(stylesheets) || computeHasScopedStylesInStylesheets(vmStylesheets);
4268
+ }
4269
+ function hasStyles(stylesheets) {
4270
+ return !isUndefined$1(stylesheets) && !isNull(stylesheets) && stylesheets.length > 0;
4271
+ }
4177
4272
  var vmBeingConstructed = null;
4178
4273
  function isBeingConstructed(vm) {
4179
4274
  return vmBeingConstructed === vm;
@@ -4325,8 +4420,8 @@
4325
4420
  * subject to change or being removed.
4326
4421
  */
4327
4422
  function register(service) {
4328
- for (var _i22 = 0; _i22 < hooks.length; ++_i22) {
4329
- var hookName = hooks[_i22];
4423
+ for (var _i24 = 0; _i24 < hooks.length; ++_i24) {
4424
+ var hookName = hooks[_i24];
4330
4425
  if (hookName in service) {
4331
4426
  var l = Services[hookName];
4332
4427
  if (isUndefined$1(l)) {
@@ -4340,8 +4435,8 @@
4340
4435
  var component = vm.component,
4341
4436
  def = vm.def,
4342
4437
  context = vm.context;
4343
- for (var _i23 = 0, len = cbs.length; _i23 < len; ++_i23) {
4344
- cbs[_i23].call(undefined, component, {}, def, context);
4438
+ for (var _i25 = 0, len = cbs.length; _i25 < len; ++_i25) {
4439
+ cbs[_i25].call(undefined, component, {}, def, context);
4345
4440
  }
4346
4441
  }
4347
4442
 
@@ -4454,6 +4549,7 @@
4454
4549
  // Properties set right after VM creation.
4455
4550
  tro: null,
4456
4551
  shadowMode: null,
4552
+ stylesheets: null,
4457
4553
  // Properties set by the LightningElement constructor.
4458
4554
  component: null,
4459
4555
  shadowRoot: null,
@@ -4463,6 +4559,7 @@
4463
4559
  getHook: getHook,
4464
4560
  renderer: renderer
4465
4561
  };
4562
+ vm.stylesheets = computeStylesheets(vm, def.ctor);
4466
4563
  vm.shadowMode = computeShadowMode(vm, renderer);
4467
4564
  vm.tro = getTemplateReactiveObserver(vm);
4468
4565
  // Create component instance associated to the vm and the element.
@@ -4473,6 +4570,38 @@
4473
4570
  }
4474
4571
  return vm;
4475
4572
  }
4573
+ function validateComponentStylesheets(vm, stylesheets) {
4574
+ var valid = true;
4575
+ var validate = function validate(arrayOrStylesheet) {
4576
+ if (isArray$1(arrayOrStylesheet)) {
4577
+ for (var _i26 = 0; _i26 < arrayOrStylesheet.length; _i26++) {
4578
+ validate(arrayOrStylesheet[_i26]);
4579
+ }
4580
+ } else if (!isFunction$1(arrayOrStylesheet)) {
4581
+ // function assumed to be a stylesheet factory
4582
+ valid = false;
4583
+ }
4584
+ };
4585
+ if (!isArray$1(stylesheets)) {
4586
+ valid = false;
4587
+ } else {
4588
+ validate(stylesheets);
4589
+ }
4590
+ return valid;
4591
+ }
4592
+ // Validate and flatten any stylesheets defined as `static stylesheets`
4593
+ function computeStylesheets(vm, ctor) {
4594
+ if (lwcRuntimeFlags.ENABLE_PROGRAMMATIC_STYLESHEETS) {
4595
+ var stylesheets = ctor.stylesheets;
4596
+ if (!isUndefined$1(stylesheets)) {
4597
+ var valid = validateComponentStylesheets(vm, stylesheets);
4598
+ if (valid) {
4599
+ return flattenStylesheets(stylesheets);
4600
+ }
4601
+ }
4602
+ }
4603
+ return null;
4604
+ }
4476
4605
  function computeShadowMode(vm, renderer) {
4477
4606
  var def = vm.def;
4478
4607
  var isSyntheticShadowDefined = renderer.isSyntheticShadowDefined,
@@ -4581,17 +4710,17 @@
4581
4710
  return a.idx - b.idx;
4582
4711
  });
4583
4712
  rehydrateQueue = []; // reset to a new queue
4584
- for (var _i24 = 0, len = vms.length; _i24 < len; _i24 += 1) {
4585
- var vm = vms[_i24];
4713
+ for (var _i27 = 0, len = vms.length; _i27 < len; _i27 += 1) {
4714
+ var vm = vms[_i27];
4586
4715
  try {
4587
4716
  rehydrate(vm);
4588
4717
  } catch (error) {
4589
- if (_i24 + 1 < len) {
4718
+ if (_i27 + 1 < len) {
4590
4719
  // pieces of the queue are still pending to be rehydrated, those should have priority
4591
4720
  if (rehydrateQueue.length === 0) {
4592
4721
  addCallbackToNextTick(flushRehydrationQueue);
4593
4722
  }
4594
- ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i24 + 1));
4723
+ ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i27 + 1));
4595
4724
  }
4596
4725
  // we need to end the measure before throwing.
4597
4726
  logGlobalOperationEnd(8 /* OperationId.GlobalRehydrate */);
@@ -4657,8 +4786,8 @@
4657
4786
  var vCustomElementCollection = vm.velements;
4658
4787
  // Reporting disconnection for every child in inverse order since they are
4659
4788
  // inserted in reserved order.
4660
- for (var _i25 = vCustomElementCollection.length - 1; _i25 >= 0; _i25 -= 1) {
4661
- var elm = vCustomElementCollection[_i25].elm;
4789
+ for (var _i28 = vCustomElementCollection.length - 1; _i28 >= 0; _i28 -= 1) {
4790
+ var elm = vCustomElementCollection[_i28].elm;
4662
4791
  // There are two cases where the element could be undefined:
4663
4792
  // * when there is an error during the construction phase, and an error
4664
4793
  // boundary picks it, there is a possibility that the VCustomElement
@@ -4689,8 +4818,8 @@
4689
4818
  * defined on its shadow.
4690
4819
  */
4691
4820
  function recursivelyDisconnectChildren(vnodes) {
4692
- for (var _i26 = 0, len = vnodes.length; _i26 < len; _i26 += 1) {
4693
- var vnode = vnodes[_i26];
4821
+ for (var _i29 = 0, len = vnodes.length; _i29 < len; _i29 += 1) {
4822
+ var vnode = vnodes[_i29];
4694
4823
  if (!isNull(vnode) && !isUndefined$1(vnode.elm)) {
4695
4824
  switch (vnode.type) {
4696
4825
  case 2 /* VNodeType.Element */:
@@ -4714,8 +4843,8 @@
4714
4843
  var children = vm.children,
4715
4844
  renderRoot = vm.renderRoot,
4716
4845
  remove = vm.renderer.remove;
4717
- for (var _i27 = 0, len = children.length; _i27 < len; _i27++) {
4718
- var child = children[_i27];
4846
+ for (var _i30 = 0, len = children.length; _i30 < len; _i30++) {
4847
+ var child = children[_i30];
4719
4848
  if (!isNull(child) && !isUndefined$1(child.elm)) {
4720
4849
  remove(child.elm, renderRoot);
4721
4850
  }
@@ -5011,16 +5140,16 @@
5011
5140
  }
5012
5141
  function connectWireAdapters(vm) {
5013
5142
  var wiredConnecting = vm.context.wiredConnecting;
5014
- for (var _i28 = 0, len = wiredConnecting.length; _i28 < len; _i28 += 1) {
5015
- wiredConnecting[_i28]();
5143
+ for (var _i31 = 0, len = wiredConnecting.length; _i31 < len; _i31 += 1) {
5144
+ wiredConnecting[_i31]();
5016
5145
  }
5017
5146
  }
5018
5147
  function disconnectWireAdapters(vm) {
5019
5148
  var wiredDisconnecting = vm.context.wiredDisconnecting;
5020
5149
  runWithBoundaryProtection(vm, vm, noop, function () {
5021
5150
  // job
5022
- for (var _i29 = 0, len = wiredDisconnecting.length; _i29 < len; _i29 += 1) {
5023
- wiredDisconnecting[_i29]();
5151
+ for (var _i32 = 0, len = wiredDisconnecting.length; _i32 < len; _i32 += 1) {
5152
+ wiredDisconnecting[_i32]();
5024
5153
  }
5025
5154
  }, noop);
5026
5155
  }
@@ -5230,8 +5359,8 @@
5230
5359
  var nextNode = node;
5231
5360
  var anchor = null;
5232
5361
  var renderer = owner.renderer;
5233
- for (var _i30 = 0; _i30 < children.length; _i30++) {
5234
- var childVnode = children[_i30];
5362
+ for (var _i33 = 0; _i33 < children.length; _i33++) {
5363
+ var childVnode = children[_i33];
5235
5364
  if (!isNull(childVnode)) {
5236
5365
  if (nextNode) {
5237
5366
  nextNode = hydrateNode(nextNode, childVnode, renderer);
@@ -5292,8 +5421,8 @@
5292
5421
  var nodesAreCompatible = true;
5293
5422
  // Validate attributes, though we could always recovery from those by running the update mods.
5294
5423
  // Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
5295
- for (var _i31 = 0, _Object$entries = Object.entries(attrs); _i31 < _Object$entries.length; _i31++) {
5296
- var _Object$entries$_i = _slicedToArray(_Object$entries[_i31], 2),
5424
+ for (var _i34 = 0, _Object$entries = Object.entries(attrs); _i34 < _Object$entries.length; _i34++) {
5425
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i34], 2),
5297
5426
  attrName = _Object$entries$_i[0],
5298
5427
  attrValue = _Object$entries$_i[1];
5299
5428
  vnode.owner;
@@ -5380,8 +5509,8 @@
5380
5509
  var parsedVnodeStyle = parseStyleText(elmStyle);
5381
5510
  var expectedStyle = [];
5382
5511
  // styleMap is used when style is set to static value.
5383
- for (var _i32 = 0, n = styleDecls.length; _i32 < n; _i32++) {
5384
- var _styleDecls$_i2 = _slicedToArray(styleDecls[_i32], 3),
5512
+ for (var _i35 = 0, n = styleDecls.length; _i35 < n; _i35++) {
5513
+ var _styleDecls$_i2 = _slicedToArray(styleDecls[_i35], 3),
5385
5514
  prop = _styleDecls$_i2[0],
5386
5515
  value = _styleDecls$_i2[1],
5387
5516
  important = _styleDecls$_i2[2];
@@ -5455,8 +5584,8 @@
5455
5584
  // Deep-traverse an array (of arrays) of stylesheet factory functions, and call the callback for every array/function
5456
5585
  function traverseStylesheets(stylesheets, callback) {
5457
5586
  callback(stylesheets);
5458
- for (var _i33 = 0; _i33 < stylesheets.length; _i33++) {
5459
- var stylesheet = stylesheets[_i33];
5587
+ for (var _i36 = 0; _i36 < stylesheets.length; _i36++) {
5588
+ var stylesheet = stylesheets[_i36];
5460
5589
  if (isArray$1(stylesheet)) {
5461
5590
  traverseStylesheets(stylesheet, callback);
5462
5591
  } else {
@@ -6472,7 +6601,7 @@
6472
6601
  function isNull(obj) {
6473
6602
  return obj === null;
6474
6603
  }
6475
- /** version: 2.33.0 */
6604
+ /** version: 2.34.0 */
6476
6605
 
6477
6606
  /*
6478
6607
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6550,7 +6679,7 @@
6550
6679
  doc.body.innerHTML = html;
6551
6680
  var content = doc.body;
6552
6681
  if (!isUndefined(wrapperTags)) {
6553
- for (var _i34 = 0; _i34 < wrapperTags.length; _i34++) {
6682
+ for (var _i37 = 0; _i37 < wrapperTags.length; _i37++) {
6554
6683
  content = content.firstChild;
6555
6684
  }
6556
6685
  }
@@ -6743,8 +6872,8 @@
6743
6872
  tagName: element.tagName.toLowerCase(),
6744
6873
  hydrated: true
6745
6874
  });
6746
- for (var _i35 = 0, _Object$entries2 = Object.entries(props); _i35 < _Object$entries2.length; _i35++) {
6747
- var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i35], 2),
6875
+ for (var _i38 = 0, _Object$entries2 = Object.entries(props); _i38 < _Object$entries2.length; _i38++) {
6876
+ var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i38], 2),
6748
6877
  key = _Object$entries2$_i[0],
6749
6878
  value = _Object$entries2$_i[1];
6750
6879
  element[key] = value;
@@ -7031,7 +7160,7 @@
7031
7160
  });
7032
7161
  freeze(LightningElement);
7033
7162
  seal(LightningElement.prototype);
7034
- /* version: 2.33.0 */
7163
+ /* version: 2.34.0 */
7035
7164
 
7036
7165
  exports.LightningElement = LightningElement;
7037
7166
  exports.__unstable__ProfilerControl = profilerControl;