lwc 2.4.0 → 2.5.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 +117 -64
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +117 -64
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +2 -2
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +116 -63
  5. package/dist/engine-dom/iife/es5/engine-dom.js +133 -86
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +2 -2
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +130 -83
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +117 -64
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +2 -2
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +116 -63
  11. package/dist/engine-dom/umd/es5/engine-dom.js +133 -86
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +2 -2
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +130 -83
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +117 -64
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +2 -2
  16. package/dist/engine-server/esm/es2017/engine-server.js +117 -64
  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 +8 -8
@@ -252,6 +252,7 @@
252
252
  const KEY__SHADOW_RESOLVER = '$shadowResolver$';
253
253
  const KEY__SHADOW_TOKEN = '$shadowToken$';
254
254
  const KEY__SYNTHETIC_MODE = '$$lwc-synthetic-mode';
255
+ const KEY__SCOPED_CSS = '$scoped$';
255
256
  /**
256
257
  * Map composed of properties to attributes not following the HTML property to attribute mapping
257
258
  * convention.
@@ -300,7 +301,7 @@
300
301
  CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
301
302
  return attributeName;
302
303
  }
303
- /** version: 2.4.0 */
304
+ /** version: 2.5.0 */
304
305
 
305
306
  /*
306
307
  * Copyright (c) 2018, salesforce.com, inc.
@@ -471,7 +472,7 @@
471
472
 
472
473
  function setFeatureFlagForTest(name, value) {
473
474
  }
474
- /** version: 2.4.0 */
475
+ /** version: 2.5.0 */
475
476
 
476
477
  /* proxy-compat-disable */
477
478
 
@@ -3367,6 +3368,19 @@
3367
3368
 
3368
3369
  function setElementShadowToken(elm, token) {
3369
3370
  elm.$shadowToken$ = token;
3371
+ } // Set the scope token class for *.scoped.css styles
3372
+
3373
+
3374
+ function setScopeTokenClassIfNecessary(elm, owner) {
3375
+ const {
3376
+ cmpTemplate,
3377
+ context
3378
+ } = owner;
3379
+ const token = cmpTemplate === null || cmpTemplate === void 0 ? void 0 : cmpTemplate.stylesheetToken;
3380
+
3381
+ if (!isUndefined$1(token) && context.hasScopedStyles) {
3382
+ owner.renderer.getClassList(elm).add(token);
3383
+ }
3370
3384
  }
3371
3385
 
3372
3386
  function updateNodeHook(oldVnode, vnode) {
@@ -3417,6 +3431,7 @@
3417
3431
  const {
3418
3432
  owner
3419
3433
  } = vnode;
3434
+ setScopeTokenClassIfNecessary(elm, owner);
3420
3435
 
3421
3436
  if (owner.shadowMode === 1
3422
3437
  /* Synthetic */
@@ -3427,7 +3442,7 @@
3427
3442
  }
3428
3443
  } = vnode;
3429
3444
  const {
3430
- shadowAttribute
3445
+ stylesheetToken
3431
3446
  } = owner.context;
3432
3447
 
3433
3448
  if (!isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === "manual"
@@ -3439,7 +3454,7 @@
3439
3454
  // into each element from the template, so they can be styled accordingly.
3440
3455
 
3441
3456
 
3442
- setElementShadowToken(elm, shadowAttribute);
3457
+ setElementShadowToken(elm, stylesheetToken);
3443
3458
  }
3444
3459
  }
3445
3460
 
@@ -3510,16 +3525,17 @@
3510
3525
  ctor,
3511
3526
  owner
3512
3527
  } = vnode;
3528
+ setScopeTokenClassIfNecessary(elm, owner);
3513
3529
 
3514
3530
  if (owner.shadowMode === 1
3515
3531
  /* Synthetic */
3516
3532
  ) {
3517
3533
  const {
3518
- shadowAttribute
3534
+ stylesheetToken
3519
3535
  } = owner.context; // when running in synthetic shadow mode, we need to set the shadowToken value
3520
3536
  // into each element from the template, so they can be styled accordingly.
3521
3537
 
3522
- setElementShadowToken(elm, shadowAttribute);
3538
+ setElementShadowToken(elm, stylesheetToken);
3523
3539
  }
3524
3540
 
3525
3541
  const def = getComponentInternalDef(ctor);
@@ -4179,6 +4195,10 @@
4179
4195
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4180
4196
  */
4181
4197
 
4198
+ function makeHostToken(token) {
4199
+ return `${token}-host`;
4200
+ }
4201
+
4182
4202
  function createInlineStyleVNode(content) {
4183
4203
  return h('style', {
4184
4204
  key: 'style',
@@ -4188,53 +4208,94 @@
4188
4208
  }, [t(content)]);
4189
4209
  }
4190
4210
 
4191
- function updateSyntheticShadowAttributes(vm, template) {
4211
+ function updateStylesheetToken(vm, template) {
4192
4212
  const {
4193
4213
  elm,
4194
4214
  context,
4195
4215
  renderer,
4196
- renderMode
4216
+ renderMode,
4217
+ shadowMode
4197
4218
  } = vm;
4198
4219
  const {
4199
4220
  stylesheets: newStylesheets,
4200
- stylesheetTokens: newStylesheetTokens
4221
+ stylesheetToken: newStylesheetToken
4201
4222
  } = template;
4202
- let newTokens; // Reset the styling token applied to the host element.
4223
+ const isSyntheticShadow = renderMode === 1
4224
+ /* Shadow */
4225
+ && shadowMode === 1
4226
+ /* Synthetic */
4227
+ ;
4228
+ const {
4229
+ hasScopedStyles
4230
+ } = context;
4231
+ let newToken;
4232
+ let newHasTokenInClass;
4233
+ let newHasTokenInAttribute; // Reset the styling token applied to the host element.
4203
4234
 
4204
- const oldHostAttribute = context.hostAttribute;
4235
+ const {
4236
+ stylesheetToken: oldToken,
4237
+ hasTokenInClass: oldHasTokenInClass,
4238
+ hasTokenInAttribute: oldHasTokenInAttribute
4239
+ } = context;
4240
+
4241
+ if (oldHasTokenInClass) {
4242
+ renderer.getClassList(elm).remove(makeHostToken(oldToken));
4243
+ }
4205
4244
 
4206
- if (!isUndefined$1(oldHostAttribute)) {
4207
- renderer.removeAttribute(elm, oldHostAttribute);
4245
+ if (oldHasTokenInAttribute) {
4246
+ renderer.removeAttribute(elm, makeHostToken(oldToken));
4208
4247
  } // Apply the new template styling token to the host element, if the new template has any
4209
- // associated stylesheets.
4248
+ // associated stylesheets. In the case of light DOM, also ensure there is at least one scoped stylesheet.
4210
4249
 
4211
4250
 
4212
- if (!isUndefined$1(newStylesheets) && newStylesheets.length !== 0 && renderMode === 1
4213
- /* Shadow */
4214
- ) {
4215
- newTokens = newStylesheetTokens;
4216
- }
4251
+ if (!isUndefined$1(newStylesheets) && newStylesheets.length !== 0) {
4252
+ newToken = newStylesheetToken;
4253
+ } // Set the new styling token on the host element
4254
+
4217
4255
 
4218
- if (!isUndefined$1(newTokens)) {
4219
- renderer.setAttribute(elm, newTokens.hostAttribute, '');
4256
+ if (!isUndefined$1(newToken)) {
4257
+ if (hasScopedStyles) {
4258
+ renderer.getClassList(elm).add(makeHostToken(newToken));
4259
+ newHasTokenInClass = true;
4260
+ }
4261
+
4262
+ if (isSyntheticShadow) {
4263
+ renderer.setAttribute(elm, makeHostToken(newToken), '');
4264
+ newHasTokenInAttribute = true;
4265
+ }
4220
4266
  } // Update the styling tokens present on the context object.
4221
4267
 
4222
4268
 
4223
- context.hostAttribute = newTokens === null || newTokens === void 0 ? void 0 : newTokens.hostAttribute;
4224
- context.shadowAttribute = newTokens === null || newTokens === void 0 ? void 0 : newTokens.shadowAttribute;
4269
+ context.stylesheetToken = newToken;
4270
+ context.hasTokenInClass = newHasTokenInClass;
4271
+ context.hasTokenInAttribute = newHasTokenInAttribute;
4225
4272
  }
4226
4273
 
4227
- function evaluateStylesheetsContent(stylesheets, hostSelector, shadowSelector, nativeShadow) {
4274
+ function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
4228
4275
  const content = [];
4229
4276
 
4230
4277
  for (let i = 0; i < stylesheets.length; i++) {
4231
4278
  let stylesheet = stylesheets[i];
4232
4279
 
4233
4280
  if (isArray$1(stylesheet)) {
4234
- ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, hostSelector, shadowSelector, nativeShadow));
4281
+ ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, stylesheetToken, vm));
4235
4282
  } else {
4283
+ // native shadow DOM. Synthetic shadow DOM never uses `:host`.
4284
+
4236
4285
 
4237
- ArrayPush$1.call(content, stylesheet(hostSelector, shadowSelector, nativeShadow));
4286
+ const isScopedCss = stylesheet[KEY__SCOPED_CSS];
4287
+ const useActualHostSelector = vm.renderMode === 0
4288
+ /* Light */
4289
+ ? !isScopedCss : vm.shadowMode === 0
4290
+ /* Native */
4291
+ ; // Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
4292
+
4293
+ const scopeToken = isScopedCss || vm.shadowMode === 1
4294
+ /* Synthetic */
4295
+ && vm.renderMode === 1
4296
+ /* Shadow */
4297
+ ? stylesheetToken : undefined;
4298
+ ArrayPush$1.call(content, stylesheet(useActualHostSelector, scopeToken));
4238
4299
  }
4239
4300
  }
4240
4301
 
@@ -4244,34 +4305,12 @@
4244
4305
  function getStylesheetsContent(vm, template) {
4245
4306
  const {
4246
4307
  stylesheets,
4247
- stylesheetTokens
4308
+ stylesheetToken
4248
4309
  } = template;
4249
- const {
4250
- renderMode,
4251
- shadowMode
4252
- } = vm;
4253
4310
  let content = [];
4254
4311
 
4255
4312
  if (!isUndefined$1(stylesheets) && stylesheets.length !== 0) {
4256
- let hostSelector;
4257
- let shadowSelector; // Scoping with the tokens is only necessary for synthetic shadow. For both
4258
- // light DOM elements and native shadow, we just render the CSS as-is.
4259
-
4260
- if (renderMode === 1
4261
- /* Shadow */
4262
- && shadowMode === 1
4263
- /* Synthetic */
4264
- && !isUndefined$1(stylesheetTokens)) {
4265
- hostSelector = `[${stylesheetTokens.hostAttribute}]`;
4266
- shadowSelector = `[${stylesheetTokens.shadowAttribute}]`;
4267
- } else {
4268
- hostSelector = '';
4269
- shadowSelector = '';
4270
- }
4271
-
4272
- content = evaluateStylesheetsContent(stylesheets, hostSelector, shadowSelector, shadowMode === 0
4273
- /* Native */
4274
- );
4313
+ content = evaluateStylesheetsContent(stylesheets, stylesheetToken, vm);
4275
4314
  }
4276
4315
 
4277
4316
  return content;
@@ -4454,8 +4493,7 @@
4454
4493
  context,
4455
4494
  cmpSlots,
4456
4495
  cmpTemplate,
4457
- tro,
4458
- shadowMode
4496
+ tro
4459
4497
  } = vm;
4460
4498
  tro.observe(() => {
4461
4499
  // Reset the cache memoizer for template when needed.
@@ -4478,15 +4516,12 @@
4478
4516
 
4479
4517
  vm.cmpTemplate = html; // Create a brand new template cache for the swapped templated.
4480
4518
 
4481
- context.tplCache = create(null); // Update the synthetic shadow attributes on the host element if necessary.
4519
+ context.tplCache = create(null); // Set the computeHasScopedStyles property in the context, to avoid recomputing it repeatedly.
4482
4520
 
4483
- if (shadowMode === 1
4484
- /* Synthetic */
4485
- ) {
4486
- updateSyntheticShadowAttributes(vm, html);
4487
- } // Evaluate, create stylesheet and cache the produced VNode for future
4488
- // re-rendering.
4521
+ context.hasScopedStyles = computeHasScopedStyles(html); // Update the scoping token on the host element.
4489
4522
 
4523
+ updateStylesheetToken(vm, html); // Evaluate, create stylesheet and cache the produced VNode for future
4524
+ // re-rendering.
4490
4525
 
4491
4526
  const stylesheetsContent = getStylesheetsContent(vm, html);
4492
4527
  context.styleVNode = stylesheetsContent.length === 0 ? null : createStylesheet(vm, stylesheetsContent);
@@ -4519,6 +4554,22 @@
4519
4554
 
4520
4555
  return vnodes;
4521
4556
  }
4557
+
4558
+ function computeHasScopedStyles(template) {
4559
+ const {
4560
+ stylesheets
4561
+ } = template;
4562
+
4563
+ if (!isUndefined$1(stylesheets)) {
4564
+ for (let i = 0; i < stylesheets.length; i++) {
4565
+ if (isTrue(stylesheets[i][KEY__SCOPED_CSS])) {
4566
+ return true;
4567
+ }
4568
+ }
4569
+ }
4570
+
4571
+ return false;
4572
+ }
4522
4573
  /*
4523
4574
  * Copyright (c) 2018, salesforce.com, inc.
4524
4575
  * All rights reserved.
@@ -4887,8 +4938,10 @@
4887
4938
  renderMode: def.renderMode,
4888
4939
  shadowMode: null,
4889
4940
  context: {
4890
- hostAttribute: undefined,
4891
- shadowAttribute: undefined,
4941
+ stylesheetToken: undefined,
4942
+ hasTokenInClass: undefined,
4943
+ hasTokenInAttribute: undefined,
4944
+ hasScopedStyles: undefined,
4892
4945
  styleVNode: null,
4893
4946
  tplCache: EmptyObject,
4894
4947
  wiredConnecting: EmptyArray,
@@ -5778,7 +5831,7 @@
5778
5831
 
5779
5832
  return reactiveMembrane.getReadOnlyProxy(obj);
5780
5833
  }
5781
- /* version: 2.4.0 */
5834
+ /* version: 2.5.0 */
5782
5835
 
5783
5836
  /*
5784
5837
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6314,7 +6367,7 @@
6314
6367
  });
6315
6368
  freeze(LightningElement);
6316
6369
  seal(LightningElement.prototype);
6317
- /* version: 2.4.0 */
6370
+ /* version: 2.5.0 */
6318
6371
 
6319
6372
  exports.LightningElement = LightningElement;
6320
6373
  exports.__unstable__ProfilerControl = profilerControl;