@lwc/engine-core 2.11.0 → 2.11.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.
@@ -2307,6 +2307,12 @@ function checkVersionMismatch(func, type) {
2307
2307
  }
2308
2308
  }
2309
2309
 
2310
+ /*
2311
+ * Copyright (c) 2018, salesforce.com, inc.
2312
+ * All rights reserved.
2313
+ * SPDX-License-Identifier: MIT
2314
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2315
+ */
2310
2316
  const signedTemplateSet = new Set();
2311
2317
  function defaultEmptyTemplate() {
2312
2318
  return [];
@@ -2324,6 +2330,30 @@ function registerTemplate(tpl) {
2324
2330
  checkVersionMismatch(tpl, 'template');
2325
2331
  }
2326
2332
  signedTemplateSet.add(tpl);
2333
+ // FIXME[@W-10950976]: the template object should be frozen, and it should not be possible to set
2334
+ // the stylesheets or stylesheetToken(s). For backwards compat, though, we shim stylesheetTokens
2335
+ // on top of stylesheetToken for anyone who is accessing the old internal API.
2336
+ // Details: https://salesforce.quip.com/v1rmAFu2cKAr
2337
+ shared.defineProperty(tpl, 'stylesheetTokens', {
2338
+ get() {
2339
+ const { stylesheetToken } = this;
2340
+ if (shared.isUndefined(stylesheetToken)) {
2341
+ return stylesheetToken;
2342
+ }
2343
+ // Shim for the old `stylesheetTokens` property
2344
+ // See https://github.com/salesforce/lwc/pull/2332/files#diff-7901555acef29969adaa6583185b3e9bce475cdc6f23e799a54e0018cb18abaa
2345
+ return {
2346
+ hostAttribute: `${stylesheetToken}-host`,
2347
+ shadowAttribute: stylesheetToken,
2348
+ };
2349
+ },
2350
+ set(value) {
2351
+ // If the value is null or some other exotic object, you would be broken anyway in the past
2352
+ // because the engine would try to access hostAttribute/shadowAttribute, which would throw an error.
2353
+ // However it may be undefined in newer versions of LWC, so we need to guard against that case.
2354
+ this.stylesheetToken = shared.isUndefined(value) ? undefined : value.shadowAttribute;
2355
+ },
2356
+ });
2327
2357
  // chaining this method as a way to wrap existing
2328
2358
  // assignment of templates easily, without too much transformation
2329
2359
  return tpl;
@@ -4705,11 +4735,15 @@ const signedTemplateMap = new Map();
4705
4735
  * INTERNAL: This function can only be invoked by compiled code. The compiler
4706
4736
  * will prevent this function from being imported by userland code.
4707
4737
  */
4708
- function registerComponent(Ctor, { tmpl }) {
4709
- if (process.env.NODE_ENV !== 'production') {
4710
- checkVersionMismatch(Ctor, 'component');
4738
+ function registerComponent(
4739
+ // We typically expect a LightningElementConstructor, but technically you can call this with anything
4740
+ Ctor, { tmpl }) {
4741
+ if (shared.isFunction(Ctor)) {
4742
+ if (process.env.NODE_ENV !== 'production') {
4743
+ checkVersionMismatch(Ctor, 'component');
4744
+ }
4745
+ signedTemplateMap.set(Ctor, tmpl);
4711
4746
  }
4712
- signedTemplateMap.set(Ctor, tmpl);
4713
4747
  // chaining this method as a way to wrap existing assignment of component constructor easily,
4714
4748
  // without too much transformation
4715
4749
  return Ctor;
@@ -4798,236 +4832,6 @@ function invokeServiceHook(vm, cbs) {
4798
4832
  }
4799
4833
  }
4800
4834
 
4801
- /*
4802
- * Copyright (c) 2022, salesforce.com, inc.
4803
- * All rights reserved.
4804
- * SPDX-License-Identifier: MIT
4805
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4806
- */
4807
- function hydrate(vnode, node) {
4808
- switch (vnode.type) {
4809
- case 0 /* Text */:
4810
- hydrateText(vnode, node);
4811
- break;
4812
- case 1 /* Comment */:
4813
- hydrateComment(vnode, node);
4814
- break;
4815
- case 2 /* Element */:
4816
- hydrateElement(vnode, node);
4817
- break;
4818
- case 3 /* CustomElement */:
4819
- hydrateCustomElement(vnode, node);
4820
- break;
4821
- }
4822
- }
4823
- function hydrateText(vnode, node) {
4824
- var _a;
4825
- if (process.env.NODE_ENV !== 'production') {
4826
- validateNodeType(vnode, node, 3 /* TEXT */);
4827
- const nodeValue = getProperty(node, 'nodeValue');
4828
- if (nodeValue !== vnode.text && !(nodeValue === '\u200D' && vnode.text === '')) {
4829
- logWarn('Hydration mismatch: text values do not match, will recover from the difference', vnode.owner);
4830
- }
4831
- }
4832
- // always set the text value to the one from the vnode.
4833
- setText(node, (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
4834
- vnode.elm = node;
4835
- }
4836
- function hydrateComment(vnode, node) {
4837
- var _a;
4838
- if (process.env.NODE_ENV !== 'production') {
4839
- validateNodeType(vnode, node, 8 /* COMMENT */);
4840
- if (getProperty(node, 'nodeValue') !== vnode.text) {
4841
- logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vnode.owner);
4842
- }
4843
- }
4844
- // always set the text value to the one from the vnode.
4845
- setProperty(node, 'nodeValue', (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
4846
- vnode.elm = node;
4847
- }
4848
- function hydrateElement(vnode, node) {
4849
- if (process.env.NODE_ENV !== 'production') {
4850
- validateNodeType(vnode, node, 1 /* ELEMENT */);
4851
- validateElement(vnode, node);
4852
- }
4853
- const elm = node;
4854
- vnode.elm = elm;
4855
- const { context } = vnode.data;
4856
- const isDomManual = Boolean(!shared.isUndefined(context) && !shared.isUndefined(context.lwc) && context.lwc.dom === "manual" /* Manual */);
4857
- if (isDomManual) {
4858
- // it may be that this element has lwc:inner-html, we need to diff and in case are the same,
4859
- // remove the innerHTML from props so it reuses the existing dom elements.
4860
- const { props } = vnode.data;
4861
- if (!shared.isUndefined(props) && !shared.isUndefined(props.innerHTML)) {
4862
- if (getProperty(elm, 'innerHTML') === props.innerHTML) {
4863
- // Do a shallow clone since VNodeData may be shared across VNodes due to hoist optimization
4864
- vnode.data = Object.assign(Object.assign({}, vnode.data), { props: cloneAndOmitKey(props, 'innerHTML') });
4865
- }
4866
- else {
4867
- logWarn(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: innerHTML values do not match for element, will recover from the difference`, vnode.owner);
4868
- }
4869
- }
4870
- }
4871
- patchElementPropsAndAttrs(vnode);
4872
- if (!isDomManual) {
4873
- hydrateChildren(getChildNodes(vnode.elm), vnode.children, vnode.owner);
4874
- }
4875
- }
4876
- function hydrateCustomElement(vnode, node) {
4877
- if (process.env.NODE_ENV !== 'production') {
4878
- validateNodeType(vnode, node, 1 /* ELEMENT */);
4879
- validateElement(vnode, node);
4880
- }
4881
- const elm = node;
4882
- const { sel, mode, ctor, owner } = vnode;
4883
- const vm = createVM(elm, ctor, {
4884
- mode,
4885
- owner,
4886
- tagName: sel,
4887
- });
4888
- vnode.elm = elm;
4889
- vnode.vm = vm;
4890
- allocateChildren(vnode, vm);
4891
- patchElementPropsAndAttrs(vnode);
4892
- // Insert hook section:
4893
- if (process.env.NODE_ENV !== 'production') {
4894
- shared.assert.isTrue(vm.state === 0 /* created */, `${vm} cannot be recycled.`);
4895
- }
4896
- runConnectedCallback(vm);
4897
- if (vm.renderMode !== 0 /* Light */) {
4898
- // VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
4899
- // Note: for Light DOM, this is handled while hydrating the VM
4900
- hydrateChildren(getChildNodes(vnode.elm), vnode.children, vm);
4901
- }
4902
- hydrateVM(vm);
4903
- }
4904
- function hydrateChildren(elmChildren, children, vm) {
4905
- if (process.env.NODE_ENV !== 'production') {
4906
- const filteredVNodes = shared.ArrayFilter.call(children, (vnode) => !!vnode);
4907
- if (elmChildren.length !== filteredVNodes.length) {
4908
- logError(`Hydration mismatch: incorrect number of rendered nodes, expected ${filteredVNodes.length} but found ${elmChildren.length}.`, vm);
4909
- throwHydrationError();
4910
- }
4911
- }
4912
- let childNodeIndex = 0;
4913
- for (let i = 0; i < children.length; i++) {
4914
- const childVnode = children[i];
4915
- if (!shared.isNull(childVnode)) {
4916
- const childNode = elmChildren[childNodeIndex];
4917
- hydrate(childVnode, childNode);
4918
- childNodeIndex++;
4919
- }
4920
- }
4921
- }
4922
- function patchElementPropsAndAttrs(vnode) {
4923
- applyEventListeners(vnode);
4924
- patchProps(null, vnode);
4925
- }
4926
- function throwHydrationError() {
4927
- shared.assert.fail('Server rendered elements do not match client side generated elements');
4928
- }
4929
- function validateNodeType(vnode, node, nodeType) {
4930
- if (getProperty(node, 'nodeType') !== nodeType) {
4931
- logError('Hydration mismatch: incorrect node type received', vnode.owner);
4932
- shared.assert.fail('Hydration mismatch: incorrect node type received.');
4933
- }
4934
- }
4935
- function validateElement(vnode, elm) {
4936
- if (vnode.sel.toLowerCase() !== getProperty(elm, 'tagName').toLowerCase()) {
4937
- logError(`Hydration mismatch: expecting element with tag "${vnode.sel.toLowerCase()}" but found "${getProperty(elm, 'tagName').toLowerCase()}".`, vnode.owner);
4938
- throwHydrationError();
4939
- }
4940
- const hasIncompatibleAttrs = validateAttrs(vnode, elm);
4941
- const hasIncompatibleClass = validateClassAttr(vnode, elm);
4942
- const hasIncompatibleStyle = validateStyleAttr(vnode, elm);
4943
- const isVNodeAndElementCompatible = hasIncompatibleAttrs && hasIncompatibleClass && hasIncompatibleStyle;
4944
- if (!isVNodeAndElementCompatible) {
4945
- throwHydrationError();
4946
- }
4947
- }
4948
- function validateAttrs(vnode, elm) {
4949
- const { data: { attrs = {} }, } = vnode;
4950
- let nodesAreCompatible = true;
4951
- // Validate attributes, though we could always recovery from those by running the update mods.
4952
- // Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
4953
- for (const [attrName, attrValue] of Object.entries(attrs)) {
4954
- const elmAttrValue = getAttribute(elm, attrName);
4955
- if (String(attrValue) !== elmAttrValue) {
4956
- logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "${attrName}" has different values, expected "${attrValue}" but found "${elmAttrValue}"`, vnode.owner);
4957
- nodesAreCompatible = false;
4958
- }
4959
- }
4960
- return nodesAreCompatible;
4961
- }
4962
- function validateClassAttr(vnode, elm) {
4963
- const { data: { className, classMap }, } = vnode;
4964
- let nodesAreCompatible = true;
4965
- let vnodeClassName;
4966
- if (!shared.isUndefined(className) && String(className) !== getProperty(elm, 'className')) {
4967
- // className is used when class is bound to an expr.
4968
- nodesAreCompatible = false;
4969
- vnodeClassName = className;
4970
- }
4971
- else if (!shared.isUndefined(classMap)) {
4972
- // classMap is used when class is set to static value.
4973
- const classList = getClassList(elm);
4974
- let computedClassName = '';
4975
- // all classes from the vnode should be in the element.classList
4976
- for (const name in classMap) {
4977
- computedClassName += ' ' + name;
4978
- if (!classList.contains(name)) {
4979
- nodesAreCompatible = false;
4980
- }
4981
- }
4982
- vnodeClassName = computedClassName.trim();
4983
- if (classList.length > shared.keys(classMap).length) {
4984
- nodesAreCompatible = false;
4985
- }
4986
- }
4987
- if (!nodesAreCompatible) {
4988
- logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "class" has different values, expected "${vnodeClassName}" but found "${getProperty(elm, 'className')}"`, vnode.owner);
4989
- }
4990
- return nodesAreCompatible;
4991
- }
4992
- function validateStyleAttr(vnode, elm) {
4993
- const { data: { style, styleDecls }, } = vnode;
4994
- const elmStyle = getAttribute(elm, 'style') || '';
4995
- let vnodeStyle;
4996
- let nodesAreCompatible = true;
4997
- if (!shared.isUndefined(style) && style !== elmStyle) {
4998
- nodesAreCompatible = false;
4999
- vnodeStyle = style;
5000
- }
5001
- else if (!shared.isUndefined(styleDecls)) {
5002
- const parsedVnodeStyle = parseStyleText(elmStyle);
5003
- const expectedStyle = [];
5004
- // styleMap is used when style is set to static value.
5005
- for (let i = 0, n = styleDecls.length; i < n; i++) {
5006
- const [prop, value, important] = styleDecls[i];
5007
- expectedStyle.push(`${prop}: ${value + (important ? ' important!' : '')}`);
5008
- const parsedPropValue = parsedVnodeStyle[prop];
5009
- if (shared.isUndefined(parsedPropValue)) {
5010
- nodesAreCompatible = false;
5011
- }
5012
- else if (!parsedPropValue.startsWith(value)) {
5013
- nodesAreCompatible = false;
5014
- }
5015
- else if (important && !parsedPropValue.endsWith('!important')) {
5016
- nodesAreCompatible = false;
5017
- }
5018
- }
5019
- if (shared.keys(parsedVnodeStyle).length > styleDecls.length) {
5020
- nodesAreCompatible = false;
5021
- }
5022
- vnodeStyle = shared.ArrayJoin.call(expectedStyle, ';');
5023
- }
5024
- if (!nodesAreCompatible) {
5025
- // style is used when class is bound to an expr.
5026
- logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "style" has different values, expected "${vnodeStyle}" but found "${elmStyle}".`, vnode.owner);
5027
- }
5028
- return nodesAreCompatible;
5029
- }
5030
-
5031
4835
  /*
5032
4836
  * Copyright (c) 2018, salesforce.com, inc.
5033
4837
  * All rights reserved.
@@ -5073,32 +4877,12 @@ function connectRootElement(elm) {
5073
4877
  /* GlobalHydrate */
5074
4878
  , vm);
5075
4879
  }
5076
- function hydrateRootElement(elm) {
5077
- const vm = getAssociatedVM(elm);
5078
- runConnectedCallback(vm);
5079
- hydrateVM(vm);
5080
- }
5081
4880
  function disconnectRootElement(elm) {
5082
4881
  const vm = getAssociatedVM(elm);
5083
4882
  resetComponentStateWhenRemoved(vm);
5084
4883
  }
5085
4884
  function appendVM(vm) {
5086
4885
  rehydrate(vm);
5087
- }
5088
- function hydrateVM(vm) {
5089
- if (shared.isTrue(vm.isDirty)) {
5090
- // manually diffing/patching here.
5091
- // This routine is:
5092
- // patchShadowRoot(vm, children);
5093
- // -> addVnodes.
5094
- const children = renderComponent(vm);
5095
- vm.children = children;
5096
- const vmChildren = vm.renderMode === 0
5097
- /* Light */
5098
- ? getChildNodes(vm.elm) : getChildNodes(vm.elm.shadowRoot);
5099
- hydrateChildren(vmChildren, children, vm);
5100
- runRenderedCallback(vm);
5101
- }
5102
4886
  } // just in case the component comes back, with this we guarantee re-rendering it
5103
4887
  // while preventing any attempt to rehydration until after reinsertion.
5104
4888
 
@@ -5403,7 +5187,6 @@ function runRenderedCallback(vm) {
5403
5187
  , vm);
5404
5188
  }
5405
5189
  }
5406
-
5407
5190
  let rehydrateQueue = [];
5408
5191
 
5409
5192
  function flushRehydrationQueue() {
@@ -6060,6 +5843,298 @@ function readonly(obj) {
6060
5843
  return reactiveMembrane.getReadOnlyProxy(obj);
6061
5844
  }
6062
5845
 
5846
+ /*
5847
+ * Copyright (c) 2022, salesforce.com, inc.
5848
+ * All rights reserved.
5849
+ * SPDX-License-Identifier: MIT
5850
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
5851
+ */
5852
+ // flag indicating if the hydration recovered from the DOM mismatch
5853
+ let hasMismatch = false;
5854
+ function hydrateRoot(vm) {
5855
+ hasMismatch = false;
5856
+ runConnectedCallback(vm);
5857
+ hydrateVM(vm);
5858
+ if (hasMismatch) {
5859
+ logError('Hydration completed with errors.', vm);
5860
+ }
5861
+ }
5862
+ function hydrateVM(vm) {
5863
+ const children = renderComponent(vm);
5864
+ vm.children = children;
5865
+ const parentNode = vm.renderRoot;
5866
+ hydrateChildren(getFirstChild(parentNode), children, parentNode, vm);
5867
+ runRenderedCallback(vm);
5868
+ }
5869
+ function hydrateNode(node, vnode) {
5870
+ let hydratedNode;
5871
+ switch (vnode.type) {
5872
+ case 0 /* Text */:
5873
+ hydratedNode = hydrateText(node, vnode);
5874
+ break;
5875
+ case 1 /* Comment */:
5876
+ hydratedNode = hydrateComment(node, vnode);
5877
+ break;
5878
+ case 2 /* Element */:
5879
+ hydratedNode = hydrateElement(node, vnode);
5880
+ break;
5881
+ case 3 /* CustomElement */:
5882
+ hydratedNode = hydrateCustomElement(node, vnode);
5883
+ break;
5884
+ }
5885
+ return nextSibling(hydratedNode);
5886
+ }
5887
+ function hydrateText(node, vnode) {
5888
+ var _a;
5889
+ if (!hasCorrectNodeType(vnode, node, 3 /* TEXT */)) {
5890
+ return handleMismatch(node, vnode);
5891
+ }
5892
+ if (process.env.NODE_ENV !== 'production') {
5893
+ const nodeValue = getProperty(node, 'nodeValue');
5894
+ if (nodeValue !== vnode.text && !(nodeValue === '\u200D' && vnode.text === '')) {
5895
+ logWarn('Hydration mismatch: text values do not match, will recover from the difference', vnode.owner);
5896
+ }
5897
+ }
5898
+ setText(node, (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
5899
+ vnode.elm = node;
5900
+ return node;
5901
+ }
5902
+ function hydrateComment(node, vnode) {
5903
+ var _a;
5904
+ if (!hasCorrectNodeType(vnode, node, 8 /* COMMENT */)) {
5905
+ return handleMismatch(node, vnode);
5906
+ }
5907
+ if (process.env.NODE_ENV !== 'production') {
5908
+ const nodeValue = getProperty(node, 'nodeValue');
5909
+ if (nodeValue !== vnode.text) {
5910
+ logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vnode.owner);
5911
+ }
5912
+ }
5913
+ setProperty(node, 'nodeValue', (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
5914
+ vnode.elm = node;
5915
+ return node;
5916
+ }
5917
+ function hydrateElement(elm, vnode) {
5918
+ if (!hasCorrectNodeType(vnode, elm, 1 /* ELEMENT */) ||
5919
+ !isMatchingElement(vnode, elm)) {
5920
+ return handleMismatch(elm, vnode);
5921
+ }
5922
+ vnode.elm = elm;
5923
+ const { context } = vnode.data;
5924
+ const isDomManual = Boolean(!shared.isUndefined(context) && !shared.isUndefined(context.lwc) && context.lwc.dom === "manual" /* Manual */);
5925
+ if (isDomManual) {
5926
+ // it may be that this element has lwc:inner-html, we need to diff and in case are the same,
5927
+ // remove the innerHTML from props so it reuses the existing dom elements.
5928
+ const { props } = vnode.data;
5929
+ if (!shared.isUndefined(props) && !shared.isUndefined(props.innerHTML)) {
5930
+ if (getProperty(elm, 'innerHTML') === props.innerHTML) {
5931
+ // Do a shallow clone since VNodeData may be shared across VNodes due to hoist optimization
5932
+ vnode.data = Object.assign(Object.assign({}, vnode.data), { props: cloneAndOmitKey(props, 'innerHTML') });
5933
+ }
5934
+ else {
5935
+ if (process.env.NODE_ENV !== 'production') {
5936
+ logWarn(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: innerHTML values do not match for element, will recover from the difference`, vnode.owner);
5937
+ }
5938
+ }
5939
+ }
5940
+ }
5941
+ patchElementPropsAndAttrs(vnode);
5942
+ if (!isDomManual) {
5943
+ hydrateChildren(getFirstChild(elm), vnode.children, elm, vnode.owner);
5944
+ }
5945
+ return elm;
5946
+ }
5947
+ function hydrateCustomElement(elm, vnode) {
5948
+ if (!hasCorrectNodeType(vnode, elm, 1 /* ELEMENT */) ||
5949
+ !isMatchingElement(vnode, elm)) {
5950
+ return handleMismatch(elm, vnode);
5951
+ }
5952
+ const { sel, mode, ctor, owner } = vnode;
5953
+ const vm = createVM(elm, ctor, {
5954
+ mode,
5955
+ owner,
5956
+ tagName: sel,
5957
+ });
5958
+ vnode.elm = elm;
5959
+ vnode.vm = vm;
5960
+ allocateChildren(vnode, vm);
5961
+ patchElementPropsAndAttrs(vnode);
5962
+ // Insert hook section:
5963
+ if (process.env.NODE_ENV !== 'production') {
5964
+ shared.assert.isTrue(vm.state === 0 /* created */, `${vm} cannot be recycled.`);
5965
+ }
5966
+ runConnectedCallback(vm);
5967
+ if (vm.renderMode !== 0 /* Light */) {
5968
+ // VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
5969
+ // Note: for Light DOM, this is handled while hydrating the VM
5970
+ hydrateChildren(getFirstChild(elm), vnode.children, elm, vm);
5971
+ }
5972
+ hydrateVM(vm);
5973
+ return elm;
5974
+ }
5975
+ function hydrateChildren(node, children, parentNode, owner) {
5976
+ let hasWarned = false;
5977
+ let nextNode = node;
5978
+ let anchor = null;
5979
+ for (let i = 0; i < children.length; i++) {
5980
+ const childVnode = children[i];
5981
+ if (!shared.isNull(childVnode)) {
5982
+ if (nextNode) {
5983
+ nextNode = hydrateNode(nextNode, childVnode);
5984
+ anchor = childVnode.elm;
5985
+ }
5986
+ else {
5987
+ hasMismatch = true;
5988
+ if (process.env.NODE_ENV !== 'production') {
5989
+ if (!hasWarned) {
5990
+ hasWarned = true;
5991
+ logError(`Hydration mismatch: incorrect number of rendered nodes. Client produced more nodes than the server.`, owner);
5992
+ }
5993
+ }
5994
+ mount(childVnode, parentNode, anchor);
5995
+ anchor = childVnode.elm;
5996
+ }
5997
+ }
5998
+ }
5999
+ if (nextNode) {
6000
+ hasMismatch = true;
6001
+ if (process.env.NODE_ENV !== 'production') {
6002
+ if (!hasWarned) {
6003
+ logError(`Hydration mismatch: incorrect number of rendered nodes. Server rendered more nodes than the client.`, owner);
6004
+ }
6005
+ }
6006
+ do {
6007
+ const current = nextNode;
6008
+ nextNode = nextSibling(nextNode);
6009
+ removeNode(current, parentNode);
6010
+ } while (nextNode);
6011
+ }
6012
+ }
6013
+ function handleMismatch(node, vnode, msg) {
6014
+ hasMismatch = true;
6015
+ if (!shared.isUndefined(msg)) {
6016
+ if (process.env.NODE_ENV !== 'production') {
6017
+ logError(msg, vnode.owner);
6018
+ }
6019
+ }
6020
+ const parentNode = getProperty(node, 'parentNode');
6021
+ mount(vnode, parentNode, node);
6022
+ removeNode(node, parentNode);
6023
+ return vnode.elm;
6024
+ }
6025
+ function patchElementPropsAndAttrs(vnode) {
6026
+ applyEventListeners(vnode);
6027
+ patchProps(null, vnode);
6028
+ }
6029
+ function hasCorrectNodeType(vnode, node, nodeType) {
6030
+ if (getProperty(node, 'nodeType') !== nodeType) {
6031
+ if (process.env.NODE_ENV !== 'production') {
6032
+ logError('Hydration mismatch: incorrect node type received', vnode.owner);
6033
+ }
6034
+ return false;
6035
+ }
6036
+ return true;
6037
+ }
6038
+ function isMatchingElement(vnode, elm) {
6039
+ if (vnode.sel.toLowerCase() !== getProperty(elm, 'tagName').toLowerCase()) {
6040
+ if (process.env.NODE_ENV !== 'production') {
6041
+ logError(`Hydration mismatch: expecting element with tag "${vnode.sel.toLowerCase()}" but found "${getProperty(elm, 'tagName').toLowerCase()}".`, vnode.owner);
6042
+ }
6043
+ return false;
6044
+ }
6045
+ const hasIncompatibleAttrs = validateAttrs(vnode, elm);
6046
+ const hasIncompatibleClass = validateClassAttr(vnode, elm);
6047
+ const hasIncompatibleStyle = validateStyleAttr(vnode, elm);
6048
+ return hasIncompatibleAttrs && hasIncompatibleClass && hasIncompatibleStyle;
6049
+ }
6050
+ function validateAttrs(vnode, elm) {
6051
+ const { data: { attrs = {} }, } = vnode;
6052
+ let nodesAreCompatible = true;
6053
+ // Validate attributes, though we could always recovery from those by running the update mods.
6054
+ // Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
6055
+ for (const [attrName, attrValue] of Object.entries(attrs)) {
6056
+ const elmAttrValue = getAttribute(elm, attrName);
6057
+ if (String(attrValue) !== elmAttrValue) {
6058
+ if (process.env.NODE_ENV !== 'production') {
6059
+ logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "${attrName}" has different values, expected "${attrValue}" but found "${elmAttrValue}"`, vnode.owner);
6060
+ }
6061
+ nodesAreCompatible = false;
6062
+ }
6063
+ }
6064
+ return nodesAreCompatible;
6065
+ }
6066
+ function validateClassAttr(vnode, elm) {
6067
+ const { data: { className, classMap }, } = vnode;
6068
+ let nodesAreCompatible = true;
6069
+ let vnodeClassName;
6070
+ if (!shared.isUndefined(className) && String(className) !== getProperty(elm, 'className')) {
6071
+ // className is used when class is bound to an expr.
6072
+ nodesAreCompatible = false;
6073
+ vnodeClassName = className;
6074
+ }
6075
+ else if (!shared.isUndefined(classMap)) {
6076
+ // classMap is used when class is set to static value.
6077
+ const classList = getClassList(elm);
6078
+ let computedClassName = '';
6079
+ // all classes from the vnode should be in the element.classList
6080
+ for (const name in classMap) {
6081
+ computedClassName += ' ' + name;
6082
+ if (!classList.contains(name)) {
6083
+ nodesAreCompatible = false;
6084
+ }
6085
+ }
6086
+ vnodeClassName = computedClassName.trim();
6087
+ if (classList.length > shared.keys(classMap).length) {
6088
+ nodesAreCompatible = false;
6089
+ }
6090
+ }
6091
+ if (!nodesAreCompatible) {
6092
+ if (process.env.NODE_ENV !== 'production') {
6093
+ logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "class" has different values, expected "${vnodeClassName}" but found "${getProperty(elm, 'className')}"`, vnode.owner);
6094
+ }
6095
+ }
6096
+ return nodesAreCompatible;
6097
+ }
6098
+ function validateStyleAttr(vnode, elm) {
6099
+ const { data: { style, styleDecls }, } = vnode;
6100
+ const elmStyle = getAttribute(elm, 'style') || '';
6101
+ let vnodeStyle;
6102
+ let nodesAreCompatible = true;
6103
+ if (!shared.isUndefined(style) && style !== elmStyle) {
6104
+ nodesAreCompatible = false;
6105
+ vnodeStyle = style;
6106
+ }
6107
+ else if (!shared.isUndefined(styleDecls)) {
6108
+ const parsedVnodeStyle = parseStyleText(elmStyle);
6109
+ const expectedStyle = [];
6110
+ // styleMap is used when style is set to static value.
6111
+ for (let i = 0, n = styleDecls.length; i < n; i++) {
6112
+ const [prop, value, important] = styleDecls[i];
6113
+ expectedStyle.push(`${prop}: ${value + (important ? ' important!' : '')}`);
6114
+ const parsedPropValue = parsedVnodeStyle[prop];
6115
+ if (shared.isUndefined(parsedPropValue)) {
6116
+ nodesAreCompatible = false;
6117
+ }
6118
+ else if (!parsedPropValue.startsWith(value)) {
6119
+ nodesAreCompatible = false;
6120
+ }
6121
+ else if (important && !parsedPropValue.endsWith('!important')) {
6122
+ nodesAreCompatible = false;
6123
+ }
6124
+ }
6125
+ if (shared.keys(parsedVnodeStyle).length > styleDecls.length) {
6126
+ nodesAreCompatible = false;
6127
+ }
6128
+ vnodeStyle = shared.ArrayJoin.call(expectedStyle, ';');
6129
+ }
6130
+ if (!nodesAreCompatible) {
6131
+ if (process.env.NODE_ENV !== 'production') {
6132
+ logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "style" has different values, expected "${vnodeStyle}" but found "${elmStyle}".`, vnode.owner);
6133
+ }
6134
+ }
6135
+ return nodesAreCompatible;
6136
+ }
6137
+
6063
6138
  /*
6064
6139
  * Copyright (c) 2018, salesforce.com, inc.
6065
6140
  * All rights reserved.
@@ -6092,7 +6167,7 @@ exports.getAssociatedVMIfPresent = getAssociatedVMIfPresent;
6092
6167
  exports.getComponentDef = getComponentDef;
6093
6168
  exports.getComponentHtmlPrototype = getComponentHtmlPrototype;
6094
6169
  exports.getUpgradableConstructor = getUpgradableConstructor;
6095
- exports.hydrateRootElement = hydrateRootElement;
6170
+ exports.hydrateRoot = hydrateRoot;
6096
6171
  exports.isComponentConstructor = isComponentConstructor;
6097
6172
  exports.readonly = readonly;
6098
6173
  exports.register = register;
@@ -6147,4 +6222,4 @@ exports.swapTemplate = swapTemplate;
6147
6222
  exports.track = track;
6148
6223
  exports.unwrap = unwrap;
6149
6224
  exports.wire = wire;
6150
- /* version: 2.11.0 */
6225
+ /* version: 2.11.4 */