lwc 2.8.0 → 2.9.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 +73 -34
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +73 -34
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +73 -34
  5. package/dist/engine-dom/iife/es5/engine-dom.js +144 -100
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +137 -94
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +73 -34
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +73 -34
  11. package/dist/engine-dom/umd/es5/engine-dom.js +144 -100
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +137 -94
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +41 -19
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +41 -19
  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
@@ -305,7 +305,7 @@
305
305
  const XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
306
306
  const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
307
307
  const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
308
- /** version: 2.8.0 */
308
+ /** version: 2.9.0 */
309
309
 
310
310
  /*
311
311
  * Copyright (c) 2018, salesforce.com, inc.
@@ -474,7 +474,7 @@
474
474
 
475
475
  function setFeatureFlagForTest(name, value) {
476
476
  }
477
- /** version: 2.8.0 */
477
+ /** version: 2.9.0 */
478
478
 
479
479
  /* proxy-compat-disable */
480
480
 
@@ -517,6 +517,19 @@
517
517
 
518
518
  return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
519
519
  } // Borrowed from Vue template compiler.
520
+
521
+
522
+ function cloneAndOmitKey(object, keyToOmit) {
523
+ const result = {};
524
+
525
+ for (const key of Object.keys(object)) {
526
+ if (key !== keyToOmit) {
527
+ result[key] = object[key];
528
+ }
529
+ }
530
+
531
+ return result;
532
+ } //
520
533
  // Primitives
521
534
  //
522
535
 
@@ -3634,11 +3647,13 @@
3634
3647
  ) {
3635
3648
  // this element will now accept any manual content inserted into it
3636
3649
  observeElementChildNodes(elm);
3637
- } // when running in synthetic shadow mode, we need to set the shadowToken value
3638
- // into each element from the template, so they can be styled accordingly.
3639
-
3650
+ }
3640
3651
 
3641
- setElementShadowToken(elm, stylesheetToken);
3652
+ if (!isUndefined$1(stylesheetToken)) {
3653
+ // when running in synthetic shadow mode, we need to set the shadowToken value
3654
+ // into each element from the template, so they can be styled accordingly.
3655
+ setElementShadowToken(elm, stylesheetToken);
3656
+ }
3642
3657
  }
3643
3658
  }
3644
3659
 
@@ -3707,7 +3722,9 @@
3707
3722
  } = owner.context; // when running in synthetic shadow mode, we need to set the shadowToken value
3708
3723
  // into each element from the template, so they can be styled accordingly.
3709
3724
 
3710
- setElementShadowToken(elm, stylesheetToken);
3725
+ if (!isUndefined$1(stylesheetToken)) {
3726
+ setElementShadowToken(elm, stylesheetToken);
3727
+ }
3711
3728
  }
3712
3729
 
3713
3730
  vm = createVM(elm, ctor, {
@@ -3884,6 +3901,7 @@
3884
3901
  let idxInOld;
3885
3902
  let elmToMove;
3886
3903
  let before;
3904
+ let clonedOldCh = false;
3887
3905
 
3888
3906
  while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
3889
3907
  if (!isVNode(oldStartVnode)) {
@@ -3935,7 +3953,18 @@
3935
3953
  newStartVnode.hook.create(newStartVnode);
3936
3954
  newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
3937
3955
  } else {
3938
- patchVnode(elmToMove, newStartVnode);
3956
+ patchVnode(elmToMove, newStartVnode); // Delete the old child, but copy the array since it is read-only.
3957
+ // The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
3958
+ // so we only care about the `oldCh` object inside this function.
3959
+ // To avoid cloning over and over again, we check `clonedOldCh`
3960
+ // and only clone once.
3961
+
3962
+ if (!clonedOldCh) {
3963
+ clonedOldCh = true;
3964
+ oldCh = [...oldCh];
3965
+ } // We've already cloned at least once, so it's no longer read-only
3966
+
3967
+
3939
3968
  oldCh[idxInOld] = undefined;
3940
3969
  newStartVnode.hook.move(elmToMove, parentElm, oldStartVnode.elm);
3941
3970
  }
@@ -4032,7 +4061,7 @@
4032
4061
  } // [h]tml node
4033
4062
 
4034
4063
 
4035
- function h(sel, data, children) {
4064
+ function h(sel, data, children = EmptyArray) {
4036
4065
  const vmBeingRendered = getVMBeingRendered();
4037
4066
 
4038
4067
  let elm;
@@ -4314,7 +4343,7 @@
4314
4343
  * create a dynamic component via `<x-foo lwc:dynamic={Ctor}>`
4315
4344
  */
4316
4345
 
4317
- function dc(sel, Ctor, data, children) {
4346
+ function dc(sel, Ctor, data, children = EmptyArray) {
4318
4347
 
4319
4348
 
4320
4349
  if (Ctor == null) {
@@ -4333,10 +4362,14 @@
4333
4362
  } // the new vnode key is a mix of idx and compiler key, this is required by the diffing algo
4334
4363
  // to identify different constructors as vnodes with different keys to avoid reusing the
4335
4364
  // element used for previous constructors.
4365
+ // Shallow clone is necessary here becuase VElementData may be shared across VNodes due to
4366
+ // hoisting optimization.
4336
4367
 
4337
4368
 
4338
- data.key = `dc:${idx}:${data.key}`;
4339
- return c(sel, Ctor, data, children);
4369
+ const newData = Object.assign(Object.assign({}, data), {
4370
+ key: `dc:${idx}:${data.key}`
4371
+ });
4372
+ return c(sel, Ctor, newData, children);
4340
4373
  }
4341
4374
  /**
4342
4375
  * slow children collection marking mechanism. this API allows the compiler to signal
@@ -4453,12 +4486,14 @@
4453
4486
  hasTokenInAttribute: oldHasTokenInAttribute
4454
4487
  } = context;
4455
4488
 
4456
- if (oldHasTokenInClass) {
4457
- getClassList$1(elm).remove(makeHostToken(oldToken));
4458
- }
4489
+ if (!isUndefined$1(oldToken)) {
4490
+ if (oldHasTokenInClass) {
4491
+ getClassList$1(elm).remove(makeHostToken(oldToken));
4492
+ }
4459
4493
 
4460
- if (oldHasTokenInAttribute) {
4461
- removeAttribute$1(elm, makeHostToken(oldToken));
4494
+ if (oldHasTokenInAttribute) {
4495
+ removeAttribute$1(elm, makeHostToken(oldToken));
4496
+ }
4462
4497
  } // Apply the new template styling token to the host element, if the new template has any
4463
4498
  // associated stylesheets. In the case of light DOM, also ensure there is at least one scoped stylesheet.
4464
4499
 
@@ -5108,7 +5143,10 @@
5108
5143
 
5109
5144
  if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
5110
5145
  if (elm.innerHTML === props.innerHTML) {
5111
- delete props.innerHTML;
5146
+ // Do a shallow clone since VNodeData may be shared across VNodes due to hoist optimization
5147
+ vnode.data = Object.assign(Object.assign({}, vnode.data), {
5148
+ props: cloneAndOmitKey(props, 'innerHTML')
5149
+ });
5112
5150
  } else {
5113
5151
  logWarn(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: innerHTML values do not match for element, will recover from the difference`, vnode.owner);
5114
5152
  }
@@ -6174,7 +6212,7 @@
6174
6212
  hooksAreSet = true;
6175
6213
  setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
6176
6214
  }
6177
- /* version: 2.8.0 */
6215
+ /* version: 2.9.0 */
6178
6216
 
6179
6217
  /*
6180
6218
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6771,30 +6809,31 @@
6771
6809
 
6772
6810
  const _Node = Node;
6773
6811
  /**
6774
- * EXPERIMENTAL: This function detects whether or not a Node is controlled by a LWC template. This
6775
- * API is subject to change or being removed.
6812
+ * EXPERIMENTAL: The purpose of this function is to detect shadowed nodes. THIS API WILL BE REMOVED
6813
+ * ONCE LOCKER V1 IS NO LONGER SUPPORTED.
6776
6814
  */
6777
6815
 
6778
- function isNodeFromTemplate(node) {
6816
+ function isNodeShadowed(node) {
6779
6817
  if (isFalse(node instanceof _Node)) {
6780
6818
  return false;
6781
- } // TODO [#1250]: skipping the shadowRoot instances itself makes no sense, we need to revisit
6782
- // this with locker
6819
+ } // It's debatable whether shadow root instances should be considered as shadowed, but we keep
6820
+ // this unchanged for legacy reasons (#1250).
6783
6821
 
6784
6822
 
6785
6823
  if (node instanceof ShadowRoot) {
6786
6824
  return false;
6787
6825
  }
6788
6826
 
6789
- if (isSyntheticShadowDefined) {
6790
- // TODO [#1252]: old behavior that is still used by some pieces of the platform,
6791
- // specifically, nodes inserted manually on places where `lwc:dom="manual"` directive is not
6792
- // used, will be considered global elements.
6793
- return !isUndefined$1(node[KEY__SHADOW_RESOLVER]);
6794
- }
6827
+ const rootNode = node.getRootNode(); // Handle the native case. We can return early here because an invariant of LWC is that
6828
+ // synthetic roots cannot be descendants of native roots.
6829
+
6830
+ if (rootNode instanceof ShadowRoot && isFalse(hasOwnProperty$1.call(getPrototypeOf$1(rootNode), 'synthetic'))) {
6831
+ return true;
6832
+ } // TODO [#1252]: Old behavior that is still used by some pieces of the platform. Manually
6833
+ // inserted nodes without the `lwc:dom=manual` directive will be considered as global elements.
6834
+
6795
6835
 
6796
- const root = node.getRootNode();
6797
- return root instanceof ShadowRoot;
6836
+ return isSyntheticShadowDefined && !isUndefined$1(node[KEY__SHADOW_RESOLVER]);
6798
6837
  }
6799
6838
  /*
6800
6839
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6839,7 +6878,7 @@
6839
6878
  });
6840
6879
  freeze(LightningElement);
6841
6880
  seal(LightningElement.prototype);
6842
- /* version: 2.8.0 */
6881
+ /* version: 2.9.0 */
6843
6882
 
6844
6883
  exports.LightningElement = LightningElement;
6845
6884
  exports.__unstable__ProfilerControl = profilerControl;
@@ -6851,7 +6890,7 @@
6851
6890
  exports.getComponentDef = getComponentDef;
6852
6891
  exports.hydrateComponent = hydrateComponent;
6853
6892
  exports.isComponentConstructor = isComponentConstructor;
6854
- exports.isNodeFromTemplate = isNodeFromTemplate;
6893
+ exports.isNodeFromTemplate = isNodeShadowed;
6855
6894
  exports.readonly = readonly;
6856
6895
  exports.register = register;
6857
6896
  exports.registerComponent = registerComponent;