lwc 2.23.1 → 2.23.2

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 +1182 -856
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +1182 -855
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +1101 -803
  5. package/dist/engine-dom/iife/es5/engine-dom.js +449 -368
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +409 -335
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +1182 -855
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +1101 -803
  11. package/dist/engine-dom/umd/es5/engine-dom.js +449 -368
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +409 -335
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +782 -521
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +782 -521
  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
@@ -365,9 +365,9 @@ var LWC = (function (exports) {
365
365
  // Increment whenever the LWC template compiler changes
366
366
 
367
367
 
368
- var LWC_VERSION = "2.23.1";
368
+ var LWC_VERSION = "2.23.2";
369
369
  var LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
370
- /** version: 2.23.1 */
370
+ /** version: 2.23.2 */
371
371
 
372
372
  /**
373
373
  * Copyright (C) 2018 salesforce.com, inc.
@@ -461,7 +461,7 @@ var LWC = (function (exports) {
461
461
  patch$1(propName);
462
462
  }
463
463
  }
464
- /** version: 2.23.1 */
464
+ /** version: 2.23.2 */
465
465
 
466
466
  /**
467
467
  * Copyright (C) 2018 salesforce.com, inc.
@@ -483,6 +483,7 @@ var LWC = (function (exports) {
483
483
  ENABLE_HTML_COLLECTIONS_PATCH: null,
484
484
  ENABLE_INNER_OUTER_TEXT_PATCH: null,
485
485
  ENABLE_MIXED_SHADOW_MODE: null,
486
+ ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE: null,
486
487
  ENABLE_NODE_LIST_PATCH: null,
487
488
  ENABLE_NODE_PATCH: null,
488
489
  ENABLE_REACTIVE_SETTER: null,
@@ -552,7 +553,7 @@ var LWC = (function (exports) {
552
553
  setFeatureFlag(name, value);
553
554
  }
554
555
  }
555
- /** version: 2.23.1 */
556
+ /** version: 2.23.2 */
556
557
 
557
558
  /*
558
559
  * Copyright (c) 2018, salesforce.com, inc.
@@ -994,8 +995,8 @@ var LWC = (function (exports) {
994
995
  // to inject at runtime.
995
996
 
996
997
 
997
- var HTMLElementConstructor$1 = typeof HTMLElement !== 'undefined' ? HTMLElement : function () {};
998
- var HTMLElementPrototype = HTMLElementConstructor$1.prototype;
998
+ var HTMLElementConstructor = typeof HTMLElement !== 'undefined' ? HTMLElement : function () {};
999
+ var HTMLElementPrototype = HTMLElementConstructor.prototype;
999
1000
  /*
1000
1001
  * Copyright (c) 2018, salesforce.com, inc.
1001
1002
  * All rights reserved.
@@ -1215,10 +1216,10 @@ var LWC = (function (exports) {
1215
1216
  }; // Apply extra restriction related to DOM manipulation if the element is not a portal.
1216
1217
 
1217
1218
  if (!options.isLight && !options.isPortal) {
1218
- var _appendChild = elm.appendChild,
1219
- _insertBefore = elm.insertBefore,
1220
- _removeChild = elm.removeChild,
1221
- _replaceChild = elm.replaceChild;
1219
+ var appendChild = elm.appendChild,
1220
+ insertBefore = elm.insertBefore,
1221
+ removeChild = elm.removeChild,
1222
+ replaceChild = elm.replaceChild;
1222
1223
  var originalNodeValueDescriptor = getPropertyDescriptor(elm, 'nodeValue');
1223
1224
  var originalInnerHTMLDescriptor = getPropertyDescriptor(elm, 'innerHTML');
1224
1225
  var originalTextContentDescriptor = getPropertyDescriptor(elm, 'textContent');
@@ -1226,7 +1227,7 @@ var LWC = (function (exports) {
1226
1227
  appendChild: generateDataDescriptor({
1227
1228
  value: function value(aChild) {
1228
1229
  logMissingPortalError('appendChild', 'method');
1229
- return _appendChild.call(this, aChild);
1230
+ return appendChild.call(this, aChild);
1230
1231
  }
1231
1232
  }),
1232
1233
  insertBefore: generateDataDescriptor({
@@ -1235,7 +1236,7 @@ var LWC = (function (exports) {
1235
1236
  logMissingPortalError('insertBefore', 'method');
1236
1237
  }
1237
1238
 
1238
- return _insertBefore.call(this, newNode, referenceNode);
1239
+ return insertBefore.call(this, newNode, referenceNode);
1239
1240
  }
1240
1241
  }),
1241
1242
  removeChild: generateDataDescriptor({
@@ -1244,13 +1245,13 @@ var LWC = (function (exports) {
1244
1245
  logMissingPortalError('removeChild', 'method');
1245
1246
  }
1246
1247
 
1247
- return _removeChild.call(this, aChild);
1248
+ return removeChild.call(this, aChild);
1248
1249
  }
1249
1250
  }),
1250
1251
  replaceChild: generateDataDescriptor({
1251
1252
  value: function value(newChild, oldChild) {
1252
1253
  logMissingPortalError('replaceChild', 'method');
1253
- return _replaceChild.call(this, newChild, oldChild);
1254
+ return replaceChild.call(this, newChild, oldChild);
1254
1255
  }
1255
1256
  }),
1256
1257
  nodeValue: generateAccessorDescriptor({
@@ -2411,9 +2412,8 @@ var LWC = (function (exports) {
2411
2412
  var bridge = def.bridge;
2412
2413
 
2413
2414
  if (process.env.NODE_ENV !== 'production') {
2414
- var _assertInstanceOfHTMLElement = vm.renderer.assertInstanceOfHTMLElement;
2415
-
2416
- _assertInstanceOfHTMLElement(vm.elm, "Component creation requires a DOM element to be associated to ".concat(vm, "."));
2415
+ var assertInstanceOfHTMLElement = vm.renderer.assertInstanceOfHTMLElement;
2416
+ assertInstanceOfHTMLElement(vm.elm, "Component creation requires a DOM element to be associated to ".concat(vm, "."));
2417
2417
  }
2418
2418
 
2419
2419
  var component = this;
@@ -3590,7 +3590,7 @@ var LWC = (function (exports) {
3590
3590
  return HTMLBridgeElement;
3591
3591
  }
3592
3592
 
3593
- var BaseBridgeElement = HTMLBridgeElementFactory(HTMLElementConstructor$1, getOwnPropertyNames$1(HTMLElementOriginalDescriptors), []);
3593
+ var BaseBridgeElement = HTMLBridgeElementFactory(HTMLElementConstructor, getOwnPropertyNames$1(HTMLElementOriginalDescriptors), []);
3594
3594
  freeze(BaseBridgeElement);
3595
3595
  seal(BaseBridgeElement.prototype);
3596
3596
  /*
@@ -4385,6 +4385,18 @@ var LWC = (function (exports) {
4385
4385
  */
4386
4386
 
4387
4387
 
4388
+ function checkHasVM(elm) {
4389
+ var hasVM = !isUndefined$1(getAssociatedVMIfPresent(elm));
4390
+
4391
+ if (process.env.NODE_ENV !== 'production' && !hasVM) {
4392
+ // Occurs when an element is manually created with the same tag name as an existing LWC component. In that case,
4393
+ // we skip calling the LWC connectedCallback/disconnectedCallback logic and log an error.
4394
+ logError("VM for tag name \"".concat(elm.tagName.toLowerCase(), "\" is undefined. ") + "This indicates that an element was created with this tag name, " + "which is already reserved by an LWC component. Use lwc.createElement " + "instead to create elements.");
4395
+ }
4396
+
4397
+ return hasVM;
4398
+ }
4399
+
4388
4400
  function getUpgradableConstructor(tagName, renderer) {
4389
4401
  var getCustomElement = renderer.getCustomElement,
4390
4402
  RendererHTMLElement = renderer.HTMLElementExported,
@@ -4426,6 +4438,20 @@ var LWC = (function (exports) {
4426
4438
  return _createClass(LWCUpgradableElement);
4427
4439
  }(RendererHTMLElement);
4428
4440
 
4441
+ if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
4442
+ CE.prototype.connectedCallback = function () {
4443
+ if (checkHasVM(this)) {
4444
+ connectRootElement(this);
4445
+ }
4446
+ };
4447
+
4448
+ CE.prototype.disconnectedCallback = function () {
4449
+ if (checkHasVM(this)) {
4450
+ disconnectRootElement(this);
4451
+ }
4452
+ };
4453
+ }
4454
+
4429
4455
  defineCustomElement(tagName, CE);
4430
4456
  return CE;
4431
4457
  }
@@ -4537,6 +4563,15 @@ var LWC = (function (exports) {
4537
4563
  // different than the one previously set.
4538
4564
 
4539
4565
  if (isFirstPatch || cur !== (isLiveBindingProp(sel, key) ? getProperty(elm, key) : oldProps[key])) {
4566
+ // Additional verification if properties are supported by the element
4567
+ // Validation relies on html properties and public properties being defined on the element,
4568
+ // SSR has its own custom validation.
4569
+ if (process.env.NODE_ENV !== 'production') {
4570
+ if (!(key in elm)) {
4571
+ logWarn("Unknown public property \"".concat(key, "\" of element <").concat(elm.tagName.toLowerCase(), ">. This is either a typo on the corresponding attribute \"").concat(htmlPropertyToAttribute(key), "\", or the attribute does not exist in this browser or DOM implementation."));
4572
+ }
4573
+ }
4574
+
4540
4575
  setProperty(elm, key, cur);
4541
4576
  }
4542
4577
  }
@@ -4949,13 +4984,19 @@ var LWC = (function (exports) {
4949
4984
  insertNode(elm, parent, anchor, renderer);
4950
4985
 
4951
4986
  if (vm) {
4952
- if (process.env.NODE_ENV !== 'production') {
4953
- assert.isTrue(vm.state === 0
4954
- /* VMState.created */
4955
- , "".concat(vm, " cannot be recycled."));
4956
- }
4987
+ {
4988
+ if (!lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
4989
+ if (process.env.NODE_ENV !== 'production') {
4990
+ // With synthetic lifecycle callbacks, it's possible for elements to be removed without the engine
4991
+ // noticing it (e.g. `appendChild` the same host element twice). This test ensures we don't regress.
4992
+ assert.isTrue(vm.state === 0
4993
+ /* VMState.created */
4994
+ , "".concat(vm, " cannot be recycled."));
4995
+ }
4957
4996
 
4958
- runConnectedCallback(vm);
4997
+ runConnectedCallback(vm);
4998
+ }
4999
+ }
4959
5000
  }
4960
5001
 
4961
5002
  mountVNodes(vnode.children, elm, renderer, null);
@@ -5145,10 +5186,10 @@ var LWC = (function (exports) {
5145
5186
  var scopeToken = getScopeTokenClass(owner);
5146
5187
 
5147
5188
  if (!isNull(scopeToken)) {
5148
- var _getClassList = renderer.getClassList; // TODO [#2762]: this dot notation with add is probably problematic
5189
+ var getClassList = renderer.getClassList; // TODO [#2762]: this dot notation with add is probably problematic
5149
5190
  // probably we should have a renderer api for just the add operation
5150
5191
 
5151
- _getClassList(elm).add(scopeToken);
5192
+ getClassList(elm).add(scopeToken);
5152
5193
  } // Set property element for synthetic shadow DOM style scoping.
5153
5194
 
5154
5195
 
@@ -7663,6 +7704,8 @@ var LWC = (function (exports) {
7663
7704
  return renderer.nextSibling(hydratedNode);
7664
7705
  }
7665
7706
 
7707
+ var NODE_VALUE_PROP = 'nodeValue';
7708
+
7666
7709
  function hydrateText(node, vnode, renderer) {
7667
7710
  var _a;
7668
7711
 
@@ -7673,9 +7716,8 @@ var LWC = (function (exports) {
7673
7716
  }
7674
7717
 
7675
7718
  if (process.env.NODE_ENV !== 'production') {
7676
- var _getProperty = renderer.getProperty;
7677
-
7678
- var nodeValue = _getProperty(node, 'nodeValue');
7719
+ var getProperty = renderer.getProperty;
7720
+ var nodeValue = getProperty(node, NODE_VALUE_PROP);
7679
7721
 
7680
7722
  if (nodeValue !== vnode.text && !(nodeValue === "\u200D" && vnode.text === '')) {
7681
7723
  logWarn('Hydration mismatch: text values do not match, will recover from the difference', vnode.owner);
@@ -7698,9 +7740,8 @@ var LWC = (function (exports) {
7698
7740
  }
7699
7741
 
7700
7742
  if (process.env.NODE_ENV !== 'production') {
7701
- var _getProperty2 = renderer.getProperty;
7702
-
7703
- var nodeValue = _getProperty2(node, 'nodeValue');
7743
+ var getProperty = renderer.getProperty;
7744
+ var nodeValue = getProperty(node, NODE_VALUE_PROP);
7704
7745
 
7705
7746
  if (nodeValue !== vnode.text) {
7706
7747
  logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vnode.owner);
@@ -7708,7 +7749,7 @@ var LWC = (function (exports) {
7708
7749
  }
7709
7750
 
7710
7751
  var setProperty = renderer.setProperty;
7711
- setProperty(node, 'nodeValue', (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
7752
+ setProperty(node, NODE_VALUE_PROP, (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
7712
7753
  vnode.elm = node;
7713
7754
  return node;
7714
7755
  }
@@ -7740,17 +7781,17 @@ var LWC = (function (exports) {
7740
7781
  // it may be that this element has lwc:inner-html, we need to diff and in case are the same,
7741
7782
  // remove the innerHTML from props so it reuses the existing dom elements.
7742
7783
  var props = vnode.data.props;
7743
- var _getProperty3 = renderer.getProperty;
7784
+ var getProperty = renderer.getProperty;
7744
7785
 
7745
7786
  if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
7746
- if (_getProperty3(elm, 'innerHTML') === props.innerHTML) {
7787
+ if (getProperty(elm, 'innerHTML') === props.innerHTML) {
7747
7788
  // Do a shallow clone since VNodeData may be shared across VNodes due to hoist optimization
7748
7789
  vnode.data = Object.assign(Object.assign({}, vnode.data), {
7749
7790
  props: cloneAndOmitKey(props, 'innerHTML')
7750
7791
  });
7751
7792
  } else {
7752
7793
  if (process.env.NODE_ENV !== 'production') {
7753
- logWarn("Mismatch hydrating element <".concat(_getProperty3(elm, 'tagName').toLowerCase(), ">: innerHTML values do not match for element, will recover from the difference"), owner);
7794
+ logWarn("Mismatch hydrating element <".concat(getProperty(elm, 'tagName').toLowerCase(), ">: innerHTML values do not match for element, will recover from the difference"), owner);
7754
7795
  }
7755
7796
  }
7756
7797
  }
@@ -7759,8 +7800,8 @@ var LWC = (function (exports) {
7759
7800
  patchElementPropsAndAttrs(vnode, renderer);
7760
7801
 
7761
7802
  if (!isDomManual) {
7762
- var _getFirstChild = renderer.getFirstChild;
7763
- hydrateChildren(_getFirstChild(elm), vnode.children, elm, owner);
7803
+ var getFirstChild = renderer.getFirstChild;
7804
+ hydrateChildren(getFirstChild(elm), vnode.children, elm, owner);
7764
7805
  }
7765
7806
 
7766
7807
  return elm;
@@ -7799,10 +7840,10 @@ var LWC = (function (exports) {
7799
7840
  if (vm.renderMode !== 0
7800
7841
  /* RenderMode.Light */
7801
7842
  ) {
7802
- var _getFirstChild2 = renderer.getFirstChild; // VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
7843
+ var getFirstChild = renderer.getFirstChild; // VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
7803
7844
  // Note: for Light DOM, this is handled while hydrating the VM
7804
7845
 
7805
- hydrateChildren(_getFirstChild2(elm), vnode.children, elm, vm);
7846
+ hydrateChildren(getFirstChild(elm), vnode.children, elm, vm);
7806
7847
  }
7807
7848
 
7808
7849
  hydrateVM(vm);
@@ -7851,11 +7892,11 @@ var LWC = (function (exports) {
7851
7892
  // next node in the list to be hydrated.
7852
7893
 
7853
7894
 
7854
- var _nextSibling = renderer.nextSibling;
7895
+ var nextSibling = renderer.nextSibling;
7855
7896
 
7856
7897
  do {
7857
7898
  var current = nextNode;
7858
- nextNode = _nextSibling(nextNode);
7899
+ nextNode = nextSibling(nextNode);
7859
7900
  removeNode(current, parentNode, renderer);
7860
7901
  } while (nextNode);
7861
7902
  }
@@ -7918,14 +7959,13 @@ var LWC = (function (exports) {
7918
7959
  attrValue = _Object$entries$_i[1];
7919
7960
 
7920
7961
  var owner = vnode.owner;
7921
- var _getAttribute = renderer.getAttribute;
7922
-
7923
- var elmAttrValue = _getAttribute(elm, attrName);
7962
+ var getAttribute = renderer.getAttribute;
7963
+ var elmAttrValue = getAttribute(elm, attrName);
7924
7964
 
7925
7965
  if (String(attrValue) !== elmAttrValue) {
7926
7966
  if (process.env.NODE_ENV !== 'production') {
7927
- var _getProperty4 = renderer.getProperty;
7928
- logError("Mismatch hydrating element <".concat(_getProperty4(elm, 'tagName').toLowerCase(), ">: attribute \"").concat(attrName, "\" has different values, expected \"").concat(attrValue, "\" but found \"").concat(elmAttrValue, "\""), owner);
7967
+ var getProperty = renderer.getProperty;
7968
+ logError("Mismatch hydrating element <".concat(getProperty(elm, 'tagName').toLowerCase(), ">: attribute \"").concat(attrName, "\" has different values, expected \"").concat(attrValue, "\" but found \"").concat(elmAttrValue, "\""), owner);
7929
7969
  }
7930
7970
 
7931
7971
  nodesAreCompatible = false;
@@ -8036,8 +8076,8 @@ var LWC = (function (exports) {
8036
8076
 
8037
8077
  if (!nodesAreCompatible) {
8038
8078
  if (process.env.NODE_ENV !== 'production') {
8039
- var _getProperty5 = renderer.getProperty;
8040
- logError("Mismatch hydrating element <".concat(_getProperty5(elm, 'tagName').toLowerCase(), ">: attribute \"style\" has different values, expected \"").concat(vnodeStyle, "\" but found \"").concat(elmStyle, "\"."), vnode.owner);
8079
+ var getProperty = renderer.getProperty;
8080
+ logError("Mismatch hydrating element <".concat(getProperty(elm, 'tagName').toLowerCase(), ">: attribute \"style\" has different values, expected \"").concat(vnodeStyle, "\" but found \"").concat(elmStyle, "\"."), vnode.owner);
8041
8081
  }
8042
8082
  }
8043
8083
 
@@ -8057,7 +8097,7 @@ var LWC = (function (exports) {
8057
8097
  return false;
8058
8098
  }
8059
8099
 
8060
- return getProperty(client, 'nodeValue') === getProperty(ssr, 'nodeValue');
8100
+ return getProperty(client, NODE_VALUE_PROP) === getProperty(ssr, NODE_VALUE_PROP);
8061
8101
  }
8062
8102
 
8063
8103
  if (getProperty(client, 'nodeType') === 8
@@ -8069,7 +8109,7 @@ var LWC = (function (exports) {
8069
8109
  return false;
8070
8110
  }
8071
8111
 
8072
- return getProperty(client, 'nodeValue') === getProperty(ssr, 'nodeValue');
8112
+ return getProperty(client, NODE_VALUE_PROP) === getProperty(ssr, NODE_VALUE_PROP);
8073
8113
  }
8074
8114
 
8075
8115
  if (!hasCorrectNodeType(vnode, ssr, 1
@@ -8269,7 +8309,7 @@ var LWC = (function (exports) {
8269
8309
 
8270
8310
  return ctor;
8271
8311
  }
8272
- /* version: 2.23.1 */
8312
+ /* version: 2.23.2 */
8273
8313
 
8274
8314
  /*
8275
8315
  * Copyright (c) 2018, salesforce.com, inc.
@@ -8436,361 +8476,395 @@ var LWC = (function (exports) {
8436
8476
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8437
8477
  */
8438
8478
 
8479
+ /**
8480
+ * A factory function that produces a renderer.
8481
+ * Renderer encapsulates operations that are required to render an LWC component into the underlying
8482
+ * runtime environment. In the case of @lwc/enigne-dom, it is meant to be used in a DOM environment.
8483
+ * Example usage:
8484
+ * import { renderer, rendererFactory } from 'lwc';
8485
+ * const customRenderer = rendererFactory(renderer);
8486
+ *
8487
+ * @param baseRenderer Either null or the base renderer imported from 'lwc'.
8488
+ */
8439
8489
 
8440
- var SUPPORTS_TEMPLATE = typeof HTMLTemplateElement === 'function';
8441
- var createFragment;
8442
8490
 
8443
- if (SUPPORTS_TEMPLATE) {
8444
- // Parse the fragment HTML string into DOM
8445
- createFragment = function createFragment(html) {
8446
- var template = document.createElement('template');
8447
- template.innerHTML = html;
8448
- return template.content.firstChild;
8449
- };
8450
- } else {
8451
- // In browsers that don't support <template> (e.g. IE11), we need to be careful to wrap elements like
8452
- // <td> in the proper container elements (e.g. <tbody>), because otherwise they will be parsed as null.
8453
- // Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L273-L280
8454
- // With other elements added from:
8455
- // https://github.com/sindresorhus/html-tags/blob/95dcdd5/index.js
8456
- // Using the test:
8457
- // document.createRange().createContextualFragment(`<${tag}></${tag}>`).firstChild === null
8458
- // And omitting <html>, <head>, and <body> as these are not practical in an LWC component.
8459
- var topLevelWrappingMap = {
8460
- caption: ['table'],
8461
- col: ['colgroup', 'table'],
8462
- colgroup: ['table'],
8463
- option: ['select'],
8464
- tbody: ['table'],
8465
- td: ['tr', 'tbody', 'table'],
8466
- th: ['tr', 'tbody', 'table'],
8467
- thead: ['table'],
8468
- tfoot: ['table'],
8469
- tr: ['tbody', 'table']
8470
- }; // Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L282-L288
8471
-
8472
- var getTagName = function getTagName(text) {
8473
- return (/<([a-z][^/\0>\x20\t\r\n\f]+)/i.exec(text) || ['', ''])[1].toLowerCase();
8474
- }; // Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L295-L320
8475
-
8476
-
8477
- createFragment = function createFragment(html) {
8478
- var wrapperTags = topLevelWrappingMap[getTagName(html)];
8479
-
8480
- if (!isUndefined$1(wrapperTags)) {
8481
- var _iterator5 = _createForOfIteratorHelper(wrapperTags),
8482
- _step5;
8491
+ function rendererFactory(baseRenderer) {
8492
+ // Util functions
8493
+ function assertInvariant(value, msg) {
8494
+ if (!value) {
8495
+ throw new Error("Invariant Violation: ".concat(msg));
8496
+ }
8497
+ }
8483
8498
 
8484
- try {
8485
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
8486
- var wrapperTag = _step5.value;
8487
- html = "<".concat(wrapperTag, ">").concat(html, "</").concat(wrapperTag, ">");
8488
- }
8489
- } catch (err) {
8490
- _iterator5.e(err);
8491
- } finally {
8492
- _iterator5.f();
8493
- }
8494
- } // For IE11, the document title must not be undefined, but it can be an empty string
8495
- // https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createHTMLDocument#browser_compatibility
8499
+ function isNull(obj) {
8500
+ return obj === null;
8501
+ }
8496
8502
 
8503
+ function isUndefined(obj) {
8504
+ return obj === undefined;
8505
+ }
8497
8506
 
8498
- var doc = document.implementation.createHTMLDocument('');
8499
- doc.body.innerHTML = html;
8500
- var content = doc.body;
8507
+ var getCustomElement;
8508
+ var defineCustomElement;
8509
+ var HTMLElementConstructor;
8501
8510
 
8502
- if (!isUndefined$1(wrapperTags)) {
8503
- for (var _i32 = 0; _i32 < wrapperTags.length; _i32++) {
8504
- content = content.firstChild;
8505
- }
8511
+ function isCustomElementRegistryAvailable() {
8512
+ if (typeof customElements === 'undefined') {
8513
+ return false;
8506
8514
  }
8507
8515
 
8508
- return content.firstChild;
8509
- };
8510
- }
8511
- /*
8512
- * Copyright (c) 2018, salesforce.com, inc.
8513
- * All rights reserved.
8514
- * SPDX-License-Identifier: MIT
8515
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8516
- */
8516
+ try {
8517
+ // dereference HTMLElement global because babel wraps globals in compat mode with a
8518
+ // _wrapNativeSuper()
8519
+ // This is a problem because LWCUpgradableElement extends renderer.HTMLElementExported which does not
8520
+ // get wrapped by babel.
8521
+ var HTMLElementAlias = HTMLElement; // In case we use compat mode with a modern browser, the compat mode transformation
8522
+ // invokes the DOM api with an .apply() or .call() to initialize any DOM api sub-classing,
8523
+ // which are not equipped to be initialized that way.
8517
8524
 
8525
+ var clazz = /*#__PURE__*/function (_HTMLElementAlias) {
8526
+ _inherits(clazz, _HTMLElementAlias);
8518
8527
 
8519
- var getCustomElement;
8520
- var defineCustomElement;
8521
- var HTMLElementConstructor;
8528
+ var _super7 = _createSuper(clazz);
8522
8529
 
8523
- function isCustomElementRegistryAvailable() {
8524
- if (typeof customElements === 'undefined') {
8525
- return false;
8530
+ function clazz() {
8531
+ _classCallCheck(this, clazz);
8532
+
8533
+ return _super7.apply(this, arguments);
8534
+ }
8535
+
8536
+ return _createClass(clazz);
8537
+ }(HTMLElementAlias);
8538
+
8539
+ customElements.define('lwc-test-' + Math.floor(Math.random() * 1000000), clazz);
8540
+ new clazz();
8541
+ return true;
8542
+ } catch (_a) {
8543
+ return false;
8544
+ }
8526
8545
  }
8527
8546
 
8528
- try {
8529
- // dereference HTMLElement global because babel wraps globals in compat mode with a
8530
- // _wrapNativeSuper()
8531
- // This is a problem because LWCUpgradableElement extends renderer.HTMLElementExported which does not
8532
- // get wrapped by babel.
8533
- var HTMLElementAlias = HTMLElement; // In case we use compat mode with a modern browser, the compat mode transformation
8534
- // invokes the DOM api with an .apply() or .call() to initialize any DOM api sub-classing,
8535
- // which are not equipped to be initialized that way.
8547
+ if (isCustomElementRegistryAvailable()) {
8548
+ getCustomElement = customElements.get.bind(customElements);
8549
+ defineCustomElement = customElements.define.bind(customElements);
8550
+ HTMLElementConstructor = HTMLElement;
8551
+ } else {
8552
+ var registry = Object.create(null);
8553
+ var reverseRegistry = new WeakMap();
8536
8554
 
8537
- var clazz = /*#__PURE__*/function (_HTMLElementAlias) {
8538
- _inherits(clazz, _HTMLElementAlias);
8555
+ defineCustomElement = function define(name, ctor) {
8556
+ if (name !== String.prototype.toLowerCase.call(name) || registry[name]) {
8557
+ throw new TypeError("Invalid Registration");
8558
+ }
8539
8559
 
8540
- var _super7 = _createSuper(clazz);
8560
+ registry[name] = ctor;
8561
+ reverseRegistry.set(ctor, name);
8562
+ };
8541
8563
 
8542
- function clazz() {
8543
- _classCallCheck(this, clazz);
8564
+ getCustomElement = function get(name) {
8565
+ return registry[name];
8566
+ };
8544
8567
 
8545
- return _super7.apply(this, arguments);
8568
+ HTMLElementConstructor = function HTMLElement() {
8569
+ if (!(this instanceof HTMLElement)) {
8570
+ throw new TypeError("Invalid Invocation");
8546
8571
  }
8547
8572
 
8548
- return _createClass(clazz);
8549
- }(HTMLElementAlias);
8573
+ var constructor = this.constructor;
8574
+ var name = reverseRegistry.get(constructor);
8550
8575
 
8551
- customElements.define('lwc-test-' + Math.floor(Math.random() * 1000000), clazz);
8552
- new clazz();
8553
- return true;
8554
- } catch (_a) {
8555
- return false;
8576
+ if (!name) {
8577
+ throw new TypeError("Invalid Construction");
8578
+ }
8579
+
8580
+ var elm = document.createElement(name);
8581
+ Object.setPrototypeOf(elm, constructor.prototype);
8582
+ return elm;
8583
+ };
8584
+
8585
+ HTMLElementConstructor.prototype = HTMLElement.prototype;
8556
8586
  }
8557
- }
8558
8587
 
8559
- if (isCustomElementRegistryAvailable()) {
8560
- getCustomElement = customElements.get.bind(customElements);
8561
- defineCustomElement = customElements.define.bind(customElements);
8562
- HTMLElementConstructor = HTMLElement;
8563
- } else {
8564
- var registry = create(null);
8565
- var reverseRegistry = new WeakMap();
8588
+ function cloneNode(node, deep) {
8589
+ return node.cloneNode(deep);
8590
+ }
8566
8591
 
8567
- defineCustomElement = function define(name, ctor) {
8568
- if (name !== StringToLowerCase.call(name) || registry[name]) {
8569
- throw new TypeError("Invalid Registration");
8570
- }
8592
+ function createElement(tagName, namespace) {
8593
+ return isUndefined(namespace) ? document.createElement(tagName) : document.createElementNS(namespace, tagName);
8594
+ }
8571
8595
 
8572
- registry[name] = ctor;
8573
- reverseRegistry.set(ctor, name);
8574
- };
8596
+ function createText(content) {
8597
+ return document.createTextNode(content);
8598
+ }
8575
8599
 
8576
- getCustomElement = function get(name) {
8577
- return registry[name];
8578
- };
8600
+ function createComment(content) {
8601
+ return document.createComment(content);
8602
+ }
8579
8603
 
8580
- HTMLElementConstructor = function HTMLElement() {
8581
- if (!(this instanceof HTMLElement)) {
8582
- throw new TypeError("Invalid Invocation");
8583
- }
8604
+ var createFragment; // IE11 lacks support for this feature
8584
8605
 
8585
- var constructor = this.constructor;
8586
- var name = reverseRegistry.get(constructor);
8606
+ var SUPPORTS_TEMPLATE = typeof HTMLTemplateElement === 'function';
8587
8607
 
8588
- if (!name) {
8589
- throw new TypeError("Invalid Construction");
8590
- }
8608
+ if (SUPPORTS_TEMPLATE) {
8609
+ // Parse the fragment HTML string into DOM
8610
+ createFragment = function createFragment(html) {
8611
+ var template = document.createElement('template');
8612
+ template.innerHTML = html;
8613
+ return template.content.firstChild;
8614
+ };
8615
+ } else {
8616
+ // In browsers that don't support <template> (e.g. IE11), we need to be careful to wrap elements like
8617
+ // <td> in the proper container elements (e.g. <tbody>), because otherwise they will be parsed as null.
8618
+ // Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L273-L280
8619
+ // With other elements added from:
8620
+ // https://github.com/sindresorhus/html-tags/blob/95dcdd5/index.js
8621
+ // Using the test:
8622
+ // document.createRange().createContextualFragment(`<${tag}></${tag}>`).firstChild === null
8623
+ // And omitting <html>, <head>, and <body> as these are not practical in an LWC component.
8624
+ var topLevelWrappingMap = {
8625
+ caption: ['table'],
8626
+ col: ['colgroup', 'table'],
8627
+ colgroup: ['table'],
8628
+ option: ['select'],
8629
+ tbody: ['table'],
8630
+ td: ['tr', 'tbody', 'table'],
8631
+ th: ['tr', 'tbody', 'table'],
8632
+ thead: ['table'],
8633
+ tfoot: ['table'],
8634
+ tr: ['tbody', 'table']
8635
+ }; // Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L282-L288
8636
+
8637
+ var getTagName = function getTagName(text) {
8638
+ return (/<([a-z][^/\0>\x20\t\r\n\f]+)/i.exec(text) || ['', ''])[1].toLowerCase();
8639
+ }; // Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L295-L320
8640
+
8641
+
8642
+ createFragment = function createFragment(html) {
8643
+ var wrapperTags = topLevelWrappingMap[getTagName(html)];
8644
+
8645
+ if (!isUndefined(wrapperTags)) {
8646
+ var _iterator5 = _createForOfIteratorHelper(wrapperTags),
8647
+ _step5;
8648
+
8649
+ try {
8650
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
8651
+ var wrapperTag = _step5.value;
8652
+ html = "<".concat(wrapperTag, ">").concat(html, "</").concat(wrapperTag, ">");
8653
+ }
8654
+ } catch (err) {
8655
+ _iterator5.e(err);
8656
+ } finally {
8657
+ _iterator5.f();
8658
+ }
8659
+ } // For IE11, the document title must not be undefined, but it can be an empty string
8660
+ // https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createHTMLDocument#browser_compatibility
8591
8661
 
8592
- var elm = document.createElement(name);
8593
- setPrototypeOf(elm, constructor.prototype);
8594
- return elm;
8595
- };
8596
8662
 
8597
- HTMLElementConstructor.prototype = HTMLElement.prototype;
8598
- }
8663
+ var doc = document.implementation.createHTMLDocument('');
8664
+ doc.body.innerHTML = html;
8665
+ var content = doc.body;
8599
8666
 
8600
- var isNativeShadowDefined = _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED];
8601
- var isSyntheticShadowDefined = hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN);
8667
+ if (!isUndefined(wrapperTags)) {
8668
+ for (var _i32 = 0; _i32 < wrapperTags.length; _i32++) {
8669
+ content = content.firstChild;
8670
+ }
8671
+ }
8602
8672
 
8603
- function cloneNode(node, deep) {
8604
- return node.cloneNode(deep);
8605
- }
8673
+ return content.firstChild;
8674
+ };
8675
+ }
8606
8676
 
8607
- function createElement$1(tagName, namespace) {
8608
- return isUndefined$1(namespace) ? document.createElement(tagName) : document.createElementNS(namespace, tagName);
8609
- }
8677
+ function insert(node, parent, anchor) {
8678
+ parent.insertBefore(node, anchor);
8679
+ }
8610
8680
 
8611
- function createText(content) {
8612
- return document.createTextNode(content);
8613
- }
8681
+ function remove(node, parent) {
8682
+ parent.removeChild(node);
8683
+ }
8614
8684
 
8615
- function createComment(content) {
8616
- return document.createComment(content);
8617
- }
8685
+ function nextSibling(node) {
8686
+ return node.nextSibling;
8687
+ }
8618
8688
 
8619
- function insert(node, parent, anchor) {
8620
- parent.insertBefore(node, anchor);
8621
- }
8689
+ function attachShadow(element, options) {
8690
+ // `shadowRoot` will be non-null in two cases:
8691
+ // 1. upon initial load with an SSR-generated DOM, while in Shadow render mode
8692
+ // 2. when a webapp author places <c-app> in their static HTML and mounts their
8693
+ // root component with customElement.define('c-app', Ctor)
8694
+ if (!isNull(element.shadowRoot)) {
8695
+ return element.shadowRoot;
8696
+ }
8622
8697
 
8623
- function remove(node, parent) {
8624
- parent.removeChild(node);
8625
- }
8698
+ return element.attachShadow(options);
8699
+ }
8626
8700
 
8627
- function nextSibling(node) {
8628
- return node.nextSibling;
8629
- }
8701
+ function setText(node, content) {
8702
+ node.nodeValue = content;
8703
+ }
8630
8704
 
8631
- function attachShadow(element, options) {
8632
- // `shadowRoot` will be non-null in two cases:
8633
- // 1. upon initial load with an SSR-generated DOM, while in Shadow render mode
8634
- // 2. when a webapp author places <c-app> in their static HTML and mounts their
8635
- // root component with customElement.define('c-app', Ctor)
8636
- if (!isNull(element.shadowRoot)) {
8637
- return element.shadowRoot;
8705
+ function getProperty(node, key) {
8706
+ return node[key];
8638
8707
  }
8639
8708
 
8640
- return element.attachShadow(options);
8641
- }
8709
+ function setProperty(node, key, value) {
8710
+ node[key] = value;
8711
+ }
8642
8712
 
8643
- function setText(node, content) {
8644
- node.nodeValue = content;
8645
- }
8713
+ function getAttribute(element, name, namespace) {
8714
+ return isUndefined(namespace) ? element.getAttribute(name) : element.getAttributeNS(namespace, name);
8715
+ }
8646
8716
 
8647
- function getProperty(node, key) {
8648
- return node[key];
8649
- }
8717
+ function setAttribute(element, name, value, namespace) {
8718
+ return isUndefined(namespace) ? element.setAttribute(name, value) : element.setAttributeNS(namespace, name, value);
8719
+ }
8650
8720
 
8651
- function setProperty(node, key, value) {
8652
- if (process.env.NODE_ENV !== 'production') {
8653
- if (node instanceof Element && !(key in node)) {
8654
- // TODO [#1297]: Move this validation to the compiler
8655
- assert.fail("Unknown public property \"".concat(key, "\" of element <").concat(node.tagName, ">. This is likely a typo on the corresponding attribute \"").concat(htmlPropertyToAttribute(key), "\"."));
8721
+ function removeAttribute(element, name, namespace) {
8722
+ if (isUndefined(namespace)) {
8723
+ element.removeAttribute(name);
8724
+ } else {
8725
+ element.removeAttributeNS(namespace, name);
8656
8726
  }
8657
8727
  }
8658
8728
 
8659
- node[key] = value;
8660
- }
8729
+ function addEventListener(target, type, callback, options) {
8730
+ target.addEventListener(type, callback, options);
8731
+ }
8661
8732
 
8662
- function getAttribute(element, name, namespace) {
8663
- return isUndefined$1(namespace) ? element.getAttribute(name) : element.getAttributeNS(namespace, name);
8664
- }
8733
+ function removeEventListener(target, type, callback, options) {
8734
+ target.removeEventListener(type, callback, options);
8735
+ }
8665
8736
 
8666
- function setAttribute(element, name, value, namespace) {
8667
- return isUndefined$1(namespace) ? element.setAttribute(name, value) : element.setAttributeNS(namespace, name, value);
8668
- }
8737
+ function dispatchEvent(target, event) {
8738
+ return target.dispatchEvent(event);
8739
+ }
8669
8740
 
8670
- function removeAttribute(element, name, namespace) {
8671
- if (isUndefined$1(namespace)) {
8672
- element.removeAttribute(name);
8673
- } else {
8674
- element.removeAttributeNS(namespace, name);
8741
+ function getClassList(element) {
8742
+ return element.classList;
8675
8743
  }
8676
- }
8677
8744
 
8678
- function addEventListener(target, type, callback, options) {
8679
- target.addEventListener(type, callback, options);
8680
- }
8745
+ function setCSSStyleProperty(element, name, value, important) {
8746
+ // TODO [#0]: How to avoid this type casting? Shall we use a different type interface to
8747
+ // represent elements in the engine?
8748
+ element.style.setProperty(name, value, important ? 'important' : '');
8749
+ }
8681
8750
 
8682
- function removeEventListener(target, type, callback, options) {
8683
- target.removeEventListener(type, callback, options);
8684
- }
8751
+ function getBoundingClientRect(element) {
8752
+ return element.getBoundingClientRect();
8753
+ }
8685
8754
 
8686
- function dispatchEvent(target, event) {
8687
- return target.dispatchEvent(event);
8688
- }
8755
+ function querySelector(element, selectors) {
8756
+ return element.querySelector(selectors);
8757
+ }
8689
8758
 
8690
- function getClassList(element) {
8691
- return element.classList;
8692
- }
8759
+ function querySelectorAll(element, selectors) {
8760
+ return element.querySelectorAll(selectors);
8761
+ }
8693
8762
 
8694
- function setCSSStyleProperty(element, name, value, important) {
8695
- // TODO [#0]: How to avoid this type casting? Shall we use a different type interface to
8696
- // represent elements in the engine?
8697
- element.style.setProperty(name, value, important ? 'important' : '');
8698
- }
8763
+ function getElementsByTagName(element, tagNameOrWildCard) {
8764
+ return element.getElementsByTagName(tagNameOrWildCard);
8765
+ }
8699
8766
 
8700
- function getBoundingClientRect(element) {
8701
- return element.getBoundingClientRect();
8702
- }
8767
+ function getElementsByClassName(element, names) {
8768
+ return element.getElementsByClassName(names);
8769
+ }
8703
8770
 
8704
- function querySelector(element, selectors) {
8705
- return element.querySelector(selectors);
8706
- }
8771
+ function getChildren(element) {
8772
+ return element.children;
8773
+ }
8707
8774
 
8708
- function querySelectorAll(element, selectors) {
8709
- return element.querySelectorAll(selectors);
8710
- }
8775
+ function getChildNodes(element) {
8776
+ return element.childNodes;
8777
+ }
8711
8778
 
8712
- function getElementsByTagName(element, tagNameOrWildCard) {
8713
- return element.getElementsByTagName(tagNameOrWildCard);
8714
- }
8779
+ function getFirstChild(element) {
8780
+ return element.firstChild;
8781
+ }
8715
8782
 
8716
- function getElementsByClassName(element, names) {
8717
- return element.getElementsByClassName(names);
8718
- }
8783
+ function getFirstElementChild(element) {
8784
+ return element.firstElementChild;
8785
+ }
8719
8786
 
8720
- function getChildren(element) {
8721
- return element.children;
8722
- }
8787
+ function getLastChild(element) {
8788
+ return element.lastChild;
8789
+ }
8723
8790
 
8724
- function getChildNodes(element) {
8725
- return element.childNodes;
8726
- }
8791
+ function getLastElementChild(element) {
8792
+ return element.lastElementChild;
8793
+ }
8727
8794
 
8728
- function getFirstChild(element) {
8729
- return element.firstChild;
8730
- }
8795
+ function isConnected(node) {
8796
+ return node.isConnected;
8797
+ }
8731
8798
 
8732
- function getFirstElementChild(element) {
8733
- return element.firstElementChild;
8734
- }
8799
+ function assertInstanceOfHTMLElement(elm, msg) {
8800
+ assertInvariant(elm instanceof HTMLElement, msg);
8801
+ }
8735
8802
 
8736
- function getLastChild(element) {
8737
- return element.lastChild;
8738
- }
8803
+ var HTMLElementExported = HTMLElementConstructor;
8804
+ var renderer = {
8805
+ HTMLElementExported: HTMLElementExported,
8806
+ insert: insert,
8807
+ remove: remove,
8808
+ cloneNode: cloneNode,
8809
+ createFragment: createFragment,
8810
+ createElement: createElement,
8811
+ createText: createText,
8812
+ createComment: createComment,
8813
+ nextSibling: nextSibling,
8814
+ attachShadow: attachShadow,
8815
+ getProperty: getProperty,
8816
+ setProperty: setProperty,
8817
+ setText: setText,
8818
+ getAttribute: getAttribute,
8819
+ setAttribute: setAttribute,
8820
+ removeAttribute: removeAttribute,
8821
+ addEventListener: addEventListener,
8822
+ removeEventListener: removeEventListener,
8823
+ dispatchEvent: dispatchEvent,
8824
+ getClassList: getClassList,
8825
+ setCSSStyleProperty: setCSSStyleProperty,
8826
+ getBoundingClientRect: getBoundingClientRect,
8827
+ querySelector: querySelector,
8828
+ querySelectorAll: querySelectorAll,
8829
+ getElementsByTagName: getElementsByTagName,
8830
+ getElementsByClassName: getElementsByClassName,
8831
+ getChildren: getChildren,
8832
+ getChildNodes: getChildNodes,
8833
+ getFirstChild: getFirstChild,
8834
+ getFirstElementChild: getFirstElementChild,
8835
+ getLastChild: getLastChild,
8836
+ getLastElementChild: getLastElementChild,
8837
+ isConnected: isConnected,
8838
+ assertInstanceOfHTMLElement: assertInstanceOfHTMLElement,
8839
+ defineCustomElement: defineCustomElement,
8840
+ getCustomElement: getCustomElement
8841
+ }; // Meant to inherit any properties passed via the base renderer as the argument to the factory.
8739
8842
 
8740
- function getLastElementChild(element) {
8741
- return element.lastElementChild;
8843
+ Object.setPrototypeOf(renderer, baseRenderer);
8844
+ return renderer;
8742
8845
  }
8846
+ /*
8847
+ * Copyright (c) 2018, salesforce.com, inc.
8848
+ * All rights reserved.
8849
+ * SPDX-License-Identifier: MIT
8850
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8851
+ */
8743
8852
 
8744
- function isConnected(node) {
8745
- return node.isConnected;
8746
- }
8853
+ /**
8854
+ * The base renderer that will be used by engine-core.
8855
+ * This will be used for DOM operations when lwc is running in a browser environment.
8856
+ */
8747
8857
 
8748
- function assertInstanceOfHTMLElement(elm, msg) {
8749
- assert.invariant(elm instanceof HTMLElement, msg);
8750
- }
8751
8858
 
8752
- var HTMLElementExported = HTMLElementConstructor;
8753
- var renderer = {
8754
- isNativeShadowDefined: isNativeShadowDefined,
8755
- isSyntheticShadowDefined: isSyntheticShadowDefined,
8756
- HTMLElementExported: HTMLElementExported,
8757
- insert: insert,
8758
- remove: remove,
8759
- cloneNode: cloneNode,
8760
- createFragment: createFragment,
8761
- createElement: createElement$1,
8762
- createText: createText,
8763
- createComment: createComment,
8764
- nextSibling: nextSibling,
8765
- attachShadow: attachShadow,
8766
- getProperty: getProperty,
8767
- setProperty: setProperty,
8768
- setText: setText,
8769
- getAttribute: getAttribute,
8770
- setAttribute: setAttribute,
8771
- removeAttribute: removeAttribute,
8772
- addEventListener: addEventListener,
8773
- removeEventListener: removeEventListener,
8774
- dispatchEvent: dispatchEvent,
8775
- getClassList: getClassList,
8776
- setCSSStyleProperty: setCSSStyleProperty,
8777
- getBoundingClientRect: getBoundingClientRect,
8778
- querySelector: querySelector,
8779
- querySelectorAll: querySelectorAll,
8780
- getElementsByTagName: getElementsByTagName,
8781
- getElementsByClassName: getElementsByClassName,
8782
- getChildren: getChildren,
8783
- getChildNodes: getChildNodes,
8784
- getFirstChild: getFirstChild,
8785
- getFirstElementChild: getFirstElementChild,
8786
- getLastChild: getLastChild,
8787
- getLastElementChild: getLastElementChild,
8788
- isConnected: isConnected,
8859
+ var renderer = assign( // The base renderer will invoke the factory with null and assign additional properties that are
8860
+ // shared across renderers
8861
+ rendererFactory(null), // Properties that are either not required to be sandboxed or rely on a globally shared information
8862
+ {
8863
+ // insertStyleSheet implementation shares a global cache of stylesheet data
8789
8864
  insertStylesheet: insertStylesheet,
8790
- assertInstanceOfHTMLElement: assertInstanceOfHTMLElement,
8791
- defineCustomElement: defineCustomElement,
8792
- getCustomElement: getCustomElement
8793
- };
8865
+ isNativeShadowDefined: _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED],
8866
+ isSyntheticShadowDefined: hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN)
8867
+ });
8794
8868
  /*
8795
8869
  * Copyright (c) 2018, salesforce.com, inc.
8796
8870
  * All rights reserved.
@@ -8962,7 +9036,6 @@ var LWC = (function (exports) {
8962
9036
  * SPDX-License-Identifier: MIT
8963
9037
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8964
9038
  */
8965
- // TODO [#2472]: Remove this workaround when appropriate.
8966
9039
  // eslint-disable-next-line @lwc/lwc-internal/no-global-node
8967
9040
 
8968
9041
 
@@ -8982,39 +9055,41 @@ var LWC = (function (exports) {
8982
9055
  }
8983
9056
 
8984
9057
  return node; // for convenience
8985
- } // Monkey patching Node methods to be able to detect the insertions and removal of root elements
8986
- // created via createElement.
8987
-
9058
+ }
8988
9059
 
8989
- var _Node$1$prototype = _Node$1.prototype,
8990
- _appendChild2 = _Node$1$prototype.appendChild,
8991
- _insertBefore2 = _Node$1$prototype.insertBefore,
8992
- _removeChild2 = _Node$1$prototype.removeChild,
8993
- _replaceChild2 = _Node$1$prototype.replaceChild;
8994
- assign(_Node$1.prototype, {
8995
- appendChild: function appendChild(newChild) {
8996
- var appendedNode = _appendChild2.call(this, newChild);
9060
+ if (!lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
9061
+ // Monkey patching Node methods to be able to detect the insertions and removal of root elements
9062
+ // created via createElement.
9063
+ var _Node$1$prototype = _Node$1.prototype,
9064
+ _appendChild = _Node$1$prototype.appendChild,
9065
+ _insertBefore = _Node$1$prototype.insertBefore,
9066
+ _removeChild = _Node$1$prototype.removeChild,
9067
+ _replaceChild = _Node$1$prototype.replaceChild;
9068
+ assign(_Node$1.prototype, {
9069
+ appendChild: function appendChild(newChild) {
9070
+ var appendedNode = _appendChild.call(this, newChild);
8997
9071
 
8998
- return callNodeSlot(appendedNode, ConnectingSlot);
8999
- },
9000
- insertBefore: function insertBefore(newChild, referenceNode) {
9001
- var insertedNode = _insertBefore2.call(this, newChild, referenceNode);
9072
+ return callNodeSlot(appendedNode, ConnectingSlot);
9073
+ },
9074
+ insertBefore: function insertBefore(newChild, referenceNode) {
9075
+ var insertedNode = _insertBefore.call(this, newChild, referenceNode);
9002
9076
 
9003
- return callNodeSlot(insertedNode, ConnectingSlot);
9004
- },
9005
- removeChild: function removeChild(oldChild) {
9006
- var removedNode = _removeChild2.call(this, oldChild);
9077
+ return callNodeSlot(insertedNode, ConnectingSlot);
9078
+ },
9079
+ removeChild: function removeChild(oldChild) {
9080
+ var removedNode = _removeChild.call(this, oldChild);
9007
9081
 
9008
- return callNodeSlot(removedNode, DisconnectingSlot);
9009
- },
9010
- replaceChild: function replaceChild(newChild, oldChild) {
9011
- var replacedNode = _replaceChild2.call(this, newChild, oldChild);
9082
+ return callNodeSlot(removedNode, DisconnectingSlot);
9083
+ },
9084
+ replaceChild: function replaceChild(newChild, oldChild) {
9085
+ var replacedNode = _replaceChild.call(this, newChild, oldChild);
9012
9086
 
9013
- callNodeSlot(replacedNode, DisconnectingSlot);
9014
- callNodeSlot(newChild, ConnectingSlot);
9015
- return replacedNode;
9016
- }
9017
- });
9087
+ callNodeSlot(replacedNode, DisconnectingSlot);
9088
+ callNodeSlot(newChild, ConnectingSlot);
9089
+ return replacedNode;
9090
+ }
9091
+ });
9092
+ }
9018
9093
  /**
9019
9094
  * EXPERIMENTAL: This function is almost identical to document.createElement with the slightly
9020
9095
  * difference that in the options, you can pass the `is` property set to a Constructor instead of
@@ -9027,6 +9102,7 @@ var LWC = (function (exports) {
9027
9102
  * ```
9028
9103
  */
9029
9104
 
9105
+
9030
9106
  function createElement(sel, options) {
9031
9107
  if (!isObject(options) || isNull(options)) {
9032
9108
  throw new TypeError("\"createElement\" function expects an object as second parameter but received \"".concat(toString$1(options), "\"."));
@@ -9054,8 +9130,12 @@ var LWC = (function (exports) {
9054
9130
  mode: options.mode !== 'closed' ? 'open' : 'closed',
9055
9131
  owner: null
9056
9132
  });
9057
- ConnectingSlot.set(elm, connectRootElement);
9058
- DisconnectingSlot.set(elm, disconnectRootElement);
9133
+
9134
+ if (!lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
9135
+ ConnectingSlot.set(elm, connectRootElement);
9136
+ DisconnectingSlot.set(elm, disconnectRootElement);
9137
+ }
9138
+
9059
9139
  wasComponentUpgraded = true;
9060
9140
  });
9061
9141
 
@@ -9102,7 +9182,7 @@ var LWC = (function (exports) {
9102
9182
  // inserted nodes without the `lwc:dom=manual` directive will be considered as global elements.
9103
9183
 
9104
9184
 
9105
- return isSyntheticShadowDefined && !isUndefined$1(node[KEY__SHADOW_RESOLVER]);
9185
+ return renderer.isSyntheticShadowDefined && !isUndefined$1(node[KEY__SHADOW_RESOLVER]);
9106
9186
  }
9107
9187
  /*
9108
9188
  * Copyright (c) 2018, salesforce.com, inc.
@@ -9146,7 +9226,7 @@ var LWC = (function (exports) {
9146
9226
  });
9147
9227
  freeze(LightningElement);
9148
9228
  seal(LightningElement.prototype);
9149
- /* version: 2.23.1 */
9229
+ /* version: 2.23.2 */
9150
9230
 
9151
9231
  exports.LightningElement = LightningElement;
9152
9232
  exports.__unstable__ProfilerControl = profilerControl;
@@ -9168,6 +9248,7 @@ var LWC = (function (exports) {
9168
9248
  exports.registerDecorators = registerDecorators;
9169
9249
  exports.registerTemplate = registerTemplate;
9170
9250
  exports.renderer = renderer;
9251
+ exports.rendererFactory = rendererFactory;
9171
9252
  exports.sanitizeAttribute = sanitizeAttribute;
9172
9253
  exports.setFeatureFlag = setFeatureFlag;
9173
9254
  exports.setFeatureFlagForTest = setFeatureFlagForTest;