lwc 2.3.4 → 2.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/engine-dom/esm/es2017/engine-dom.js +389 -174
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +389 -174
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +2 -2
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +359 -137
  5. package/dist/engine-dom/iife/es5/engine-dom.js +404 -198
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +2 -2
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +372 -159
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +389 -174
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +2 -2
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +359 -137
  11. package/dist/engine-dom/umd/es5/engine-dom.js +404 -198
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +2 -2
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +372 -159
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +333 -181
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +2 -2
  16. package/dist/engine-server/esm/es2017/engine-server.js +333 -181
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +29 -16
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +29 -16
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.min.js +2 -2
  20. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +29 -16
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +31 -16
  22. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.min.js +2 -2
  23. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +31 -16
  24. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +29 -16
  25. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.min.js +2 -2
  26. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +29 -16
  27. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +31 -16
  28. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.min.js +2 -2
  29. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +31 -16
  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 +3 -3
  34. package/dist/wire-service/iife/es5/wire-service.min.js +1 -1
  35. package/dist/wire-service/iife/es5/wire-service_debug.js +3 -3
  36. package/dist/wire-service/umd/es2017/wire-service.js +2 -2
  37. package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
  38. package/dist/wire-service/umd/es5/wire-service.js +3 -3
  39. package/dist/wire-service/umd/es5/wire-service.min.js +1 -1
  40. package/dist/wire-service/umd/es5/wire-service_debug.js +3 -3
  41. package/package.json +8 -8
@@ -29,7 +29,7 @@ var LWC = (function (exports) {
29
29
 
30
30
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf2(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf2(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
31
31
 
32
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
32
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
33
33
 
34
34
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
35
35
 
@@ -151,6 +151,10 @@ var LWC = (function (exports) {
151
151
  return obj === false;
152
152
  }
153
153
 
154
+ function isBoolean(obj) {
155
+ return typeof obj === 'boolean';
156
+ }
157
+
154
158
  function isFunction$1(obj) {
155
159
  return typeof obj === 'function';
156
160
  }
@@ -294,6 +298,7 @@ var LWC = (function (exports) {
294
298
  var KEY__SHADOW_RESOLVER = '$shadowResolver$';
295
299
  var KEY__SHADOW_TOKEN = '$shadowToken$';
296
300
  var KEY__SYNTHETIC_MODE = '$$lwc-synthetic-mode';
301
+ var KEY__SCOPED_CSS = '$scoped$';
297
302
  /**
298
303
  * Map composed of properties to attributes not following the HTML property to attribute mapping
299
304
  * convention.
@@ -342,7 +347,7 @@ var LWC = (function (exports) {
342
347
  CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
343
348
  return attributeName;
344
349
  }
345
- /** version: 2.3.4 */
350
+ /** version: 2.5.1 */
346
351
 
347
352
  /*
348
353
  * Copyright (c) 2018, salesforce.com, inc.
@@ -445,19 +450,33 @@ var LWC = (function (exports) {
445
450
  */
446
451
 
447
452
 
453
+ var features = {
454
+ ENABLE_REACTIVE_SETTER: null,
455
+ ENABLE_HMR: null,
456
+ ENABLE_INNER_OUTER_TEXT_PATCH: null,
457
+ ENABLE_ELEMENT_PATCH: null,
458
+ ENABLE_NODE_LIST_PATCH: null,
459
+ ENABLE_HTML_COLLECTIONS_PATCH: null,
460
+ ENABLE_NODE_PATCH: null,
461
+ ENABLE_NON_COMPOSED_EVENTS_LEAKAGE: null,
462
+ ENABLE_MIXED_SHADOW_MODE: null,
463
+ ENABLE_WIRE_SYNC_EMIT: null
464
+ };
465
+
448
466
  if (!_globalThis.lwcRuntimeFlags) {
449
467
  Object.defineProperty(_globalThis, 'lwcRuntimeFlags', {
450
468
  value: create(null)
451
469
  });
452
470
  }
453
471
 
454
- var runtimeFlags = _globalThis.lwcRuntimeFlags; // This function is not supported for use within components and is meant for
455
- // configuring runtime feature flags during app initialization.
472
+ var runtimeFlags = _globalThis.lwcRuntimeFlags;
473
+ /**
474
+ * Set the value at runtime of a given feature flag. This method only be invoked once per feature
475
+ * flag. It is meant to be used during the app initialization.
476
+ */
456
477
 
457
478
  function setFeatureFlag(name, value) {
458
- var isBoolean = isTrue(value) || isFalse(value);
459
-
460
- if (!isBoolean) {
479
+ if (!isBoolean(value)) {
461
480
  var message = "Failed to set the value \"".concat(value, "\" for the runtime feature flag \"").concat(name, "\". Runtime feature flags can only be set to a boolean value.");
462
481
 
463
482
  if (process.env.NODE_ENV !== 'production') {
@@ -469,9 +488,12 @@ var LWC = (function (exports) {
469
488
  }
470
489
  }
471
490
 
472
- if (isUndefined$1(featureFlagLookup[name])) {
473
- // eslint-disable-next-line no-console
474
- console.warn("Failed to set the value \"".concat(value, "\" for the runtime feature flag \"").concat(name, "\" because it is undefined. Possible reasons are that 1) it was misspelled or 2) it was removed from the @lwc/features package."));
491
+ if (isUndefined$1(features[name])) {
492
+ var availableFlags = keys(features).map(function (name) {
493
+ return "\"".concat(name, "\"");
494
+ }).join(', '); // eslint-disable-next-line no-console
495
+
496
+ console.warn("Failed to set the value \"".concat(value, "\" for the runtime feature flag \"").concat(name, "\" because it is undefined. Available flags: ").concat(availableFlags, "."));
475
497
  return;
476
498
  }
477
499
 
@@ -488,37 +510,23 @@ var LWC = (function (exports) {
488
510
  return;
489
511
  }
490
512
 
491
- Object.defineProperty(runtimeFlags, name, {
513
+ defineProperty(runtimeFlags, name, {
492
514
  value: value
493
515
  });
494
516
  }
495
- } // This function is exposed to components to facilitate testing so we add a
496
- // check to make sure it is not invoked in production.
517
+ }
518
+ /**
519
+ * Set the value at runtime of a given feature flag. This method should only be used for testing
520
+ * purposes. It is a no-op when invoked in production mode.
521
+ */
497
522
 
498
523
 
499
524
  function setFeatureFlagForTest(name, value) {
500
525
  if (process.env.NODE_ENV !== 'production') {
501
- return setFeatureFlag(name, value);
526
+ setFeatureFlag(name, value);
502
527
  }
503
528
  }
504
-
505
- var featureFlagLookup = {
506
- ENABLE_REACTIVE_SETTER: null,
507
- ENABLE_HMR: null,
508
- // Flag to toggle on/off the enforcement of innerText/outerText shadow dom semantic in elements when using synthetic shadow.
509
- // Note: Once active, elements outside the lwc boundary are controlled by the ENABLE_ELEMENT_PATCH flag.
510
- ENABLE_INNER_OUTER_TEXT_PATCH: null,
511
- // Flags to toggle on/off the enforcement of shadow dom semantic in element/node outside lwc boundary when using synthetic shadow.
512
- ENABLE_ELEMENT_PATCH: null,
513
- ENABLE_NODE_LIST_PATCH: null,
514
- ENABLE_HTML_COLLECTIONS_PATCH: null,
515
- ENABLE_NODE_PATCH: null,
516
- // Disables the fix for #2121 where non-composed events are visible outside of their shadow root.
517
- ENABLE_NON_COMPOSED_EVENTS_LEAKAGE: null,
518
- ENABLE_LIGHT_DOM_COMPONENTS: null,
519
- ENABLE_MIXED_SHADOW_MODE: null
520
- };
521
- /** version: 2.3.4 */
529
+ /** version: 2.5.1 */
522
530
 
523
531
  /* proxy-compat-disable */
524
532
 
@@ -529,6 +537,7 @@ var LWC = (function (exports) {
529
537
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
530
538
  */
531
539
 
540
+
532
541
  var nextTickCallbackQueue = [];
533
542
  var SPACE_CHAR = 32;
534
543
  var EmptyObject = seal(create(null));
@@ -2780,12 +2789,6 @@ var LWC = (function (exports) {
2780
2789
  associateVM(component, vm);
2781
2790
  associateVM(elm, vm);
2782
2791
 
2783
- if (!runtimeFlags.ENABLE_LIGHT_DOM_COMPONENTS) {
2784
- assert.isTrue(def.renderMode !== 0
2785
- /* Light */
2786
- , "".concat(def.name || 'Anonymous class', " is an invalid LWC component. Light DOM components are not available in this environment."));
2787
- }
2788
-
2789
2792
  if (vm.renderMode === 1
2790
2793
  /* Shadow */
2791
2794
  ) {
@@ -2816,6 +2819,12 @@ var LWC = (function (exports) {
2816
2819
  if (process.env.NODE_ENV !== 'production') {
2817
2820
  patchShadowRootWithRestrictions(cmpRoot);
2818
2821
  }
2822
+ }
2823
+
2824
+ function warnIfInvokedDuringConstruction(vm, methodName) {
2825
+ if (isBeingConstructed(vm)) {
2826
+ logError("this.".concat(methodName, "() should not be called during the construction of the custom element for ").concat(getComponentTag(vm), " because the element is not yet in the DOM or has no children yet."));
2827
+ }
2819
2828
  } // @ts-ignore
2820
2829
 
2821
2830
 
@@ -2929,7 +2938,7 @@ var LWC = (function (exports) {
2929
2938
  getBoundingClientRect = vm.renderer.getBoundingClientRect;
2930
2939
 
2931
2940
  if (process.env.NODE_ENV !== 'production') {
2932
- assert.isFalse(isBeingConstructed(vm), "this.getBoundingClientRect() should not be called during the construction of the custom element for ".concat(getComponentTag(vm), " because the element is not yet in the DOM, instead, you can use it in one of the available life-cycle hooks."));
2941
+ warnIfInvokedDuringConstruction(vm, 'getBoundingClientRect');
2933
2942
  }
2934
2943
 
2935
2944
  return getBoundingClientRect(elm);
@@ -2940,7 +2949,7 @@ var LWC = (function (exports) {
2940
2949
  querySelector = vm.renderer.querySelector;
2941
2950
 
2942
2951
  if (process.env.NODE_ENV !== 'production') {
2943
- assert.isFalse(isBeingConstructed(vm), "this.querySelector() cannot be called during the construction of the custom element for ".concat(getComponentTag(vm), " because no children has been added to this element yet."));
2952
+ warnIfInvokedDuringConstruction(vm, 'querySelector');
2944
2953
  }
2945
2954
 
2946
2955
  return querySelector(elm, selectors);
@@ -2951,7 +2960,7 @@ var LWC = (function (exports) {
2951
2960
  querySelectorAll = vm.renderer.querySelectorAll;
2952
2961
 
2953
2962
  if (process.env.NODE_ENV !== 'production') {
2954
- assert.isFalse(isBeingConstructed(vm), "this.querySelectorAll() cannot be called during the construction of the custom element for ".concat(getComponentTag(vm), " because no children has been added to this element yet."));
2963
+ warnIfInvokedDuringConstruction(vm, 'querySelectorAll');
2955
2964
  }
2956
2965
 
2957
2966
  return querySelectorAll(elm, selectors);
@@ -2962,7 +2971,7 @@ var LWC = (function (exports) {
2962
2971
  getElementsByTagName = vm.renderer.getElementsByTagName;
2963
2972
 
2964
2973
  if (process.env.NODE_ENV !== 'production') {
2965
- assert.isFalse(isBeingConstructed(vm), "this.getElementsByTagName() cannot be called during the construction of the custom element for ".concat(getComponentTag(vm), " because no children has been added to this element yet."));
2974
+ warnIfInvokedDuringConstruction(vm, 'getElementsByTagName');
2966
2975
  }
2967
2976
 
2968
2977
  return getElementsByTagName(elm, tagNameOrWildCard);
@@ -2973,7 +2982,7 @@ var LWC = (function (exports) {
2973
2982
  getElementsByClassName = vm.renderer.getElementsByClassName;
2974
2983
 
2975
2984
  if (process.env.NODE_ENV !== 'production') {
2976
- assert.isFalse(isBeingConstructed(vm), "this.getElementsByClassName() cannot be called during the construction of the custom element for ".concat(getComponentTag(vm), " because no children has been added to this element yet."));
2985
+ warnIfInvokedDuringConstruction(vm, 'getElementsByClassName');
2977
2986
  }
2978
2987
 
2979
2988
  return getElementsByClassName(elm, names);
@@ -3342,18 +3351,33 @@ var LWC = (function (exports) {
3342
3351
 
3343
3352
  function getClassDescriptorType(descriptor) {
3344
3353
  if (isFunction$1(descriptor.value)) {
3345
- return 'method';
3354
+ return "method"
3355
+ /* Method */
3356
+ ;
3346
3357
  } else if (isFunction$1(descriptor.set) || isFunction$1(descriptor.get)) {
3347
- return 'accessor';
3358
+ return "accessor"
3359
+ /* Accessor */
3360
+ ;
3348
3361
  } else {
3349
- return 'field';
3362
+ return "field"
3363
+ /* Field */
3364
+ ;
3350
3365
  }
3351
3366
  }
3352
3367
 
3353
3368
  function validateObservedField(Ctor, fieldName, descriptor) {
3354
3369
  if (!isUndefined$1(descriptor)) {
3355
3370
  var type = getClassDescriptorType(descriptor);
3356
- assert.fail("Invalid observed ".concat(fieldName, " field. Found a duplicate ").concat(type, " with the same name."));
3371
+ var message = "Invalid observed ".concat(fieldName, " field. Found a duplicate ").concat(type, " with the same name."); // [W-9927596] Ideally we always throw an error when detecting duplicate observed field.
3372
+ // This branch is only here for backward compatibility reasons.
3373
+
3374
+ if (type === "accessor"
3375
+ /* Accessor */
3376
+ ) {
3377
+ logError(message);
3378
+ } else {
3379
+ assert.fail(message);
3380
+ }
3357
3381
  }
3358
3382
  }
3359
3383
 
@@ -3380,7 +3404,16 @@ var LWC = (function (exports) {
3380
3404
  function validateFieldDecoratedWithApi(Ctor, fieldName, descriptor) {
3381
3405
  if (!isUndefined$1(descriptor)) {
3382
3406
  var type = getClassDescriptorType(descriptor);
3383
- assert.fail("Invalid @api ".concat(fieldName, " field. Found a duplicate ").concat(type, " with the same name."));
3407
+ var message = "Invalid @api ".concat(fieldName, " field. Found a duplicate ").concat(type, " with the same name."); // [W-9927596] Ideally we always throw an error when detecting duplicate public properties.
3408
+ // This branch is only here for backward compatibility reasons.
3409
+
3410
+ if (type === "accessor"
3411
+ /* Accessor */
3412
+ ) {
3413
+ logError(message);
3414
+ } else {
3415
+ assert.fail(message);
3416
+ }
3384
3417
  }
3385
3418
  }
3386
3419
 
@@ -3441,9 +3474,16 @@ var LWC = (function (exports) {
3441
3474
  // field declaration
3442
3475
  if (process.env.NODE_ENV !== 'production') {
3443
3476
  validateFieldDecoratedWithApi(Ctor, fieldName, descriptor);
3444
- }
3477
+ } // [W-9927596] If a component has both a public property and a private setter/getter
3478
+ // with the same name, the property is defined as a public accessor. This branch is
3479
+ // only here for backward compatibility reasons.
3445
3480
 
3446
- descriptor = createPublicPropertyDescriptor(fieldName);
3481
+
3482
+ if (!isUndefined$1(descriptor) && !isUndefined$1(descriptor.get)) {
3483
+ descriptor = createPublicAccessorDescriptor(fieldName, descriptor);
3484
+ } else {
3485
+ descriptor = createPublicPropertyDescriptor(fieldName);
3486
+ }
3447
3487
  }
3448
3488
 
3449
3489
  apiFields[fieldName] = descriptor;
@@ -3523,9 +3563,16 @@ var LWC = (function (exports) {
3523
3563
 
3524
3564
  if (process.env.NODE_ENV !== 'production') {
3525
3565
  validateObservedField(Ctor, _fieldName2, descriptor);
3526
- }
3566
+ } // [W-9927596] Only mark a field as observed whenever it isn't a duplicated public nor
3567
+ // tracked property. This is only here for backward compatibility purposes.
3568
+
3527
3569
 
3528
- observedFields[_fieldName2] = createObservedFieldPropertyDescriptor(_fieldName2);
3570
+ var isDuplicatePublicProp = !isUndefined$1(publicProps) && _fieldName2 in publicProps;
3571
+ var isDuplicateTrackedProp = !isUndefined$1(track) && _fieldName2 in track;
3572
+
3573
+ if (!isDuplicatePublicProp && !isDuplicateTrackedProp) {
3574
+ observedFields[_fieldName2] = createObservedFieldPropertyDescriptor(_fieldName2);
3575
+ }
3529
3576
  }
3530
3577
  }
3531
3578
 
@@ -4380,6 +4427,17 @@ var LWC = (function (exports) {
4380
4427
 
4381
4428
  function setElementShadowToken(elm, token) {
4382
4429
  elm.$shadowToken$ = token;
4430
+ } // Set the scope token class for *.scoped.css styles
4431
+
4432
+
4433
+ function setScopeTokenClassIfNecessary(elm, owner) {
4434
+ var cmpTemplate = owner.cmpTemplate,
4435
+ context = owner.context;
4436
+ var token = cmpTemplate === null || cmpTemplate === void 0 ? void 0 : cmpTemplate.stylesheetToken;
4437
+
4438
+ if (!isUndefined$1(token) && context.hasScopedStyles) {
4439
+ owner.renderer.getClassList(elm).add(token);
4440
+ }
4383
4441
  }
4384
4442
 
4385
4443
  function updateNodeHook(oldVnode, vnode) {
@@ -4443,12 +4501,13 @@ var LWC = (function (exports) {
4443
4501
 
4444
4502
  function fallbackElmHook(elm, vnode) {
4445
4503
  var owner = vnode.owner;
4504
+ setScopeTokenClassIfNecessary(elm, owner);
4446
4505
 
4447
4506
  if (owner.shadowMode === 1
4448
4507
  /* Synthetic */
4449
4508
  ) {
4450
4509
  var context = vnode.data.context;
4451
- var shadowAttribute = owner.context.shadowAttribute;
4510
+ var stylesheetToken = owner.context.stylesheetToken;
4452
4511
 
4453
4512
  if (!isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === "manual"
4454
4513
  /* manual */
@@ -4459,7 +4518,7 @@ var LWC = (function (exports) {
4459
4518
  // into each element from the template, so they can be styled accordingly.
4460
4519
 
4461
4520
 
4462
- setElementShadowToken(elm, shadowAttribute);
4521
+ setElementShadowToken(elm, stylesheetToken);
4463
4522
  }
4464
4523
 
4465
4524
  if (process.env.NODE_ENV !== 'production') {
@@ -4538,14 +4597,15 @@ var LWC = (function (exports) {
4538
4597
  mode = vnode.mode,
4539
4598
  ctor = vnode.ctor,
4540
4599
  owner = vnode.owner;
4600
+ setScopeTokenClassIfNecessary(elm, owner);
4541
4601
 
4542
4602
  if (owner.shadowMode === 1
4543
4603
  /* Synthetic */
4544
4604
  ) {
4545
- var shadowAttribute = owner.context.shadowAttribute; // when running in synthetic shadow mode, we need to set the shadowToken value
4605
+ var stylesheetToken = owner.context.stylesheetToken; // when running in synthetic shadow mode, we need to set the shadowToken value
4546
4606
  // into each element from the template, so they can be styled accordingly.
4547
4607
 
4548
- setElementShadowToken(elm, shadowAttribute);
4608
+ setElementShadowToken(elm, stylesheetToken);
4549
4609
  }
4550
4610
 
4551
4611
  var def = getComponentInternalDef(ctor);
@@ -4834,12 +4894,18 @@ var LWC = (function (exports) {
4834
4894
  };
4835
4895
 
4836
4896
  function linkNodeToShadow(elm, owner) {
4837
- var shadowMode = owner.shadowMode; // TODO [#1164]: this should eventually be done by the polyfill directly
4897
+ var renderer = owner.renderer,
4898
+ renderMode = owner.renderMode,
4899
+ shadowMode = owner.shadowMode; // TODO [#1164]: this should eventually be done by the polyfill directly
4838
4900
 
4839
- if (shadowMode === 1
4840
- /* Synthetic */
4841
- ) {
4842
- elm[KEY__SHADOW_RESOLVER] = getRenderRoot(owner)[KEY__SHADOW_RESOLVER];
4901
+ if (renderer.isSyntheticShadowDefined) {
4902
+ if (shadowMode === 1
4903
+ /* Synthetic */
4904
+ || renderMode === 0
4905
+ /* Light */
4906
+ ) {
4907
+ elm[KEY__SHADOW_RESOLVER] = getRenderRoot(owner)[KEY__SHADOW_RESOLVER];
4908
+ }
4843
4909
  }
4844
4910
  }
4845
4911
 
@@ -5176,13 +5242,10 @@ var LWC = (function (exports) {
5176
5242
  }
5177
5243
 
5178
5244
  var idx = vmBeingRendered.idx,
5179
- renderMode = vmBeingRendered.renderMode,
5180
5245
  shadowMode = vmBeingRendered.shadowMode;
5181
5246
 
5182
5247
  if (shadowMode === 1
5183
5248
  /* Synthetic */
5184
- && renderMode === 1
5185
- /* Shadow */
5186
5249
  ) {
5187
5250
  return StringReplace.call(id, /\S+/g, function (id) {
5188
5251
  return "".concat(id, "-").concat(idx);
@@ -5212,13 +5275,10 @@ var LWC = (function (exports) {
5212
5275
  }
5213
5276
 
5214
5277
  var idx = vmBeingRendered.idx,
5215
- renderMode = vmBeingRendered.renderMode,
5216
5278
  shadowMode = vmBeingRendered.shadowMode; // Apply transformation only for fragment-only-urls, and only in shadow DOM
5217
5279
 
5218
5280
  if (shadowMode === 1
5219
5281
  /* Synthetic */
5220
- && renderMode === 1
5221
- /* Shadow */
5222
5282
  && /^#/.test(url)) {
5223
5283
  return "".concat(url, "-").concat(idx);
5224
5284
  }
@@ -5319,6 +5379,10 @@ var LWC = (function (exports) {
5319
5379
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
5320
5380
  */
5321
5381
 
5382
+ function makeHostToken(token) {
5383
+ return "".concat(token, "-host");
5384
+ }
5385
+
5322
5386
  function createInlineStyleVNode(content) {
5323
5387
  return h('style', {
5324
5388
  key: 'style',
@@ -5328,55 +5392,92 @@ var LWC = (function (exports) {
5328
5392
  }, [t(content)]);
5329
5393
  }
5330
5394
 
5331
- function updateSyntheticShadowAttributes(vm, template) {
5395
+ function updateStylesheetToken(vm, template) {
5332
5396
  var elm = vm.elm,
5333
5397
  context = vm.context,
5334
5398
  renderer = vm.renderer,
5335
- renderMode = vm.renderMode;
5399
+ renderMode = vm.renderMode,
5400
+ shadowMode = vm.shadowMode;
5336
5401
  var newStylesheets = template.stylesheets,
5337
- newStylesheetTokens = template.stylesheetTokens;
5338
- var newTokens; // Reset the styling token applied to the host element.
5402
+ newStylesheetToken = template.stylesheetToken;
5403
+ var isSyntheticShadow = renderMode === 1
5404
+ /* Shadow */
5405
+ && shadowMode === 1
5406
+ /* Synthetic */
5407
+ ;
5408
+ var hasScopedStyles = context.hasScopedStyles;
5409
+ var newToken;
5410
+ var newHasTokenInClass;
5411
+ var newHasTokenInAttribute; // Reset the styling token applied to the host element.
5339
5412
 
5340
- var oldHostAttribute = context.hostAttribute;
5413
+ var oldToken = context.stylesheetToken,
5414
+ oldHasTokenInClass = context.hasTokenInClass,
5415
+ oldHasTokenInAttribute = context.hasTokenInAttribute;
5341
5416
 
5342
- if (!isUndefined$1(oldHostAttribute)) {
5343
- renderer.removeAttribute(elm, oldHostAttribute);
5417
+ if (oldHasTokenInClass) {
5418
+ renderer.getClassList(elm).remove(makeHostToken(oldToken));
5419
+ }
5420
+
5421
+ if (oldHasTokenInAttribute) {
5422
+ renderer.removeAttribute(elm, makeHostToken(oldToken));
5344
5423
  } // Apply the new template styling token to the host element, if the new template has any
5345
- // associated stylesheets.
5424
+ // associated stylesheets. In the case of light DOM, also ensure there is at least one scoped stylesheet.
5346
5425
 
5347
5426
 
5348
- if (!isUndefined$1(newStylesheets) && newStylesheets.length !== 0 && renderMode === 1
5349
- /* Shadow */
5350
- ) {
5351
- newTokens = newStylesheetTokens;
5352
- }
5427
+ if (!isUndefined$1(newStylesheets) && newStylesheets.length !== 0) {
5428
+ newToken = newStylesheetToken;
5429
+ } // Set the new styling token on the host element
5430
+
5353
5431
 
5354
- if (!isUndefined$1(newTokens)) {
5355
- renderer.setAttribute(elm, newTokens.hostAttribute, '');
5432
+ if (!isUndefined$1(newToken)) {
5433
+ if (hasScopedStyles) {
5434
+ renderer.getClassList(elm).add(makeHostToken(newToken));
5435
+ newHasTokenInClass = true;
5436
+ }
5437
+
5438
+ if (isSyntheticShadow) {
5439
+ renderer.setAttribute(elm, makeHostToken(newToken), '');
5440
+ newHasTokenInAttribute = true;
5441
+ }
5356
5442
  } // Update the styling tokens present on the context object.
5357
5443
 
5358
5444
 
5359
- context.hostAttribute = newTokens === null || newTokens === void 0 ? void 0 : newTokens.hostAttribute;
5360
- context.shadowAttribute = newTokens === null || newTokens === void 0 ? void 0 : newTokens.shadowAttribute;
5445
+ context.stylesheetToken = newToken;
5446
+ context.hasTokenInClass = newHasTokenInClass;
5447
+ context.hasTokenInAttribute = newHasTokenInAttribute;
5361
5448
  }
5362
5449
 
5363
- function evaluateStylesheetsContent(stylesheets, hostSelector, shadowSelector, nativeShadow) {
5450
+ function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
5364
5451
  var content = [];
5365
5452
 
5366
5453
  for (var _i12 = 0; _i12 < stylesheets.length; _i12++) {
5367
5454
  var stylesheet = stylesheets[_i12];
5368
5455
 
5369
5456
  if (isArray$1(stylesheet)) {
5370
- ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, hostSelector, shadowSelector, nativeShadow));
5457
+ ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, stylesheetToken, vm));
5371
5458
  } else {
5372
5459
  if (process.env.NODE_ENV !== 'production') {
5373
5460
  // in dev-mode, we support hot swapping of stylesheet, which means that
5374
5461
  // the component instance might be attempting to use an old version of
5375
5462
  // the stylesheet, while internally, we have a replacement for it.
5376
5463
  stylesheet = getStyleOrSwappedStyle(stylesheet);
5377
- }
5464
+ } // Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
5465
+ // native shadow DOM. Synthetic shadow DOM never uses `:host`.
5466
+
5467
+
5468
+ var isScopedCss = stylesheet[KEY__SCOPED_CSS];
5469
+ var useActualHostSelector = vm.renderMode === 0
5470
+ /* Light */
5471
+ ? !isScopedCss : vm.shadowMode === 0
5472
+ /* Native */
5473
+ ; // Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
5378
5474
 
5379
- ArrayPush$1.call(content, stylesheet(hostSelector, shadowSelector, nativeShadow));
5475
+ var scopeToken = isScopedCss || vm.shadowMode === 1
5476
+ /* Synthetic */
5477
+ && vm.renderMode === 1
5478
+ /* Shadow */
5479
+ ? stylesheetToken : undefined;
5480
+ ArrayPush$1.call(content, stylesheet(useActualHostSelector, scopeToken));
5380
5481
  }
5381
5482
  }
5382
5483
 
@@ -5385,34 +5486,35 @@ var LWC = (function (exports) {
5385
5486
 
5386
5487
  function getStylesheetsContent(vm, template) {
5387
5488
  var stylesheets = template.stylesheets,
5388
- stylesheetTokens = template.stylesheetTokens;
5389
- var renderMode = vm.renderMode,
5390
- shadowMode = vm.shadowMode;
5489
+ stylesheetToken = template.stylesheetToken;
5391
5490
  var content = [];
5392
5491
 
5393
5492
  if (!isUndefined$1(stylesheets) && stylesheets.length !== 0) {
5394
- var hostSelector;
5395
- var shadowSelector; // Scoping with the tokens is only necessary for synthetic shadow. For both
5396
- // light DOM elements and native shadow, we just render the CSS as-is.
5493
+ content = evaluateStylesheetsContent(stylesheets, stylesheetToken, vm);
5494
+ }
5495
+
5496
+ return content;
5497
+ } // It might be worth caching this to avoid doing the lookup repeatedly, but
5498
+ // perf testing has not shown it to be a huge improvement yet:
5499
+ // https://github.com/salesforce/lwc/pull/2460#discussion_r691208892
5500
+
5397
5501
 
5398
- if (renderMode === 1
5502
+ function getNearestNativeShadowComponent(vm) {
5503
+ var owner = vm;
5504
+
5505
+ while (!isNull(owner)) {
5506
+ if (owner.renderMode === 1
5399
5507
  /* Shadow */
5400
- && shadowMode === 1
5401
- /* Synthetic */
5402
- && !isUndefined$1(stylesheetTokens)) {
5403
- hostSelector = "[".concat(stylesheetTokens.hostAttribute, "]");
5404
- shadowSelector = "[".concat(stylesheetTokens.shadowAttribute, "]");
5405
- } else {
5406
- hostSelector = '';
5407
- shadowSelector = '';
5508
+ && owner.shadowMode === 0
5509
+ /* Native */
5510
+ ) {
5511
+ return owner;
5408
5512
  }
5409
5513
 
5410
- content = evaluateStylesheetsContent(stylesheets, hostSelector, shadowSelector, shadowMode === 0
5411
- /* Native */
5412
- );
5514
+ owner = owner.owner;
5413
5515
  }
5414
5516
 
5415
- return content;
5517
+ return owner;
5416
5518
  }
5417
5519
 
5418
5520
  function createStylesheet(vm, stylesheets) {
@@ -5428,13 +5530,26 @@ var LWC = (function (exports) {
5428
5530
  for (var _i13 = 0; _i13 < stylesheets.length; _i13++) {
5429
5531
  renderer.insertGlobalStylesheet(stylesheets[_i13]);
5430
5532
  }
5431
-
5432
- return null;
5433
- } else {
5434
- // native shadow or light DOM
5533
+ } else if (renderer.ssr) {
5534
+ // native shadow or light DOM, SSR
5435
5535
  var combinedStylesheetContent = ArrayJoin.call(stylesheets, '\n');
5436
5536
  return createInlineStyleVNode(combinedStylesheetContent);
5537
+ } else {
5538
+ // native shadow or light DOM, DOM renderer
5539
+ var root = getNearestNativeShadowComponent(vm);
5540
+ var isGlobal = isNull(root);
5541
+
5542
+ for (var _i14 = 0; _i14 < stylesheets.length; _i14++) {
5543
+ if (isGlobal) {
5544
+ renderer.insertGlobalStylesheet(stylesheets[_i14]);
5545
+ } else {
5546
+ // local level
5547
+ renderer.insertStylesheet(stylesheets[_i14], root.cmpRoot);
5548
+ }
5549
+ }
5437
5550
  }
5551
+
5552
+ return null;
5438
5553
  }
5439
5554
  /*
5440
5555
  * Copyright (c) 2018, salesforce.com, inc.
@@ -5632,8 +5747,7 @@ var LWC = (function (exports) {
5632
5747
  context = vm.context,
5633
5748
  cmpSlots = vm.cmpSlots,
5634
5749
  cmpTemplate = vm.cmpTemplate,
5635
- tro = vm.tro,
5636
- shadowMode = vm.shadowMode;
5750
+ tro = vm.tro;
5637
5751
  tro.observe(function () {
5638
5752
  // Reset the cache memoizer for template when needed.
5639
5753
  if (html !== cmpTemplate) {
@@ -5657,15 +5771,12 @@ var LWC = (function (exports) {
5657
5771
 
5658
5772
  vm.cmpTemplate = html; // Create a brand new template cache for the swapped templated.
5659
5773
 
5660
- context.tplCache = create(null); // Update the synthetic shadow attributes on the host element if necessary.
5774
+ context.tplCache = create(null); // Set the computeHasScopedStyles property in the context, to avoid recomputing it repeatedly.
5661
5775
 
5662
- if (shadowMode === 1
5663
- /* Synthetic */
5664
- ) {
5665
- updateSyntheticShadowAttributes(vm, html);
5666
- } // Evaluate, create stylesheet and cache the produced VNode for future
5667
- // re-rendering.
5776
+ context.hasScopedStyles = computeHasScopedStyles(html); // Update the scoping token on the host element.
5668
5777
 
5778
+ updateStylesheetToken(vm, html); // Evaluate, create stylesheet and cache the produced VNode for future
5779
+ // re-rendering.
5669
5780
 
5670
5781
  var stylesheetsContent = getStylesheetsContent(vm, html);
5671
5782
  context.styleVNode = stylesheetsContent.length === 0 ? null : createStylesheet(vm, stylesheetsContent);
@@ -5705,6 +5816,20 @@ var LWC = (function (exports) {
5705
5816
 
5706
5817
  return vnodes;
5707
5818
  }
5819
+
5820
+ function computeHasScopedStyles(template) {
5821
+ var stylesheets = template.stylesheets;
5822
+
5823
+ if (!isUndefined$1(stylesheets)) {
5824
+ for (var _i15 = 0; _i15 < stylesheets.length; _i15++) {
5825
+ if (isTrue(stylesheets[_i15][KEY__SCOPED_CSS])) {
5826
+ return true;
5827
+ }
5828
+ }
5829
+ }
5830
+
5831
+ return false;
5832
+ }
5708
5833
  /*
5709
5834
  * Copyright (c) 2018, salesforce.com, inc.
5710
5835
  * All rights reserved.
@@ -5927,8 +6052,8 @@ var LWC = (function (exports) {
5927
6052
  assert.isTrue(isObject(service), "Invalid service declaration, ".concat(service, ": service must be an object"));
5928
6053
  }
5929
6054
 
5930
- for (var _i14 = 0; _i14 < hooks.length; ++_i14) {
5931
- var hookName = hooks[_i14];
6055
+ for (var _i16 = 0; _i16 < hooks.length; ++_i16) {
6056
+ var hookName = hooks[_i16];
5932
6057
 
5933
6058
  if (hookName in service) {
5934
6059
  var l = Services[hookName];
@@ -5951,8 +6076,8 @@ var LWC = (function (exports) {
5951
6076
  def = vm.def,
5952
6077
  context = vm.context;
5953
6078
 
5954
- for (var _i15 = 0, _len6 = cbs.length; _i15 < _len6; ++_i15) {
5955
- cbs[_i15].call(undefined, component, {}, def, context);
6079
+ for (var _i17 = 0, _len6 = cbs.length; _i17 < _len6; ++_i17) {
6080
+ cbs[_i17].call(undefined, component, {}, def, context);
5956
6081
  }
5957
6082
  }
5958
6083
  /*
@@ -5963,7 +6088,6 @@ var LWC = (function (exports) {
5963
6088
  */
5964
6089
 
5965
6090
 
5966
- var isNativeShadowRootDefined = _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED];
5967
6091
  var idx = 0;
5968
6092
  /** The internal slot used to associate different objects the engine manipulates with the VM */
5969
6093
 
@@ -6069,50 +6193,11 @@ var LWC = (function (exports) {
6069
6193
  return ancestor;
6070
6194
  }
6071
6195
 
6072
- function assertNotSyntheticComposedWithinNative(vm) {
6073
- var isSynthetic = vm.renderMode === 1
6074
- /* Shadow */
6075
- && vm.shadowMode === 1
6076
- /* Synthetic */
6077
- ;
6078
-
6079
- if (!isSynthetic) {
6080
- return;
6081
- }
6082
-
6083
- var ancestor = getNearestShadowAncestor(vm);
6084
-
6085
- if (!isNull(ancestor)) {
6086
- // Any native shadow component being an ancestor of a synthetic shadow component is disallowed.
6087
- assert.isFalse(ancestor.renderMode === 1
6088
- /* Shadow */
6089
- && ancestor.shadowMode === 0
6090
- /* Native */
6091
- , "".concat(getComponentTag(vm), " (synthetic shadow DOM) cannot be composed inside of ").concat(getComponentTag(ancestor), " (native shadow DOM), because synthetic-within-native composition is disallowed"));
6092
- }
6093
- }
6094
-
6095
6196
  function createVM(elm, def, options) {
6096
6197
  var mode = options.mode,
6097
6198
  owner = options.owner,
6098
6199
  renderer = options.renderer,
6099
6200
  tagName = options.tagName;
6100
- var shadowMode;
6101
-
6102
- if (renderer.syntheticShadow) {
6103
- shadowMode = def.shadowSupportMode === "any"
6104
- /* Any */
6105
- && isNativeShadowRootDefined ? 0
6106
- /* Native */
6107
- : 1
6108
- /* Synthetic */
6109
- ;
6110
- } else {
6111
- shadowMode = 0
6112
- /* Native */
6113
- ;
6114
- }
6115
-
6116
6201
  var vm = {
6117
6202
  elm: elm,
6118
6203
  def: def,
@@ -6135,10 +6220,12 @@ var LWC = (function (exports) {
6135
6220
  oar: create(null),
6136
6221
  cmpTemplate: null,
6137
6222
  renderMode: def.renderMode,
6138
- shadowMode: shadowMode,
6223
+ shadowMode: null,
6139
6224
  context: {
6140
- hostAttribute: undefined,
6141
- shadowAttribute: undefined,
6225
+ stylesheetToken: undefined,
6226
+ hasTokenInClass: undefined,
6227
+ hasTokenInAttribute: undefined,
6228
+ hasScopedStyles: undefined,
6142
6229
  styleVNode: null,
6143
6230
  tplCache: EmptyObject,
6144
6231
  wiredConnecting: EmptyArray,
@@ -6151,26 +6238,83 @@ var LWC = (function (exports) {
6151
6238
  setHook: setHook,
6152
6239
  getHook: getHook
6153
6240
  };
6241
+ vm.shadowMode = computeShadowMode(vm);
6154
6242
  vm.tro = getTemplateReactiveObserver(vm);
6155
6243
 
6156
6244
  if (process.env.NODE_ENV !== 'production') {
6157
6245
  vm.toString = function () {
6158
6246
  return "[object:vm ".concat(def.name, " (").concat(vm.idx, ")]");
6159
6247
  };
6160
-
6161
- assertNotSyntheticComposedWithinNative(vm);
6162
6248
  } // Create component instance associated to the vm and the element.
6163
6249
 
6164
6250
 
6165
6251
  invokeComponentConstructor(vm, def.ctor); // Initializing the wire decorator per instance only when really needed
6166
6252
 
6167
- if (isFalse(renderer.ssr) && hasWireAdapters(vm)) {
6253
+ if (hasWireAdapters(vm)) {
6168
6254
  installWireAdapters(vm);
6169
6255
  }
6170
6256
 
6171
6257
  return vm;
6172
6258
  }
6173
6259
 
6260
+ function computeShadowMode(vm) {
6261
+ var def = vm.def,
6262
+ renderer = vm.renderer;
6263
+ var isNativeShadowDefined = renderer.isNativeShadowDefined,
6264
+ isSyntheticShadowDefined = renderer.isSyntheticShadowDefined;
6265
+ var shadowMode;
6266
+
6267
+ if (isSyntheticShadowDefined) {
6268
+ if (def.renderMode === 0
6269
+ /* Light */
6270
+ ) {
6271
+ // ShadowMode.Native implies "not synthetic shadow" which is consistent with how
6272
+ // everything defaults to native when the synthetic shadow polyfill is unavailable.
6273
+ shadowMode = 0
6274
+ /* Native */
6275
+ ;
6276
+ } else if (isNativeShadowDefined) {
6277
+ if (def.shadowSupportMode === "any"
6278
+ /* Any */
6279
+ ) {
6280
+ shadowMode = 0
6281
+ /* Native */
6282
+ ;
6283
+ } else {
6284
+ var shadowAncestor = getNearestShadowAncestor(vm);
6285
+
6286
+ if (!isNull(shadowAncestor) && shadowAncestor.shadowMode === 0
6287
+ /* Native */
6288
+ ) {
6289
+ // Transitive support for native Shadow DOM. A component in native mode
6290
+ // transitively opts all of its descendants into native.
6291
+ shadowMode = 0
6292
+ /* Native */
6293
+ ;
6294
+ } else {
6295
+ // Synthetic if neither this component nor any of its ancestors are configured
6296
+ // to be native.
6297
+ shadowMode = 1
6298
+ /* Synthetic */
6299
+ ;
6300
+ }
6301
+ }
6302
+ } else {
6303
+ // Synthetic if there is no native Shadow DOM support.
6304
+ shadowMode = 1
6305
+ /* Synthetic */
6306
+ ;
6307
+ }
6308
+ } else {
6309
+ // Native if the synthetic shadow polyfill is unavailable.
6310
+ shadowMode = 0
6311
+ /* Native */
6312
+ ;
6313
+ }
6314
+
6315
+ return shadowMode;
6316
+ }
6317
+
6174
6318
  function assertIsVM(obj) {
6175
6319
  if (isNull(obj) || !isObject(obj) || !('cmpRoot' in obj)) {
6176
6320
  throw new TypeError("".concat(obj, " is not a VM."));
@@ -6290,19 +6434,19 @@ var LWC = (function (exports) {
6290
6434
  });
6291
6435
  rehydrateQueue = []; // reset to a new queue
6292
6436
 
6293
- for (var _i16 = 0, _len7 = vms.length; _i16 < _len7; _i16 += 1) {
6294
- var vm = vms[_i16];
6437
+ for (var _i18 = 0, _len7 = vms.length; _i18 < _len7; _i18 += 1) {
6438
+ var vm = vms[_i18];
6295
6439
 
6296
6440
  try {
6297
6441
  rehydrate(vm);
6298
6442
  } catch (error) {
6299
- if (_i16 + 1 < _len7) {
6443
+ if (_i18 + 1 < _len7) {
6300
6444
  // pieces of the queue are still pending to be rehydrated, those should have priority
6301
6445
  if (rehydrateQueue.length === 0) {
6302
6446
  addCallbackToNextTick(flushRehydrationQueue);
6303
6447
  }
6304
6448
 
6305
- ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i16 + 1));
6449
+ ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i18 + 1));
6306
6450
  } // we need to end the measure before throwing.
6307
6451
 
6308
6452
 
@@ -6406,8 +6550,8 @@ var LWC = (function (exports) {
6406
6550
  var vCustomElementCollection = vm.velements; // Reporting disconnection for every child in inverse order since they are
6407
6551
  // inserted in reserved order.
6408
6552
 
6409
- for (var _i17 = vCustomElementCollection.length - 1; _i17 >= 0; _i17 -= 1) {
6410
- var elm = vCustomElementCollection[_i17].elm; // There are two cases where the element could be undefined:
6553
+ for (var _i19 = vCustomElementCollection.length - 1; _i19 >= 0; _i19 -= 1) {
6554
+ var elm = vCustomElementCollection[_i19].elm; // There are two cases where the element could be undefined:
6411
6555
  // * when there is an error during the construction phase, and an error
6412
6556
  // boundary picks it, there is a possibility that the VCustomElement
6413
6557
  // is not properly initialized, and therefore is should be ignored.
@@ -6441,8 +6585,8 @@ var LWC = (function (exports) {
6441
6585
 
6442
6586
 
6443
6587
  function recursivelyDisconnectChildren(vnodes) {
6444
- for (var _i18 = 0, _len8 = vnodes.length; _i18 < _len8; _i18 += 1) {
6445
- var vnode = vnodes[_i18];
6588
+ for (var _i20 = 0, _len8 = vnodes.length; _i20 < _len8; _i20 += 1) {
6589
+ var vnode = vnodes[_i20];
6446
6590
 
6447
6591
  if (!isNull(vnode) && isArray$1(vnode.children) && !isUndefined$1(vnode.elm)) {
6448
6592
  // vnode is a VElement with children
@@ -6466,8 +6610,8 @@ var LWC = (function (exports) {
6466
6610
  renderer = vm.renderer;
6467
6611
  var rootNode = getRenderRoot(vm);
6468
6612
 
6469
- for (var _i19 = 0, _len9 = children.length; _i19 < _len9; _i19++) {
6470
- var child = children[_i19];
6613
+ for (var _i21 = 0, _len9 = children.length; _i21 < _len9; _i21++) {
6614
+ var child = children[_i21];
6471
6615
 
6472
6616
  if (!isNull(child) && !isUndefined$1(child.elm)) {
6473
6617
  renderer.remove(child.elm, rootNode);
@@ -6512,8 +6656,8 @@ var LWC = (function (exports) {
6512
6656
  var oldSlots = vm.cmpSlots;
6513
6657
  var cmpSlots = vm.cmpSlots = create(null);
6514
6658
 
6515
- for (var _i20 = 0, _len10 = children.length; _i20 < _len10; _i20 += 1) {
6516
- var vnode = children[_i20];
6659
+ for (var _i22 = 0, _len10 = children.length; _i22 < _len10; _i22 += 1) {
6660
+ var vnode = children[_i22];
6517
6661
 
6518
6662
  if (isNull(vnode)) {
6519
6663
  continue;
@@ -6543,8 +6687,8 @@ var LWC = (function (exports) {
6543
6687
  return;
6544
6688
  }
6545
6689
 
6546
- for (var _i21 = 0, _len11 = oldKeys.length; _i21 < _len11; _i21 += 1) {
6547
- var key = oldKeys[_i21];
6690
+ for (var _i23 = 0, _len11 = oldKeys.length; _i23 < _len11; _i23 += 1) {
6691
+ var key = oldKeys[_i23];
6548
6692
 
6549
6693
  if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
6550
6694
  markComponentAsDirty(vm);
@@ -6886,11 +7030,14 @@ var LWC = (function (exports) {
6886
7030
  ArrayPush$1.call(wiredConnecting, function () {
6887
7031
  connector.connect();
6888
7032
 
6889
- if (hasDynamicParams) {
6890
- Promise.resolve().then(computeConfigAndUpdate);
6891
- } else {
6892
- computeConfigAndUpdate();
7033
+ if (!runtimeFlags.ENABLE_WIRE_SYNC_EMIT) {
7034
+ if (hasDynamicParams) {
7035
+ Promise.resolve().then(computeConfigAndUpdate);
7036
+ return;
7037
+ }
6893
7038
  }
7039
+
7040
+ computeConfigAndUpdate();
6894
7041
  });
6895
7042
  ArrayPush$1.call(wiredDisconnecting, function () {
6896
7043
  connector.disconnect();
@@ -6904,8 +7051,8 @@ var LWC = (function (exports) {
6904
7051
  function connectWireAdapters(vm) {
6905
7052
  var wiredConnecting = vm.context.wiredConnecting;
6906
7053
 
6907
- for (var _i22 = 0, _len12 = wiredConnecting.length; _i22 < _len12; _i22 += 1) {
6908
- wiredConnecting[_i22]();
7054
+ for (var _i24 = 0, _len12 = wiredConnecting.length; _i24 < _len12; _i24 += 1) {
7055
+ wiredConnecting[_i24]();
6909
7056
  }
6910
7057
  }
6911
7058
 
@@ -6913,8 +7060,8 @@ var LWC = (function (exports) {
6913
7060
  var wiredDisconnecting = vm.context.wiredDisconnecting;
6914
7061
  runWithBoundaryProtection(vm, vm, noop, function () {
6915
7062
  // job
6916
- for (var _i23 = 0, _len13 = wiredDisconnecting.length; _i23 < _len13; _i23 += 1) {
6917
- wiredDisconnecting[_i23]();
7063
+ for (var _i25 = 0, _len13 = wiredDisconnecting.length; _i25 < _len13; _i25 += 1) {
7064
+ wiredDisconnecting[_i25]();
6918
7065
  }
6919
7066
  }, noop);
6920
7067
  }
@@ -6989,7 +7136,7 @@ var LWC = (function (exports) {
6989
7136
 
6990
7137
  return reactiveMembrane.getReadOnlyProxy(obj);
6991
7138
  }
6992
- /* version: 2.3.4 */
7139
+ /* version: 2.5.1 */
6993
7140
 
6994
7141
  /*
6995
7142
  * Copyright (c) 2018, salesforce.com, inc.
@@ -7004,14 +7151,18 @@ var LWC = (function (exports) {
7004
7151
  if (process.env.NODE_ENV === 'development') {
7005
7152
  // @ts-ignore
7006
7153
  window.__lwcResetGlobalStylesheets = function () {
7007
- for (var _i24 = 0, _Object$keys = Object.keys(globalStylesheets); _i24 < _Object$keys.length; _i24++) {
7008
- var key = _Object$keys[_i24];
7154
+ for (var _i26 = 0, _Object$keys = Object.keys(globalStylesheets); _i26 < _Object$keys.length; _i26++) {
7155
+ var key = _Object$keys[_i26];
7009
7156
  delete globalStylesheets[key];
7010
7157
  }
7011
7158
  };
7012
7159
  }
7013
7160
 
7014
7161
  var globalStylesheetsParentElement = document.head || document.body || document;
7162
+ var supportsConstructableStyleSheets = isFunction$1(CSSStyleSheet.prototype.replaceSync);
7163
+ var styleElements = create(null);
7164
+ var styleSheets = create(null);
7165
+ var nodesToStyleSheets = new WeakMap();
7015
7166
  var getCustomElement, defineCustomElement, HTMLElementConstructor;
7016
7167
 
7017
7168
  function isCustomElementRegistryAvailable() {
@@ -7050,6 +7201,52 @@ var LWC = (function (exports) {
7050
7201
  }
7051
7202
  }
7052
7203
 
7204
+ function insertConstructableStyleSheet(content, target) {
7205
+ // It's important for CSSStyleSheets to be unique based on their content, so that
7206
+ // `shadowRoot.adoptedStyleSheets.includes(sheet)` works.
7207
+ var styleSheet = styleSheets[content];
7208
+
7209
+ if (isUndefined$1(styleSheet)) {
7210
+ styleSheet = new CSSStyleSheet();
7211
+ styleSheet.replaceSync(content);
7212
+ styleSheets[content] = styleSheet;
7213
+ }
7214
+
7215
+ if (!target.adoptedStyleSheets.includes(styleSheet)) {
7216
+ target.adoptedStyleSheets = [].concat(_toConsumableArray(target.adoptedStyleSheets), [styleSheet]);
7217
+ }
7218
+ }
7219
+
7220
+ function insertStyleElement(content, target) {
7221
+ // Avoid inserting duplicate `<style>`s
7222
+ var sheets = nodesToStyleSheets.get(target);
7223
+
7224
+ if (isUndefined$1(sheets)) {
7225
+ sheets = create(null);
7226
+ nodesToStyleSheets.set(target, sheets);
7227
+ }
7228
+
7229
+ if (sheets[content]) {
7230
+ return;
7231
+ }
7232
+
7233
+ sheets[content] = true; // This `<style>` may be repeated multiple times in the DOM, so cache it. It's a bit
7234
+ // faster to call `cloneNode()` on an existing node than to recreate it every time.
7235
+
7236
+ var elm = styleElements[content];
7237
+
7238
+ if (isUndefined$1(elm)) {
7239
+ elm = document.createElement('style');
7240
+ elm.type = 'text/css';
7241
+ elm.textContent = content;
7242
+ styleElements[content] = elm;
7243
+ } else {
7244
+ elm = elm.cloneNode(true);
7245
+ }
7246
+
7247
+ target.appendChild(elm);
7248
+ }
7249
+
7053
7250
  if (isCustomElementRegistryAvailable()) {
7054
7251
  getCustomElement = customElements.get.bind(customElements);
7055
7252
  defineCustomElement = customElements.define.bind(customElements);
@@ -7093,7 +7290,8 @@ var LWC = (function (exports) {
7093
7290
 
7094
7291
  var renderer = {
7095
7292
  ssr: false,
7096
- syntheticShadow: hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN),
7293
+ isNativeShadowDefined: _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED],
7294
+ isSyntheticShadowDefined: hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN),
7097
7295
  createElement: function createElement(tagName, namespace) {
7098
7296
  return isUndefined$1(namespace) ? document.createElement(tagName) : document.createElementNS(namespace, tagName);
7099
7297
  },
@@ -7190,6 +7388,14 @@ var LWC = (function (exports) {
7190
7388
  elm.textContent = content;
7191
7389
  globalStylesheetsParentElement.appendChild(elm);
7192
7390
  },
7391
+ insertStylesheet: function insertStylesheet(content, target) {
7392
+ if (supportsConstructableStyleSheets) {
7393
+ insertConstructableStyleSheet(content, target);
7394
+ } else {
7395
+ // Fall back to <style> element
7396
+ insertStyleElement(content, target);
7397
+ }
7398
+ },
7193
7399
  assertInstanceOfHTMLElement: function assertInstanceOfHTMLElement(elm, msg) {
7194
7400
  assert.invariant(elm instanceof HTMLElement, msg);
7195
7401
  },
@@ -7431,7 +7637,7 @@ var LWC = (function (exports) {
7431
7637
  return false;
7432
7638
  }
7433
7639
 
7434
- if (renderer.syntheticShadow) {
7640
+ if (renderer.isSyntheticShadowDefined) {
7435
7641
  // TODO [#1252]: old behavior that is still used by some pieces of the platform,
7436
7642
  // specifically, nodes inserted manually on places where `lwc:dom="manual"` directive is not
7437
7643
  // used, will be considered global elements.
@@ -7483,7 +7689,7 @@ var LWC = (function (exports) {
7483
7689
  });
7484
7690
  freeze(LightningElement);
7485
7691
  seal(LightningElement.prototype);
7486
- /* version: 2.3.4 */
7692
+ /* version: 2.5.1 */
7487
7693
 
7488
7694
  exports.LightningElement = LightningElement;
7489
7695
  exports.__unstable__ProfilerControl = profilerControl;