lwc 2.5.3 → 2.5.4

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 +75 -71
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +75 -71
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +2 -2
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +64 -52
  5. package/dist/engine-dom/iife/es5/engine-dom.js +115 -90
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +2 -2
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +102 -69
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +75 -71
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +2 -2
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +64 -52
  11. package/dist/engine-dom/umd/es5/engine-dom.js +115 -90
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +2 -2
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +102 -69
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +57 -71
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +2 -2
  16. package/dist/engine-server/esm/es2017/engine-server.js +57 -71
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +75 -39
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +75 -39
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.min.js +2 -2
  20. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +74 -38
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +75 -39
  22. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.min.js +2 -2
  23. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +74 -38
  24. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +75 -39
  25. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.min.js +2 -2
  26. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +74 -38
  27. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +75 -39
  28. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.min.js +2 -2
  29. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +74 -38
  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 +2 -2
  34. package/dist/wire-service/iife/es5/wire-service.min.js +1 -1
  35. package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
  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 +2 -2
  39. package/dist/wire-service/umd/es5/wire-service.min.js +1 -1
  40. package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
  41. package/package.json +8 -8
@@ -117,7 +117,7 @@
117
117
  var KEY__SHADOW_TOKEN = '$shadowToken$';
118
118
  var KEY__SHADOW_TOKEN_PRIVATE = '$$ShadowTokenKey$$';
119
119
  var KEY__SYNTHETIC_MODE = '$$lwc-synthetic-mode';
120
- /** version: 2.5.3 */
120
+ /** version: 2.5.4 */
121
121
 
122
122
  /*
123
123
  * Copyright (c) 2018, salesforce.com, inc.
@@ -448,7 +448,7 @@
448
448
  }
449
449
 
450
450
  var runtimeFlags = _globalThis.lwcRuntimeFlags;
451
- /** version: 2.5.3 */
451
+ /** version: 2.5.4 */
452
452
 
453
453
  /*
454
454
  * Copyright (c) 2018, salesforce.com, inc.
@@ -922,6 +922,15 @@
922
922
  function isNodeShadowed(node) {
923
923
  return !isUndefined(getNodeOwnerKey(node));
924
924
  }
925
+ /**
926
+ * Returns true if this node is a shadow host, is in a shadow host, or contains a shadow host
927
+ * anywhere in its tree.
928
+ */
929
+
930
+
931
+ function isNodeOrDescendantsShadowed(node) {
932
+ return isNodeShadowed(node) || isSyntheticShadowHost(node) || containsHost(node);
933
+ }
925
934
  /*
926
935
  * Copyright (c) 2018, salesforce.com, inc.
927
936
  * All rights reserved.
@@ -1111,13 +1120,13 @@
1111
1120
  }
1112
1121
 
1113
1122
  function getFilteredChildNodes(node) {
1114
- if (!isHostElement(node) && !isSlotElement(node)) {
1123
+ if (!isSyntheticShadowHost(node) && !isSlotElement(node)) {
1115
1124
  // regular element - fast path
1116
1125
  var children = childNodesGetter.call(node);
1117
1126
  return arrayFromCollection(children);
1118
1127
  }
1119
1128
 
1120
- if (isHostElement(node)) {
1129
+ if (isSyntheticShadowHost(node)) {
1121
1130
  // we need to get only the nodes that were slotted
1122
1131
  var slots = arrayFromCollection(querySelectorAll$1.call(node, 'slot'));
1123
1132
  var resolver = getShadowRootResolver(getShadowRoot(node)); // Typescript is inferring the wrong function type for this particular
@@ -1529,7 +1538,7 @@
1529
1538
 
1530
1539
 
1531
1540
  function hasMountedChildren(node) {
1532
- return isSyntheticSlotElement(node) || isHostElement(node);
1541
+ return isSyntheticSlotElement(node) || isSyntheticShadowHost(node);
1533
1542
  }
1534
1543
 
1535
1544
  function getShadowParent(node, value) {
@@ -1650,9 +1659,9 @@
1650
1659
 
1651
1660
 
1652
1661
  function childNodesGetterPatched() {
1653
- if (isHostElement(this)) {
1662
+ if (isSyntheticShadowHost(this)) {
1654
1663
  var owner = getNodeOwner(this);
1655
- var childNodes = isNull(owner) ? [] : getAllMatches(owner, getFilteredChildNodes(this));
1664
+ var childNodes = isNull(owner) ? getFilteredChildNodes(this) : getAllMatches(owner, getFilteredChildNodes(this));
1656
1665
 
1657
1666
  return createStaticNodeList(childNodes);
1658
1667
  } // nothing to do here since this does not have a synthetic shadow attached to it
@@ -1753,7 +1762,8 @@
1753
1762
  textContent: {
1754
1763
  get: function get() {
1755
1764
  if (!runtimeFlags.ENABLE_NODE_PATCH) {
1756
- if (isNodeShadowed(this) || isHostElement(this)) {
1765
+ // See note on get innerHTML in faux-shadow/element.ts
1766
+ if (isNodeOrDescendantsShadowed(this)) {
1757
1767
  return textContentGetterPatched.call(this);
1758
1768
  }
1759
1769
 
@@ -1858,7 +1868,7 @@
1858
1868
  return false;
1859
1869
  }
1860
1870
 
1861
- if (isNodeShadowed(this) || isHostElement(this)) {
1871
+ if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
1862
1872
  return containsPatched.call(this, otherNode);
1863
1873
  }
1864
1874
 
@@ -1879,7 +1889,7 @@
1879
1889
  cloneNode: {
1880
1890
  value: function value(deep) {
1881
1891
  if (!runtimeFlags.ENABLE_NODE_PATCH) {
1882
- if (isNodeShadowed(this) || isHostElement(this)) {
1892
+ if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
1883
1893
  return cloneNodePatched.call(this, deep);
1884
1894
  }
1885
1895
 
@@ -1982,7 +1992,7 @@
1982
1992
  createDocumentFragment = _document.createDocumentFragment;
1983
1993
 
1984
1994
  function hasInternalSlot(root) {
1985
- return Boolean(InternalSlot.get(root));
1995
+ return InternalSlot.has(root);
1986
1996
  }
1987
1997
 
1988
1998
  function getInternalSlot(root) {
@@ -2034,14 +2044,36 @@
2034
2044
  // and we can avoid having to cast the type before calling this method in a few places.
2035
2045
 
2036
2046
 
2037
- function isHostElement(node) {
2038
- return !isUndefined(InternalSlot.get(node));
2047
+ function isSyntheticShadowHost(node) {
2048
+ var shadowRootRecord = InternalSlot.get(node);
2049
+ return !isUndefined(shadowRootRecord) && node === shadowRootRecord.host;
2050
+ }
2051
+
2052
+ function isSyntheticShadowRoot(node) {
2053
+ var shadowRootRecord = InternalSlot.get(node);
2054
+ return !isUndefined(shadowRootRecord) && node === shadowRootRecord.shadowRoot;
2055
+ } // Return true if any descendant is a host element
2056
+
2057
+
2058
+ function containsHost(node) {
2059
+ // IE requires all arguments
2060
+ // https://developer.mozilla.org/en-US/docs/Web/API/Document/createTreeWalker#browser_compatibility
2061
+ var walker = document.createTreeWalker(node, NodeFilter.SHOW_ELEMENT, null, false);
2062
+ var descendant;
2063
+
2064
+ while (!isNull(descendant = walker.nextNode())) {
2065
+ if (isSyntheticShadowHost(descendant)) {
2066
+ return true;
2067
+ }
2068
+ }
2069
+
2070
+ return false;
2039
2071
  }
2040
2072
 
2041
2073
  var uid = 0;
2042
2074
 
2043
2075
  function attachShadow(elm, options) {
2044
- if (!isUndefined(InternalSlot.get(elm))) {
2076
+ if (InternalSlot.has(elm)) {
2045
2077
  throw new Error("Failed to execute 'attachShadow' on 'Element': Shadow root cannot be created on a host which already hosts a shadow tree.");
2046
2078
  }
2047
2079
 
@@ -2545,7 +2577,7 @@
2545
2577
  } else {
2546
2578
  current = current.parentNode;
2547
2579
  }
2548
- } else if ((current instanceof SyntheticShadowRoot || isInstanceOfNativeShadowRoot(current)) && (composed || current !== startRoot)) {
2580
+ } else if ((isSyntheticShadowRoot(current) || isInstanceOfNativeShadowRoot(current)) && (composed || current !== startRoot)) {
2549
2581
  current = current.host;
2550
2582
  } else if (current instanceof _Node) {
2551
2583
  current = current.parentNode;
@@ -2607,7 +2639,7 @@
2607
2639
  lastRoot = root;
2608
2640
  }
2609
2641
 
2610
- if (!(root instanceof SyntheticShadowRoot) || !isUndefined(rootIdx) && rootIdx > -1) {
2642
+ if (!isSyntheticShadowRoot(root) || !isUndefined(rootIdx) && rootIdx > -1) {
2611
2643
  return ancestor;
2612
2644
  }
2613
2645
  }
@@ -3400,10 +3432,10 @@
3400
3432
  if (ArrayIndexOf.call(targetObservers, this) === -1) {
3401
3433
  ArrayPush.call(targetObservers, this);
3402
3434
  } // else There is more bookkeeping to do here https://dom.spec.whatwg.org/#dom-mutationobserver-observe Step #7
3403
- // If the target is a SyntheticShadowRoot, observe the host since the shadowRoot is an empty documentFragment
3435
+ // SyntheticShadowRoot instances are not actually a part of the DOM so observe the host instead.
3404
3436
 
3405
3437
 
3406
- if (target instanceof SyntheticShadowRoot) {
3438
+ if (isSyntheticShadowRoot(target)) {
3407
3439
  target = target.host;
3408
3440
  } // maintain a list of all nodes observed by this observer
3409
3441
 
@@ -3446,7 +3478,7 @@
3446
3478
  */
3447
3479
 
3448
3480
  function patchedAddEventListener$1(type, listener, optionsOrCapture) {
3449
- if (isHostElement(this)) {
3481
+ if (isSyntheticShadowHost(this)) {
3450
3482
  // Typescript does not like it when you treat the `arguments` object as an array
3451
3483
  // @ts-ignore type-mismatch
3452
3484
  return addCustomElementEventListener.apply(this, arguments);
@@ -3474,7 +3506,7 @@
3474
3506
  }
3475
3507
 
3476
3508
  function patchedRemoveEventListener$1(_type, _listener, _optionsOrCapture) {
3477
- if (isHostElement(this)) {
3509
+ if (isSyntheticShadowHost(this)) {
3478
3510
  // Typescript does not like it when you treat the `arguments` object as an array
3479
3511
  // @ts-ignore type-mismatch
3480
3512
  return removeCustomElementEventListener.apply(this, arguments);
@@ -3640,7 +3672,7 @@
3640
3672
  var actualCurrentTarget = originalCurrentTarget;
3641
3673
  var actualPath = composedPath; // Address the possibility that `currentTarget` is a shadow root
3642
3674
 
3643
- if (isHostElement(originalCurrentTarget)) {
3675
+ if (isSyntheticShadowHost(originalCurrentTarget)) {
3644
3676
  var context = eventToContextMap.get(this);
3645
3677
 
3646
3678
  if (context === 1
@@ -3651,7 +3683,7 @@
3651
3683
  } // Address the possibility that `target` is a shadow root
3652
3684
 
3653
3685
 
3654
- if (isHostElement(originalTarget) && eventToShadowRootMap.has(this)) {
3686
+ if (isSyntheticShadowHost(originalTarget) && eventToShadowRootMap.has(this)) {
3655
3687
  actualPath = pathComposer(getShadowRoot(originalTarget), this.composed);
3656
3688
  }
3657
3689
 
@@ -3688,7 +3720,7 @@
3688
3720
 
3689
3721
  var actualTarget = originalTarget;
3690
3722
 
3691
- if (isHostElement(originalTarget) && eventToShadowRootMap.has(this)) {
3723
+ if (isSyntheticShadowHost(originalTarget) && eventToShadowRootMap.has(this)) {
3692
3724
  actualTarget = getShadowRoot(originalTarget);
3693
3725
  }
3694
3726
 
@@ -3949,7 +3981,7 @@
3949
3981
  var ownerKey = getNodeOwnerKey(context); // a node inside a shadow.
3950
3982
 
3951
3983
  if (!isUndefined(ownerKey)) {
3952
- if (isHostElement(context)) {
3984
+ if (isSyntheticShadowHost(context)) {
3953
3985
  // element with shadowRoot attached
3954
3986
  var owner = getNodeOwner(context);
3955
3987
 
@@ -4014,7 +4046,7 @@
4014
4046
  }
4015
4047
 
4016
4048
  function shadowRootGetterPatched() {
4017
- if (isHostElement(this)) {
4049
+ if (isSyntheticShadowHost(this)) {
4018
4050
  var shadow = getShadowRoot(this);
4019
4051
 
4020
4052
  if (shadow.mode === 'open') {
@@ -4052,7 +4084,10 @@
4052
4084
  innerHTML: {
4053
4085
  get: function get() {
4054
4086
  if (!runtimeFlags.ENABLE_ELEMENT_PATCH) {
4055
- if (isNodeShadowed(this) || isHostElement(this)) {
4087
+ // If this element is in synthetic shadow, if it's a synthetic shadow host,
4088
+ // or if any of its descendants are synthetic shadow hosts, then we can't
4089
+ // use the native innerHTML because it would expose private node internals.
4090
+ if (isNodeOrDescendantsShadowed(this)) {
4056
4091
  return innerHTMLGetterPatched.call(this);
4057
4092
  }
4058
4093
 
@@ -4075,7 +4110,8 @@
4075
4110
  outerHTML: {
4076
4111
  get: function get() {
4077
4112
  if (!runtimeFlags.ENABLE_ELEMENT_PATCH) {
4078
- if (isNodeShadowed(this) || isHostElement(this)) {
4113
+ // See notes above on get innerHTML
4114
+ if (isNodeOrDescendantsShadowed(this)) {
4079
4115
  return outerHTMLGetterPatched.call(this);
4080
4116
  }
4081
4117
 
@@ -4176,7 +4212,7 @@
4176
4212
 
4177
4213
  var nodeList = arrayFromCollection(querySelectorAll$1.apply(this, ArraySlice.call(arguments)));
4178
4214
 
4179
- if (isHostElement(this)) {
4215
+ if (isSyntheticShadowHost(this)) {
4180
4216
  // element with shadowRoot attached
4181
4217
  var owner = getNodeOwner(this);
4182
4218
 
@@ -4236,7 +4272,7 @@
4236
4272
  function getFilteredArrayOfNodes(context, unfilteredNodes, shadowDomSemantic) {
4237
4273
  var filtered;
4238
4274
 
4239
- if (isHostElement(context)) {
4275
+ if (isSyntheticShadowHost(context)) {
4240
4276
  // element with shadowRoot attached
4241
4277
  var owner = getNodeOwner(context);
4242
4278
 
@@ -4435,7 +4471,7 @@
4435
4471
 
4436
4472
 
4437
4473
  function isTabbable(element) {
4438
- if (isHostElement(element) && isDelegatingFocus(element)) {
4474
+ if (isSyntheticShadowHost(element) && isDelegatingFocus(element)) {
4439
4475
  return false;
4440
4476
  }
4441
4477
 
@@ -5124,7 +5160,7 @@
5124
5160
  disableKeyboardFocusNavigationRoutines();
5125
5161
  }
5126
5162
 
5127
- if (isHostElement(this) && isDelegatingFocus(this)) {
5163
+ if (isSyntheticShadowHost(this) && isDelegatingFocus(this)) {
5128
5164
  hostElementFocus.call(this);
5129
5165
  return;
5130
5166
  } // Typescript does not like it when you treat the `arguments` object as an array
@@ -5143,14 +5179,14 @@
5143
5179
  defineProperties(HTMLElement.prototype, {
5144
5180
  tabIndex: {
5145
5181
  get: function get() {
5146
- if (isHostElement(this)) {
5182
+ if (isSyntheticShadowHost(this)) {
5147
5183
  return tabIndexGetterPatched.call(this);
5148
5184
  }
5149
5185
 
5150
5186
  return tabIndexGetter.call(this);
5151
5187
  },
5152
5188
  set: function set(v) {
5153
- if (isHostElement(this)) {
5189
+ if (isSyntheticShadowHost(this)) {
5154
5190
  return tabIndexSetterPatched.call(this, v);
5155
5191
  }
5156
5192
 
@@ -5161,7 +5197,7 @@
5161
5197
  },
5162
5198
  blur: {
5163
5199
  value: function value() {
5164
- if (isHostElement(this)) {
5200
+ if (isSyntheticShadowHost(this)) {
5165
5201
  return blurPatched.call(this);
5166
5202
  }
5167
5203
 
@@ -5191,7 +5227,7 @@
5191
5227
  }
5192
5228
 
5193
5229
  if (!runtimeFlags.ENABLE_ELEMENT_PATCH) {
5194
- if (isNodeShadowed(this) || isHostElement(this)) {
5230
+ if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
5195
5231
  return getInnerText(this);
5196
5232
  }
5197
5233
 
@@ -5225,7 +5261,7 @@
5225
5261
  }
5226
5262
 
5227
5263
  if (!runtimeFlags.ENABLE_ELEMENT_PATCH) {
5228
- if (isNodeShadowed(this) || isHostElement(this)) {
5264
+ if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
5229
5265
  return getInnerText(this);
5230
5266
  }
5231
5267
 
@@ -5326,7 +5362,7 @@
5326
5362
  if (node instanceof Element) {
5327
5363
  setShadowToken(node, shadowToken);
5328
5364
 
5329
- if (isHostElement(node)) {
5365
+ if (isSyntheticShadowHost(node)) {
5330
5366
  // Root LWC elements can't get content slotted into them, therefore we don't observe their children.
5331
5367
  return;
5332
5368
  }
@@ -5429,6 +5465,6 @@
5429
5465
  },
5430
5466
  configurable: true
5431
5467
  });
5432
- /** version: 2.5.3 */
5468
+ /** version: 2.5.4 */
5433
5469
 
5434
5470
  })();