lwc 2.20.0 → 2.20.3

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 +235 -202
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +235 -202
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +225 -192
  5. package/dist/engine-dom/iife/es5/engine-dom.js +320 -285
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +310 -274
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +235 -202
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +225 -192
  11. package/dist/engine-dom/umd/es5/engine-dom.js +320 -285
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +310 -274
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +177 -169
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +177 -169
  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
@@ -368,9 +368,9 @@
368
368
  // Increment whenever the LWC template compiler changes
369
369
 
370
370
 
371
- var LWC_VERSION = "2.20.0";
371
+ var LWC_VERSION = "2.20.3";
372
372
  var LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
373
- /** version: 2.20.0 */
373
+ /** version: 2.20.3 */
374
374
 
375
375
  /*
376
376
  * Copyright (c) 2018, salesforce.com, inc.
@@ -549,7 +549,7 @@
549
549
  setFeatureFlag(name, value);
550
550
  }
551
551
  }
552
- /** version: 2.20.0 */
552
+ /** version: 2.20.3 */
553
553
 
554
554
  /*
555
555
  * Copyright (c) 2018, salesforce.com, inc.
@@ -4119,6 +4119,241 @@
4119
4119
  methods: publicMethods
4120
4120
  };
4121
4121
  }
4122
+ /*
4123
+ * Copyright (c) 2018, salesforce.com, inc.
4124
+ * All rights reserved.
4125
+ * SPDX-License-Identifier: MIT
4126
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4127
+ */
4128
+
4129
+
4130
+ function makeHostToken(token) {
4131
+ return "".concat(token, "-host");
4132
+ }
4133
+
4134
+ function createInlineStyleVNode(content) {
4135
+ return api.h('style', {
4136
+ key: 'style',
4137
+ attrs: {
4138
+ type: 'text/css'
4139
+ }
4140
+ }, [api.t(content)]);
4141
+ }
4142
+
4143
+ function updateStylesheetToken(vm, template) {
4144
+ var elm = vm.elm,
4145
+ context = vm.context,
4146
+ renderMode = vm.renderMode,
4147
+ shadowMode = vm.shadowMode,
4148
+ _vm$renderer = vm.renderer,
4149
+ getClassList = _vm$renderer.getClassList,
4150
+ removeAttribute = _vm$renderer.removeAttribute,
4151
+ setAttribute = _vm$renderer.setAttribute;
4152
+ var newStylesheets = template.stylesheets,
4153
+ newStylesheetToken = template.stylesheetToken;
4154
+ var isSyntheticShadow = renderMode === 1
4155
+ /* RenderMode.Shadow */
4156
+ && shadowMode === 1
4157
+ /* ShadowMode.Synthetic */
4158
+ ;
4159
+ var hasScopedStyles = context.hasScopedStyles;
4160
+ var newToken;
4161
+ var newHasTokenInClass;
4162
+ var newHasTokenInAttribute; // Reset the styling token applied to the host element.
4163
+
4164
+ var oldToken = context.stylesheetToken,
4165
+ oldHasTokenInClass = context.hasTokenInClass,
4166
+ oldHasTokenInAttribute = context.hasTokenInAttribute;
4167
+
4168
+ if (!isUndefined$1(oldToken)) {
4169
+ if (oldHasTokenInClass) {
4170
+ getClassList(elm).remove(makeHostToken(oldToken));
4171
+ }
4172
+
4173
+ if (oldHasTokenInAttribute) {
4174
+ removeAttribute(elm, makeHostToken(oldToken));
4175
+ }
4176
+ } // Apply the new template styling token to the host element, if the new template has any
4177
+ // associated stylesheets. In the case of light DOM, also ensure there is at least one scoped stylesheet.
4178
+
4179
+
4180
+ if (!isUndefined$1(newStylesheets) && newStylesheets.length !== 0) {
4181
+ newToken = newStylesheetToken;
4182
+ } // Set the new styling token on the host element
4183
+
4184
+
4185
+ if (!isUndefined$1(newToken)) {
4186
+ if (hasScopedStyles) {
4187
+ getClassList(elm).add(makeHostToken(newToken));
4188
+ newHasTokenInClass = true;
4189
+ }
4190
+
4191
+ if (isSyntheticShadow) {
4192
+ setAttribute(elm, makeHostToken(newToken), '');
4193
+ newHasTokenInAttribute = true;
4194
+ }
4195
+ } // Update the styling tokens present on the context object.
4196
+
4197
+
4198
+ context.stylesheetToken = newToken;
4199
+ context.hasTokenInClass = newHasTokenInClass;
4200
+ context.hasTokenInAttribute = newHasTokenInAttribute;
4201
+ }
4202
+
4203
+ function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
4204
+ var content = [];
4205
+ var root;
4206
+
4207
+ for (var _i11 = 0; _i11 < stylesheets.length; _i11++) {
4208
+ var stylesheet = stylesheets[_i11];
4209
+
4210
+ if (isArray$1(stylesheet)) {
4211
+ ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, stylesheetToken, vm));
4212
+ } else {
4213
+ if (process.env.NODE_ENV !== 'production') {
4214
+ // Check for compiler version mismatch in dev mode only
4215
+ checkVersionMismatch(stylesheet, 'stylesheet'); // in dev-mode, we support hot swapping of stylesheet, which means that
4216
+ // the component instance might be attempting to use an old version of
4217
+ // the stylesheet, while internally, we have a replacement for it.
4218
+
4219
+ stylesheet = getStyleOrSwappedStyle(stylesheet);
4220
+ }
4221
+
4222
+ var isScopedCss = stylesheet[KEY__SCOPED_CSS]; // Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
4223
+
4224
+ var scopeToken = isScopedCss || vm.shadowMode === 1
4225
+ /* ShadowMode.Synthetic */
4226
+ && vm.renderMode === 1
4227
+ /* RenderMode.Shadow */
4228
+ ? stylesheetToken : undefined; // Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
4229
+ // native shadow DOM. Synthetic shadow DOM never uses `:host`.
4230
+
4231
+ var useActualHostSelector = vm.renderMode === 0
4232
+ /* RenderMode.Light */
4233
+ ? !isScopedCss : vm.shadowMode === 0
4234
+ /* ShadowMode.Native */
4235
+ ; // Use the native :dir() pseudoclass only in native shadow DOM. Otherwise, in synthetic shadow,
4236
+ // we use an attribute selector on the host to simulate :dir().
4237
+
4238
+ var useNativeDirPseudoclass = void 0;
4239
+
4240
+ if (vm.renderMode === 1
4241
+ /* RenderMode.Shadow */
4242
+ ) {
4243
+ useNativeDirPseudoclass = vm.shadowMode === 0
4244
+ /* ShadowMode.Native */
4245
+ ;
4246
+ } else {
4247
+ // Light DOM components should only render `[dir]` if they're inside of a synthetic shadow root.
4248
+ // At the top level (root is null) or inside of a native shadow root, they should use `:dir()`.
4249
+ if (isUndefined$1(root)) {
4250
+ // Only calculate the root once as necessary
4251
+ root = getNearestShadowComponent(vm);
4252
+ }
4253
+
4254
+ useNativeDirPseudoclass = isNull(root) || root.shadowMode === 0
4255
+ /* ShadowMode.Native */
4256
+ ;
4257
+ }
4258
+
4259
+ ArrayPush$1.call(content, stylesheet(scopeToken, useActualHostSelector, useNativeDirPseudoclass));
4260
+ }
4261
+ }
4262
+
4263
+ return content;
4264
+ }
4265
+
4266
+ function getStylesheetsContent(vm, template) {
4267
+ var stylesheets = template.stylesheets,
4268
+ stylesheetToken = template.stylesheetToken;
4269
+ var content = [];
4270
+
4271
+ if (!isUndefined$1(stylesheets) && stylesheets.length !== 0) {
4272
+ content = evaluateStylesheetsContent(stylesheets, stylesheetToken, vm);
4273
+ }
4274
+
4275
+ return content;
4276
+ } // It might be worth caching this to avoid doing the lookup repeatedly, but
4277
+ // perf testing has not shown it to be a huge improvement yet:
4278
+ // https://github.com/salesforce/lwc/pull/2460#discussion_r691208892
4279
+
4280
+
4281
+ function getNearestShadowComponent(vm) {
4282
+ var owner = vm;
4283
+
4284
+ while (!isNull(owner)) {
4285
+ if (owner.renderMode === 1
4286
+ /* RenderMode.Shadow */
4287
+ ) {
4288
+ return owner;
4289
+ }
4290
+
4291
+ owner = owner.owner;
4292
+ }
4293
+
4294
+ return owner;
4295
+ }
4296
+ /**
4297
+ * If the component that is currently being rendered uses scoped styles,
4298
+ * this returns the unique token for that scoped stylesheet. Otherwise
4299
+ * it returns null.
4300
+ */
4301
+
4302
+
4303
+ function getScopeTokenClass(owner) {
4304
+ var cmpTemplate = owner.cmpTemplate,
4305
+ context = owner.context;
4306
+ return context.hasScopedStyles && (cmpTemplate === null || cmpTemplate === void 0 ? void 0 : cmpTemplate.stylesheetToken) || null;
4307
+ }
4308
+
4309
+ function getNearestNativeShadowComponent(vm) {
4310
+ var owner = getNearestShadowComponent(vm);
4311
+
4312
+ if (!isNull(owner) && owner.shadowMode === 1
4313
+ /* ShadowMode.Synthetic */
4314
+ ) {
4315
+ // Synthetic-within-native is impossible. So if the nearest shadow component is
4316
+ // synthetic, we know we won't find a native component if we go any further.
4317
+ return null;
4318
+ }
4319
+
4320
+ return owner;
4321
+ }
4322
+
4323
+ function createStylesheet(vm, stylesheets) {
4324
+ var renderMode = vm.renderMode,
4325
+ shadowMode = vm.shadowMode,
4326
+ _vm$renderer2 = vm.renderer,
4327
+ ssr = _vm$renderer2.ssr,
4328
+ insertStylesheet = _vm$renderer2.insertStylesheet;
4329
+
4330
+ if (renderMode === 1
4331
+ /* RenderMode.Shadow */
4332
+ && shadowMode === 1
4333
+ /* ShadowMode.Synthetic */
4334
+ ) {
4335
+ for (var _i12 = 0; _i12 < stylesheets.length; _i12++) {
4336
+ insertStylesheet(stylesheets[_i12]);
4337
+ }
4338
+ } else if (ssr || vm.hydrated) {
4339
+ // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
4340
+ // This works in the client, because the stylesheets are created, and cached in the VM
4341
+ // the first time the VM renders.
4342
+ // native shadow or light DOM, SSR
4343
+ return ArrayMap.call(stylesheets, createInlineStyleVNode);
4344
+ } else {
4345
+ // native shadow or light DOM, DOM renderer
4346
+ var root = getNearestNativeShadowComponent(vm); // null root means a global style
4347
+
4348
+ var target = isNull(root) ? undefined : root.shadowRoot;
4349
+
4350
+ for (var _i13 = 0; _i13 < stylesheets.length; _i13++) {
4351
+ insertStylesheet(stylesheets[_i13], target);
4352
+ }
4353
+ }
4354
+
4355
+ return null;
4356
+ }
4122
4357
  /*
4123
4358
  * Copyright (c) 2020, salesforce.com, inc.
4124
4359
  * All rights reserved.
@@ -4461,8 +4696,8 @@
4461
4696
 
4462
4697
  var setCSSStyleProperty = renderer.setCSSStyleProperty;
4463
4698
 
4464
- for (var _i11 = 0; _i11 < styleDecls.length; _i11++) {
4465
- var _styleDecls$_i = _slicedToArray(styleDecls[_i11], 3),
4699
+ for (var _i14 = 0; _i14 < styleDecls.length; _i14++) {
4700
+ var _styleDecls$_i = _slicedToArray(styleDecls[_i14], 3),
4466
4701
  prop = _styleDecls$_i[0],
4467
4702
  value = _styleDecls$_i[1],
4468
4703
  important = _styleDecls$_i[2];
@@ -4818,15 +5053,13 @@
4818
5053
 
4819
5054
 
4820
5055
  function setScopeTokenClassIfNecessary(elm, owner, renderer) {
4821
- var cmpTemplate = owner.cmpTemplate,
4822
- context = owner.context;
4823
- var getClassList = renderer.getClassList;
4824
- var token = cmpTemplate === null || cmpTemplate === void 0 ? void 0 : cmpTemplate.stylesheetToken;
5056
+ var token = getScopeTokenClass(owner);
4825
5057
 
4826
- if (!isUndefined$1(token) && context.hasScopedStyles) {
4827
- // TODO [#2762]: this dot notation with add is probably problematic
5058
+ if (!isNull(token)) {
5059
+ var _getClassList = renderer.getClassList; // TODO [#2762]: this dot notation with add is probably problematic
4828
5060
  // probably we should have a renderer api for just the add operation
4829
- getClassList(elm).add(token);
5061
+
5062
+ _getClassList(elm).add(token);
4830
5063
  }
4831
5064
  }
4832
5065
 
@@ -5016,8 +5249,8 @@
5016
5249
  var oldSlots = vm.cmpSlots;
5017
5250
  var cmpSlots = vm.cmpSlots = create(null);
5018
5251
 
5019
- for (var _i12 = 0, len = children.length; _i12 < len; _i12 += 1) {
5020
- var vnode = children[_i12];
5252
+ for (var _i15 = 0, len = children.length; _i15 < len; _i15 += 1) {
5253
+ var vnode = children[_i15];
5021
5254
 
5022
5255
  if (isNull(vnode)) {
5023
5256
  continue;
@@ -5043,8 +5276,8 @@
5043
5276
  return;
5044
5277
  }
5045
5278
 
5046
- for (var _i13 = 0, _len4 = oldKeys.length; _i13 < _len4; _i13 += 1) {
5047
- var key = oldKeys[_i13];
5279
+ for (var _i16 = 0, _len4 = oldKeys.length; _i16 < _len4; _i16 += 1) {
5280
+ var key = oldKeys[_i16];
5048
5281
 
5049
5282
  if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
5050
5283
  markComponentAsDirty(vm);
@@ -5184,12 +5417,12 @@
5184
5417
  if (oldStartIdx > oldEndIdx) {
5185
5418
  // There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
5186
5419
  // already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
5187
- var _i14 = newEndIdx;
5420
+ var _i17 = newEndIdx;
5188
5421
  var n;
5189
5422
 
5190
5423
  do {
5191
- n = newCh[++_i14];
5192
- } while (!isVNode(n) && _i14 < newChEnd);
5424
+ n = newCh[++_i17];
5425
+ } while (!isVNode(n) && _i17 < newChEnd);
5193
5426
 
5194
5427
  before = isVNode(n) ? n.elm : null;
5195
5428
  mountVNodes(newCh, parent, renderer, before, newStartIdx, newEndIdx + 1);
@@ -5220,9 +5453,9 @@
5220
5453
 
5221
5454
  var anchor = null;
5222
5455
 
5223
- for (var _i15 = c2Length - 1; _i15 >= 0; _i15 -= 1) {
5224
- var n1 = c1[_i15];
5225
- var n2 = c2[_i15];
5456
+ for (var _i18 = c2Length - 1; _i18 >= 0; _i18 -= 1) {
5457
+ var n1 = c1[_i18];
5458
+ var n2 = c2[_i18];
5226
5459
 
5227
5460
  if (n2 !== n1) {
5228
5461
  if (isVNode(n1)) {
@@ -5768,229 +6001,6 @@
5768
6001
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
5769
6002
  */
5770
6003
 
5771
- function makeHostToken(token) {
5772
- return "".concat(token, "-host");
5773
- }
5774
-
5775
- function createInlineStyleVNode(content) {
5776
- return api.h('style', {
5777
- key: 'style',
5778
- attrs: {
5779
- type: 'text/css'
5780
- }
5781
- }, [api.t(content)]);
5782
- }
5783
-
5784
- function updateStylesheetToken(vm, template) {
5785
- var elm = vm.elm,
5786
- context = vm.context,
5787
- renderMode = vm.renderMode,
5788
- shadowMode = vm.shadowMode,
5789
- _vm$renderer = vm.renderer,
5790
- getClassList = _vm$renderer.getClassList,
5791
- removeAttribute = _vm$renderer.removeAttribute,
5792
- setAttribute = _vm$renderer.setAttribute;
5793
- var newStylesheets = template.stylesheets,
5794
- newStylesheetToken = template.stylesheetToken;
5795
- var isSyntheticShadow = renderMode === 1
5796
- /* RenderMode.Shadow */
5797
- && shadowMode === 1
5798
- /* ShadowMode.Synthetic */
5799
- ;
5800
- var hasScopedStyles = context.hasScopedStyles;
5801
- var newToken;
5802
- var newHasTokenInClass;
5803
- var newHasTokenInAttribute; // Reset the styling token applied to the host element.
5804
-
5805
- var oldToken = context.stylesheetToken,
5806
- oldHasTokenInClass = context.hasTokenInClass,
5807
- oldHasTokenInAttribute = context.hasTokenInAttribute;
5808
-
5809
- if (!isUndefined$1(oldToken)) {
5810
- if (oldHasTokenInClass) {
5811
- getClassList(elm).remove(makeHostToken(oldToken));
5812
- }
5813
-
5814
- if (oldHasTokenInAttribute) {
5815
- removeAttribute(elm, makeHostToken(oldToken));
5816
- }
5817
- } // Apply the new template styling token to the host element, if the new template has any
5818
- // associated stylesheets. In the case of light DOM, also ensure there is at least one scoped stylesheet.
5819
-
5820
-
5821
- if (!isUndefined$1(newStylesheets) && newStylesheets.length !== 0) {
5822
- newToken = newStylesheetToken;
5823
- } // Set the new styling token on the host element
5824
-
5825
-
5826
- if (!isUndefined$1(newToken)) {
5827
- if (hasScopedStyles) {
5828
- getClassList(elm).add(makeHostToken(newToken));
5829
- newHasTokenInClass = true;
5830
- }
5831
-
5832
- if (isSyntheticShadow) {
5833
- setAttribute(elm, makeHostToken(newToken), '');
5834
- newHasTokenInAttribute = true;
5835
- }
5836
- } // Update the styling tokens present on the context object.
5837
-
5838
-
5839
- context.stylesheetToken = newToken;
5840
- context.hasTokenInClass = newHasTokenInClass;
5841
- context.hasTokenInAttribute = newHasTokenInAttribute;
5842
- }
5843
-
5844
- function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
5845
- var content = [];
5846
- var root;
5847
-
5848
- for (var _i16 = 0; _i16 < stylesheets.length; _i16++) {
5849
- var stylesheet = stylesheets[_i16];
5850
-
5851
- if (isArray$1(stylesheet)) {
5852
- ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, stylesheetToken, vm));
5853
- } else {
5854
- if (process.env.NODE_ENV !== 'production') {
5855
- // Check for compiler version mismatch in dev mode only
5856
- checkVersionMismatch(stylesheet, 'stylesheet'); // in dev-mode, we support hot swapping of stylesheet, which means that
5857
- // the component instance might be attempting to use an old version of
5858
- // the stylesheet, while internally, we have a replacement for it.
5859
-
5860
- stylesheet = getStyleOrSwappedStyle(stylesheet);
5861
- }
5862
-
5863
- var isScopedCss = stylesheet[KEY__SCOPED_CSS]; // Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
5864
-
5865
- var scopeToken = isScopedCss || vm.shadowMode === 1
5866
- /* ShadowMode.Synthetic */
5867
- && vm.renderMode === 1
5868
- /* RenderMode.Shadow */
5869
- ? stylesheetToken : undefined; // Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
5870
- // native shadow DOM. Synthetic shadow DOM never uses `:host`.
5871
-
5872
- var useActualHostSelector = vm.renderMode === 0
5873
- /* RenderMode.Light */
5874
- ? !isScopedCss : vm.shadowMode === 0
5875
- /* ShadowMode.Native */
5876
- ; // Use the native :dir() pseudoclass only in native shadow DOM. Otherwise, in synthetic shadow,
5877
- // we use an attribute selector on the host to simulate :dir().
5878
-
5879
- var useNativeDirPseudoclass = void 0;
5880
-
5881
- if (vm.renderMode === 1
5882
- /* RenderMode.Shadow */
5883
- ) {
5884
- useNativeDirPseudoclass = vm.shadowMode === 0
5885
- /* ShadowMode.Native */
5886
- ;
5887
- } else {
5888
- // Light DOM components should only render `[dir]` if they're inside of a synthetic shadow root.
5889
- // At the top level (root is null) or inside of a native shadow root, they should use `:dir()`.
5890
- if (isUndefined$1(root)) {
5891
- // Only calculate the root once as necessary
5892
- root = getNearestShadowComponent(vm);
5893
- }
5894
-
5895
- useNativeDirPseudoclass = isNull(root) || root.shadowMode === 0
5896
- /* ShadowMode.Native */
5897
- ;
5898
- }
5899
-
5900
- ArrayPush$1.call(content, stylesheet(scopeToken, useActualHostSelector, useNativeDirPseudoclass));
5901
- }
5902
- }
5903
-
5904
- return content;
5905
- }
5906
-
5907
- function getStylesheetsContent(vm, template) {
5908
- var stylesheets = template.stylesheets,
5909
- stylesheetToken = template.stylesheetToken;
5910
- var content = [];
5911
-
5912
- if (!isUndefined$1(stylesheets) && stylesheets.length !== 0) {
5913
- content = evaluateStylesheetsContent(stylesheets, stylesheetToken, vm);
5914
- }
5915
-
5916
- return content;
5917
- } // It might be worth caching this to avoid doing the lookup repeatedly, but
5918
- // perf testing has not shown it to be a huge improvement yet:
5919
- // https://github.com/salesforce/lwc/pull/2460#discussion_r691208892
5920
-
5921
-
5922
- function getNearestShadowComponent(vm) {
5923
- var owner = vm;
5924
-
5925
- while (!isNull(owner)) {
5926
- if (owner.renderMode === 1
5927
- /* RenderMode.Shadow */
5928
- ) {
5929
- return owner;
5930
- }
5931
-
5932
- owner = owner.owner;
5933
- }
5934
-
5935
- return owner;
5936
- }
5937
-
5938
- function getNearestNativeShadowComponent(vm) {
5939
- var owner = getNearestShadowComponent(vm);
5940
-
5941
- if (!isNull(owner) && owner.shadowMode === 1
5942
- /* ShadowMode.Synthetic */
5943
- ) {
5944
- // Synthetic-within-native is impossible. So if the nearest shadow component is
5945
- // synthetic, we know we won't find a native component if we go any further.
5946
- return null;
5947
- }
5948
-
5949
- return owner;
5950
- }
5951
-
5952
- function createStylesheet(vm, stylesheets) {
5953
- var renderMode = vm.renderMode,
5954
- shadowMode = vm.shadowMode,
5955
- _vm$renderer2 = vm.renderer,
5956
- ssr = _vm$renderer2.ssr,
5957
- insertStylesheet = _vm$renderer2.insertStylesheet;
5958
-
5959
- if (renderMode === 1
5960
- /* RenderMode.Shadow */
5961
- && shadowMode === 1
5962
- /* ShadowMode.Synthetic */
5963
- ) {
5964
- for (var _i17 = 0; _i17 < stylesheets.length; _i17++) {
5965
- insertStylesheet(stylesheets[_i17]);
5966
- }
5967
- } else if (ssr || vm.hydrated) {
5968
- // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
5969
- // This works in the client, because the stylesheets are created, and cached in the VM
5970
- // the first time the VM renders.
5971
- // native shadow or light DOM, SSR
5972
- return ArrayMap.call(stylesheets, createInlineStyleVNode);
5973
- } else {
5974
- // native shadow or light DOM, DOM renderer
5975
- var root = getNearestNativeShadowComponent(vm); // null root means a global style
5976
-
5977
- var target = isNull(root) ? undefined : root.shadowRoot;
5978
-
5979
- for (var _i18 = 0; _i18 < stylesheets.length; _i18++) {
5980
- insertStylesheet(stylesheets[_i18], target);
5981
- }
5982
- }
5983
-
5984
- return null;
5985
- }
5986
- /*
5987
- * Copyright (c) 2018, salesforce.com, inc.
5988
- * All rights reserved.
5989
- * SPDX-License-Identifier: MIT
5990
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
5991
- */
5992
-
5993
-
5994
6004
  var operationIdNameMapping = ['constructor', 'render', 'patch', 'connectedCallback', 'renderedCallback', 'disconnectedCallback', 'errorCallback', 'lwc-hydrate', 'lwc-rehydrate']; // Even if all the browser the engine supports implements the UserTiming API, we need to guard the measure APIs.
5995
6005
  // JSDom (used in Jest) for example doesn't implement the UserTiming APIs.
5996
6006
 
@@ -7954,11 +7964,27 @@
7954
7964
  }
7955
7965
 
7956
7966
  function validateClassAttr(vnode, elm, renderer) {
7957
- var _vnode$data = vnode.data,
7958
- className = _vnode$data.className,
7959
- classMap = _vnode$data.classMap;
7967
+ var data = vnode.data,
7968
+ owner = vnode.owner;
7969
+ var className = data.className,
7970
+ classMap = data.classMap;
7960
7971
  var getProperty = renderer.getProperty,
7961
7972
  getClassList = renderer.getClassList;
7973
+ var scopedToken = getScopeTokenClass(owner); // Classnames for scoped CSS are added directly to the DOM during rendering,
7974
+ // or to the VDOM on the server in the case of SSR. As such, these classnames
7975
+ // are never present in VDOM nodes in the browser.
7976
+ //
7977
+ // Consequently, hydration mismatches will occur if scoped CSS token classnames
7978
+ // are rendered during SSR. This needs to be accounted for when validating.
7979
+
7980
+ if (scopedToken) {
7981
+ if (!isUndefined$1(className)) {
7982
+ className = "".concat(scopedToken, " ").concat(className);
7983
+ } else if (!isUndefined$1(classMap)) {
7984
+ classMap = Object.assign(Object.assign({}, classMap), _defineProperty({}, scopedToken, true));
7985
+ }
7986
+ }
7987
+
7962
7988
  var nodesAreCompatible = true;
7963
7989
  var vnodeClassName;
7964
7990
 
@@ -7996,9 +8022,9 @@
7996
8022
  }
7997
8023
 
7998
8024
  function validateStyleAttr(vnode, elm, renderer) {
7999
- var _vnode$data2 = vnode.data,
8000
- style = _vnode$data2.style,
8001
- styleDecls = _vnode$data2.styleDecls;
8025
+ var _vnode$data = vnode.data,
8026
+ style = _vnode$data.style,
8027
+ styleDecls = _vnode$data.styleDecls;
8002
8028
  var getAttribute = renderer.getAttribute;
8003
8029
  var elmStyle = getAttribute(elm, 'style') || '';
8004
8030
  var vnodeStyle;
@@ -8271,7 +8297,7 @@
8271
8297
 
8272
8298
  return ctor;
8273
8299
  }
8274
- /* version: 2.20.0 */
8300
+ /* version: 2.20.3 */
8275
8301
 
8276
8302
  /*
8277
8303
  * Copyright (c) 2018, salesforce.com, inc.
@@ -8306,10 +8332,6 @@
8306
8332
  };
8307
8333
  }
8308
8334
 
8309
- function isDocument(target) {
8310
- return !isUndefined$1(target.head);
8311
- }
8312
-
8313
8335
  function createFreshStyleElement(content) {
8314
8336
  var elm = document.createElement('style');
8315
8337
  elm.type = 'text/css';
@@ -8318,11 +8340,11 @@
8318
8340
  }
8319
8341
 
8320
8342
  function createStyleElement(content, cacheData) {
8321
- var stylesheet = cacheData.stylesheet,
8322
- used = cacheData.used; // If the <style> was already used, then we should clone it. We cannot insert
8343
+ var element = cacheData.element,
8344
+ usedElement = cacheData.usedElement; // If the <style> was already used, then we should clone it. We cannot insert
8323
8345
  // the same <style> in two places in the DOM.
8324
8346
 
8325
- if (used) {
8347
+ if (usedElement) {
8326
8348
  // For a mysterious reason, IE11 doesn't like the way we clone <style> nodes
8327
8349
  // and will render the incorrect styles if we do things that way. It's just
8328
8350
  // a perf optimization, so we can skip it for IE11.
@@ -8332,12 +8354,12 @@
8332
8354
  // faster to call `cloneNode()` on an existing node than to recreate it every time.
8333
8355
 
8334
8356
 
8335
- return stylesheet.cloneNode(true);
8357
+ return element.cloneNode(true);
8336
8358
  } // We don't clone every time, because that would be a perf tax on the first time
8337
8359
 
8338
8360
 
8339
- cacheData.used = true;
8340
- return stylesheet;
8361
+ cacheData.usedElement = true;
8362
+ return element;
8341
8363
  }
8342
8364
 
8343
8365
  function createConstructableStylesheet(content) {
@@ -8360,40 +8382,36 @@
8360
8382
 
8361
8383
  function insertStyleElement(content, target, cacheData) {
8362
8384
  var elm = createStyleElement(content, cacheData);
8363
- var targetAnchorPoint = isDocument(target) ? target.head : target;
8364
- targetAnchorPoint.appendChild(elm);
8365
- }
8366
-
8367
- function doInsertStylesheet(content, target, cacheData) {
8368
- // Constructable stylesheets are only supported in certain browsers:
8369
- // https://caniuse.com/mdn-api_document_adoptedstylesheets
8370
- // The reason we use it is for perf: https://github.com/salesforce/lwc/pull/2460
8371
- if (supportsConstructableStylesheets) {
8372
- insertConstructableStylesheet(content, target, cacheData);
8373
- } else {
8374
- // Fall back to <style> element
8375
- insertStyleElement(content, target, cacheData);
8376
- }
8385
+ target.appendChild(elm);
8377
8386
  }
8378
8387
 
8379
- function getCacheData(content) {
8388
+ function getCacheData(content, useConstructableStylesheet) {
8380
8389
  var cacheData = stylesheetCache.get(content);
8381
8390
 
8382
8391
  if (isUndefined$1(cacheData)) {
8383
8392
  cacheData = {
8384
- stylesheet: supportsConstructableStylesheets ? createConstructableStylesheet(content) : createFreshStyleElement(content),
8393
+ stylesheet: undefined,
8394
+ element: undefined,
8385
8395
  roots: undefined,
8386
8396
  global: false,
8387
- used: false
8397
+ usedElement: false
8388
8398
  };
8389
8399
  stylesheetCache.set(content, cacheData);
8400
+ } // Create <style> elements or CSSStyleSheets on-demand, as needed
8401
+
8402
+
8403
+ if (useConstructableStylesheet && isUndefined$1(cacheData.stylesheet)) {
8404
+ cacheData.stylesheet = createConstructableStylesheet(content);
8405
+ } else if (!useConstructableStylesheet && isUndefined$1(cacheData.element)) {
8406
+ cacheData.element = createFreshStyleElement(content);
8390
8407
  }
8391
8408
 
8392
8409
  return cacheData;
8393
8410
  }
8394
8411
 
8395
8412
  function insertGlobalStylesheet(content) {
8396
- var cacheData = getCacheData(content);
8413
+ // Force a <style> element for global stylesheets. See comment below.
8414
+ var cacheData = getCacheData(content, false);
8397
8415
 
8398
8416
  if (cacheData.global) {
8399
8417
  // already inserted
@@ -8401,12 +8419,13 @@
8401
8419
  }
8402
8420
 
8403
8421
  cacheData.global = true; // mark inserted
8422
+ // TODO [#2922]: use document.adoptedStyleSheets in supported browsers. Currently we can't, due to backwards compat.
8404
8423
 
8405
- doInsertStylesheet(content, document, cacheData);
8424
+ insertStyleElement(content, document.head, cacheData);
8406
8425
  }
8407
8426
 
8408
8427
  function insertLocalStylesheet(content, target) {
8409
- var cacheData = getCacheData(content);
8428
+ var cacheData = getCacheData(content, supportsConstructableStylesheets);
8410
8429
  var roots = cacheData.roots;
8411
8430
 
8412
8431
  if (isUndefined$1(roots)) {
@@ -8417,8 +8436,16 @@
8417
8436
  }
8418
8437
 
8419
8438
  roots.add(target); // mark inserted
8439
+ // Constructable stylesheets are only supported in certain browsers:
8440
+ // https://caniuse.com/mdn-api_document_adoptedstylesheets
8441
+ // The reason we use it is for perf: https://github.com/salesforce/lwc/pull/2460
8420
8442
 
8421
- doInsertStylesheet(content, target, cacheData);
8443
+ if (supportsConstructableStylesheets) {
8444
+ insertConstructableStylesheet(content, target, cacheData);
8445
+ } else {
8446
+ // Fall back to <style> element
8447
+ insertStyleElement(content, target, cacheData);
8448
+ }
8422
8449
  }
8423
8450
 
8424
8451
  function insertStylesheet(content, target) {
@@ -8567,7 +8594,15 @@
8567
8594
  }
8568
8595
 
8569
8596
  function attachShadow(element, options) {
8570
- if (hydrating) {
8597
+ // `hydrating` will be true in two cases:
8598
+ // 1. upon initial load with an SSR-generated DOM, while in Shadow render mode
8599
+ // 2. when a webapp author places <c-app> in their static HTML and mounts their
8600
+ // root component with customeElement.define('c-app', Ctor)
8601
+ //
8602
+ // The second case can be treated as a failed hydration with nominal impact
8603
+ // to performance. However, because <c-app> won't have a <template shadowroot>
8604
+ // declarative child, `element.shadowRoot` is `null`.
8605
+ if (hydrating && element.shadowRoot) {
8571
8606
  return element.shadowRoot;
8572
8607
  }
8573
8608
 
@@ -9091,7 +9126,7 @@
9091
9126
  });
9092
9127
  freeze(LightningElement);
9093
9128
  seal(LightningElement.prototype);
9094
- /* version: 2.20.0 */
9129
+ /* version: 2.20.3 */
9095
9130
 
9096
9131
  exports.LightningElement = LightningElement;
9097
9132
  exports.__unstable__ProfilerControl = profilerControl;