@lwc/engine-core 2.11.1 → 2.11.3-238prod.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,10 @@
1
+ MIT LICENSE
2
+
3
+ Copyright (c) 2018, Salesforce.com, Inc.
4
+ All rights reserved.
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
7
+
8
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
9
+
10
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -4802,236 +4802,6 @@ function invokeServiceHook(vm, cbs) {
4802
4802
  }
4803
4803
  }
4804
4804
 
4805
- /*
4806
- * Copyright (c) 2022, salesforce.com, inc.
4807
- * All rights reserved.
4808
- * SPDX-License-Identifier: MIT
4809
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4810
- */
4811
- function hydrate(vnode, node) {
4812
- switch (vnode.type) {
4813
- case 0 /* Text */:
4814
- hydrateText(vnode, node);
4815
- break;
4816
- case 1 /* Comment */:
4817
- hydrateComment(vnode, node);
4818
- break;
4819
- case 2 /* Element */:
4820
- hydrateElement(vnode, node);
4821
- break;
4822
- case 3 /* CustomElement */:
4823
- hydrateCustomElement(vnode, node);
4824
- break;
4825
- }
4826
- }
4827
- function hydrateText(vnode, node) {
4828
- var _a;
4829
- if (process.env.NODE_ENV !== 'production') {
4830
- validateNodeType(vnode, node, 3 /* TEXT */);
4831
- const nodeValue = getProperty(node, 'nodeValue');
4832
- if (nodeValue !== vnode.text && !(nodeValue === '\u200D' && vnode.text === '')) {
4833
- logWarn('Hydration mismatch: text values do not match, will recover from the difference', vnode.owner);
4834
- }
4835
- }
4836
- // always set the text value to the one from the vnode.
4837
- setText(node, (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
4838
- vnode.elm = node;
4839
- }
4840
- function hydrateComment(vnode, node) {
4841
- var _a;
4842
- if (process.env.NODE_ENV !== 'production') {
4843
- validateNodeType(vnode, node, 8 /* COMMENT */);
4844
- if (getProperty(node, 'nodeValue') !== vnode.text) {
4845
- logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vnode.owner);
4846
- }
4847
- }
4848
- // always set the text value to the one from the vnode.
4849
- setProperty(node, 'nodeValue', (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
4850
- vnode.elm = node;
4851
- }
4852
- function hydrateElement(vnode, node) {
4853
- if (process.env.NODE_ENV !== 'production') {
4854
- validateNodeType(vnode, node, 1 /* ELEMENT */);
4855
- validateElement(vnode, node);
4856
- }
4857
- const elm = node;
4858
- vnode.elm = elm;
4859
- const { context } = vnode.data;
4860
- const isDomManual = Boolean(!shared.isUndefined(context) && !shared.isUndefined(context.lwc) && context.lwc.dom === "manual" /* Manual */);
4861
- if (isDomManual) {
4862
- // it may be that this element has lwc:inner-html, we need to diff and in case are the same,
4863
- // remove the innerHTML from props so it reuses the existing dom elements.
4864
- const { props } = vnode.data;
4865
- if (!shared.isUndefined(props) && !shared.isUndefined(props.innerHTML)) {
4866
- if (getProperty(elm, 'innerHTML') === props.innerHTML) {
4867
- // Do a shallow clone since VNodeData may be shared across VNodes due to hoist optimization
4868
- vnode.data = Object.assign(Object.assign({}, vnode.data), { props: cloneAndOmitKey(props, 'innerHTML') });
4869
- }
4870
- else {
4871
- logWarn(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: innerHTML values do not match for element, will recover from the difference`, vnode.owner);
4872
- }
4873
- }
4874
- }
4875
- patchElementPropsAndAttrs(vnode);
4876
- if (!isDomManual) {
4877
- hydrateChildren(getChildNodes(vnode.elm), vnode.children, vnode.owner);
4878
- }
4879
- }
4880
- function hydrateCustomElement(vnode, node) {
4881
- if (process.env.NODE_ENV !== 'production') {
4882
- validateNodeType(vnode, node, 1 /* ELEMENT */);
4883
- validateElement(vnode, node);
4884
- }
4885
- const elm = node;
4886
- const { sel, mode, ctor, owner } = vnode;
4887
- const vm = createVM(elm, ctor, {
4888
- mode,
4889
- owner,
4890
- tagName: sel,
4891
- });
4892
- vnode.elm = elm;
4893
- vnode.vm = vm;
4894
- allocateChildren(vnode, vm);
4895
- patchElementPropsAndAttrs(vnode);
4896
- // Insert hook section:
4897
- if (process.env.NODE_ENV !== 'production') {
4898
- shared.assert.isTrue(vm.state === 0 /* created */, `${vm} cannot be recycled.`);
4899
- }
4900
- runConnectedCallback(vm);
4901
- if (vm.renderMode !== 0 /* Light */) {
4902
- // VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
4903
- // Note: for Light DOM, this is handled while hydrating the VM
4904
- hydrateChildren(getChildNodes(vnode.elm), vnode.children, vm);
4905
- }
4906
- hydrateVM(vm);
4907
- }
4908
- function hydrateChildren(elmChildren, children, vm) {
4909
- if (process.env.NODE_ENV !== 'production') {
4910
- const filteredVNodes = shared.ArrayFilter.call(children, (vnode) => !!vnode);
4911
- if (elmChildren.length !== filteredVNodes.length) {
4912
- logError(`Hydration mismatch: incorrect number of rendered nodes, expected ${filteredVNodes.length} but found ${elmChildren.length}.`, vm);
4913
- throwHydrationError();
4914
- }
4915
- }
4916
- let childNodeIndex = 0;
4917
- for (let i = 0; i < children.length; i++) {
4918
- const childVnode = children[i];
4919
- if (!shared.isNull(childVnode)) {
4920
- const childNode = elmChildren[childNodeIndex];
4921
- hydrate(childVnode, childNode);
4922
- childNodeIndex++;
4923
- }
4924
- }
4925
- }
4926
- function patchElementPropsAndAttrs(vnode) {
4927
- applyEventListeners(vnode);
4928
- patchProps(null, vnode);
4929
- }
4930
- function throwHydrationError() {
4931
- shared.assert.fail('Server rendered elements do not match client side generated elements');
4932
- }
4933
- function validateNodeType(vnode, node, nodeType) {
4934
- if (getProperty(node, 'nodeType') !== nodeType) {
4935
- logError('Hydration mismatch: incorrect node type received', vnode.owner);
4936
- shared.assert.fail('Hydration mismatch: incorrect node type received.');
4937
- }
4938
- }
4939
- function validateElement(vnode, elm) {
4940
- if (vnode.sel.toLowerCase() !== getProperty(elm, 'tagName').toLowerCase()) {
4941
- logError(`Hydration mismatch: expecting element with tag "${vnode.sel.toLowerCase()}" but found "${getProperty(elm, 'tagName').toLowerCase()}".`, vnode.owner);
4942
- throwHydrationError();
4943
- }
4944
- const hasIncompatibleAttrs = validateAttrs(vnode, elm);
4945
- const hasIncompatibleClass = validateClassAttr(vnode, elm);
4946
- const hasIncompatibleStyle = validateStyleAttr(vnode, elm);
4947
- const isVNodeAndElementCompatible = hasIncompatibleAttrs && hasIncompatibleClass && hasIncompatibleStyle;
4948
- if (!isVNodeAndElementCompatible) {
4949
- throwHydrationError();
4950
- }
4951
- }
4952
- function validateAttrs(vnode, elm) {
4953
- const { data: { attrs = {} }, } = vnode;
4954
- let nodesAreCompatible = true;
4955
- // Validate attributes, though we could always recovery from those by running the update mods.
4956
- // Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
4957
- for (const [attrName, attrValue] of Object.entries(attrs)) {
4958
- const elmAttrValue = getAttribute(elm, attrName);
4959
- if (String(attrValue) !== elmAttrValue) {
4960
- logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "${attrName}" has different values, expected "${attrValue}" but found "${elmAttrValue}"`, vnode.owner);
4961
- nodesAreCompatible = false;
4962
- }
4963
- }
4964
- return nodesAreCompatible;
4965
- }
4966
- function validateClassAttr(vnode, elm) {
4967
- const { data: { className, classMap }, } = vnode;
4968
- let nodesAreCompatible = true;
4969
- let vnodeClassName;
4970
- if (!shared.isUndefined(className) && String(className) !== getProperty(elm, 'className')) {
4971
- // className is used when class is bound to an expr.
4972
- nodesAreCompatible = false;
4973
- vnodeClassName = className;
4974
- }
4975
- else if (!shared.isUndefined(classMap)) {
4976
- // classMap is used when class is set to static value.
4977
- const classList = getClassList(elm);
4978
- let computedClassName = '';
4979
- // all classes from the vnode should be in the element.classList
4980
- for (const name in classMap) {
4981
- computedClassName += ' ' + name;
4982
- if (!classList.contains(name)) {
4983
- nodesAreCompatible = false;
4984
- }
4985
- }
4986
- vnodeClassName = computedClassName.trim();
4987
- if (classList.length > shared.keys(classMap).length) {
4988
- nodesAreCompatible = false;
4989
- }
4990
- }
4991
- if (!nodesAreCompatible) {
4992
- logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "class" has different values, expected "${vnodeClassName}" but found "${getProperty(elm, 'className')}"`, vnode.owner);
4993
- }
4994
- return nodesAreCompatible;
4995
- }
4996
- function validateStyleAttr(vnode, elm) {
4997
- const { data: { style, styleDecls }, } = vnode;
4998
- const elmStyle = getAttribute(elm, 'style') || '';
4999
- let vnodeStyle;
5000
- let nodesAreCompatible = true;
5001
- if (!shared.isUndefined(style) && style !== elmStyle) {
5002
- nodesAreCompatible = false;
5003
- vnodeStyle = style;
5004
- }
5005
- else if (!shared.isUndefined(styleDecls)) {
5006
- const parsedVnodeStyle = parseStyleText(elmStyle);
5007
- const expectedStyle = [];
5008
- // styleMap is used when style is set to static value.
5009
- for (let i = 0, n = styleDecls.length; i < n; i++) {
5010
- const [prop, value, important] = styleDecls[i];
5011
- expectedStyle.push(`${prop}: ${value + (important ? ' important!' : '')}`);
5012
- const parsedPropValue = parsedVnodeStyle[prop];
5013
- if (shared.isUndefined(parsedPropValue)) {
5014
- nodesAreCompatible = false;
5015
- }
5016
- else if (!parsedPropValue.startsWith(value)) {
5017
- nodesAreCompatible = false;
5018
- }
5019
- else if (important && !parsedPropValue.endsWith('!important')) {
5020
- nodesAreCompatible = false;
5021
- }
5022
- }
5023
- if (shared.keys(parsedVnodeStyle).length > styleDecls.length) {
5024
- nodesAreCompatible = false;
5025
- }
5026
- vnodeStyle = shared.ArrayJoin.call(expectedStyle, ';');
5027
- }
5028
- if (!nodesAreCompatible) {
5029
- // style is used when class is bound to an expr.
5030
- logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "style" has different values, expected "${vnodeStyle}" but found "${elmStyle}".`, vnode.owner);
5031
- }
5032
- return nodesAreCompatible;
5033
- }
5034
-
5035
4805
  /*
5036
4806
  * Copyright (c) 2018, salesforce.com, inc.
5037
4807
  * All rights reserved.
@@ -5077,32 +4847,12 @@ function connectRootElement(elm) {
5077
4847
  /* GlobalHydrate */
5078
4848
  , vm);
5079
4849
  }
5080
- function hydrateRootElement(elm) {
5081
- const vm = getAssociatedVM(elm);
5082
- runConnectedCallback(vm);
5083
- hydrateVM(vm);
5084
- }
5085
4850
  function disconnectRootElement(elm) {
5086
4851
  const vm = getAssociatedVM(elm);
5087
4852
  resetComponentStateWhenRemoved(vm);
5088
4853
  }
5089
4854
  function appendVM(vm) {
5090
4855
  rehydrate(vm);
5091
- }
5092
- function hydrateVM(vm) {
5093
- if (shared.isTrue(vm.isDirty)) {
5094
- // manually diffing/patching here.
5095
- // This routine is:
5096
- // patchShadowRoot(vm, children);
5097
- // -> addVnodes.
5098
- const children = renderComponent(vm);
5099
- vm.children = children;
5100
- const vmChildren = vm.renderMode === 0
5101
- /* Light */
5102
- ? getChildNodes(vm.elm) : getChildNodes(vm.elm.shadowRoot);
5103
- hydrateChildren(vmChildren, children, vm);
5104
- runRenderedCallback(vm);
5105
- }
5106
4856
  } // just in case the component comes back, with this we guarantee re-rendering it
5107
4857
  // while preventing any attempt to rehydration until after reinsertion.
5108
4858
 
@@ -5407,7 +5157,6 @@ function runRenderedCallback(vm) {
5407
5157
  , vm);
5408
5158
  }
5409
5159
  }
5410
-
5411
5160
  let rehydrateQueue = [];
5412
5161
 
5413
5162
  function flushRehydrationQueue() {
@@ -6064,6 +5813,298 @@ function readonly(obj) {
6064
5813
  return reactiveMembrane.getReadOnlyProxy(obj);
6065
5814
  }
6066
5815
 
5816
+ /*
5817
+ * Copyright (c) 2022, salesforce.com, inc.
5818
+ * All rights reserved.
5819
+ * SPDX-License-Identifier: MIT
5820
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
5821
+ */
5822
+ // flag indicating if the hydration recovered from the DOM mismatch
5823
+ let hasMismatch = false;
5824
+ function hydrateRoot(vm) {
5825
+ hasMismatch = false;
5826
+ runConnectedCallback(vm);
5827
+ hydrateVM(vm);
5828
+ if (hasMismatch) {
5829
+ logError('Hydration completed with errors.', vm);
5830
+ }
5831
+ }
5832
+ function hydrateVM(vm) {
5833
+ const children = renderComponent(vm);
5834
+ vm.children = children;
5835
+ const parentNode = vm.renderRoot;
5836
+ hydrateChildren(getFirstChild(parentNode), children, parentNode, vm);
5837
+ runRenderedCallback(vm);
5838
+ }
5839
+ function hydrateNode(node, vnode) {
5840
+ let hydratedNode;
5841
+ switch (vnode.type) {
5842
+ case 0 /* Text */:
5843
+ hydratedNode = hydrateText(node, vnode);
5844
+ break;
5845
+ case 1 /* Comment */:
5846
+ hydratedNode = hydrateComment(node, vnode);
5847
+ break;
5848
+ case 2 /* Element */:
5849
+ hydratedNode = hydrateElement(node, vnode);
5850
+ break;
5851
+ case 3 /* CustomElement */:
5852
+ hydratedNode = hydrateCustomElement(node, vnode);
5853
+ break;
5854
+ }
5855
+ return nextSibling(hydratedNode);
5856
+ }
5857
+ function hydrateText(node, vnode) {
5858
+ var _a;
5859
+ if (!hasCorrectNodeType(vnode, node, 3 /* TEXT */)) {
5860
+ return handleMismatch(node, vnode);
5861
+ }
5862
+ if (process.env.NODE_ENV !== 'production') {
5863
+ const nodeValue = getProperty(node, 'nodeValue');
5864
+ if (nodeValue !== vnode.text && !(nodeValue === '\u200D' && vnode.text === '')) {
5865
+ logWarn('Hydration mismatch: text values do not match, will recover from the difference', vnode.owner);
5866
+ }
5867
+ }
5868
+ setText(node, (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
5869
+ vnode.elm = node;
5870
+ return node;
5871
+ }
5872
+ function hydrateComment(node, vnode) {
5873
+ var _a;
5874
+ if (!hasCorrectNodeType(vnode, node, 8 /* COMMENT */)) {
5875
+ return handleMismatch(node, vnode);
5876
+ }
5877
+ if (process.env.NODE_ENV !== 'production') {
5878
+ const nodeValue = getProperty(node, 'nodeValue');
5879
+ if (nodeValue !== vnode.text) {
5880
+ logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vnode.owner);
5881
+ }
5882
+ }
5883
+ setProperty(node, 'nodeValue', (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
5884
+ vnode.elm = node;
5885
+ return node;
5886
+ }
5887
+ function hydrateElement(elm, vnode) {
5888
+ if (!hasCorrectNodeType(vnode, elm, 1 /* ELEMENT */) ||
5889
+ !isMatchingElement(vnode, elm)) {
5890
+ return handleMismatch(elm, vnode);
5891
+ }
5892
+ vnode.elm = elm;
5893
+ const { context } = vnode.data;
5894
+ const isDomManual = Boolean(!shared.isUndefined(context) && !shared.isUndefined(context.lwc) && context.lwc.dom === "manual" /* Manual */);
5895
+ if (isDomManual) {
5896
+ // it may be that this element has lwc:inner-html, we need to diff and in case are the same,
5897
+ // remove the innerHTML from props so it reuses the existing dom elements.
5898
+ const { props } = vnode.data;
5899
+ if (!shared.isUndefined(props) && !shared.isUndefined(props.innerHTML)) {
5900
+ if (getProperty(elm, 'innerHTML') === props.innerHTML) {
5901
+ // Do a shallow clone since VNodeData may be shared across VNodes due to hoist optimization
5902
+ vnode.data = Object.assign(Object.assign({}, vnode.data), { props: cloneAndOmitKey(props, 'innerHTML') });
5903
+ }
5904
+ else {
5905
+ if (process.env.NODE_ENV !== 'production') {
5906
+ logWarn(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: innerHTML values do not match for element, will recover from the difference`, vnode.owner);
5907
+ }
5908
+ }
5909
+ }
5910
+ }
5911
+ patchElementPropsAndAttrs(vnode);
5912
+ if (!isDomManual) {
5913
+ hydrateChildren(getFirstChild(elm), vnode.children, elm, vnode.owner);
5914
+ }
5915
+ return elm;
5916
+ }
5917
+ function hydrateCustomElement(elm, vnode) {
5918
+ if (!hasCorrectNodeType(vnode, elm, 1 /* ELEMENT */) ||
5919
+ !isMatchingElement(vnode, elm)) {
5920
+ return handleMismatch(elm, vnode);
5921
+ }
5922
+ const { sel, mode, ctor, owner } = vnode;
5923
+ const vm = createVM(elm, ctor, {
5924
+ mode,
5925
+ owner,
5926
+ tagName: sel,
5927
+ });
5928
+ vnode.elm = elm;
5929
+ vnode.vm = vm;
5930
+ allocateChildren(vnode, vm);
5931
+ patchElementPropsAndAttrs(vnode);
5932
+ // Insert hook section:
5933
+ if (process.env.NODE_ENV !== 'production') {
5934
+ shared.assert.isTrue(vm.state === 0 /* created */, `${vm} cannot be recycled.`);
5935
+ }
5936
+ runConnectedCallback(vm);
5937
+ if (vm.renderMode !== 0 /* Light */) {
5938
+ // VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
5939
+ // Note: for Light DOM, this is handled while hydrating the VM
5940
+ hydrateChildren(getFirstChild(elm), vnode.children, elm, vm);
5941
+ }
5942
+ hydrateVM(vm);
5943
+ return elm;
5944
+ }
5945
+ function hydrateChildren(node, children, parentNode, owner) {
5946
+ let hasWarned = false;
5947
+ let nextNode = node;
5948
+ let anchor = null;
5949
+ for (let i = 0; i < children.length; i++) {
5950
+ const childVnode = children[i];
5951
+ if (!shared.isNull(childVnode)) {
5952
+ if (nextNode) {
5953
+ nextNode = hydrateNode(nextNode, childVnode);
5954
+ anchor = childVnode.elm;
5955
+ }
5956
+ else {
5957
+ hasMismatch = true;
5958
+ if (process.env.NODE_ENV !== 'production') {
5959
+ if (!hasWarned) {
5960
+ hasWarned = true;
5961
+ logError(`Hydration mismatch: incorrect number of rendered nodes. Client produced more nodes than the server.`, owner);
5962
+ }
5963
+ }
5964
+ mount(childVnode, parentNode, anchor);
5965
+ anchor = childVnode.elm;
5966
+ }
5967
+ }
5968
+ }
5969
+ if (nextNode) {
5970
+ hasMismatch = true;
5971
+ if (process.env.NODE_ENV !== 'production') {
5972
+ if (!hasWarned) {
5973
+ logError(`Hydration mismatch: incorrect number of rendered nodes. Server rendered more nodes than the client.`, owner);
5974
+ }
5975
+ }
5976
+ do {
5977
+ const current = nextNode;
5978
+ nextNode = nextSibling(nextNode);
5979
+ removeNode(current, parentNode);
5980
+ } while (nextNode);
5981
+ }
5982
+ }
5983
+ function handleMismatch(node, vnode, msg) {
5984
+ hasMismatch = true;
5985
+ if (!shared.isUndefined(msg)) {
5986
+ if (process.env.NODE_ENV !== 'production') {
5987
+ logError(msg, vnode.owner);
5988
+ }
5989
+ }
5990
+ const parentNode = getProperty(node, 'parentNode');
5991
+ mount(vnode, parentNode, node);
5992
+ removeNode(node, parentNode);
5993
+ return vnode.elm;
5994
+ }
5995
+ function patchElementPropsAndAttrs(vnode) {
5996
+ applyEventListeners(vnode);
5997
+ patchProps(null, vnode);
5998
+ }
5999
+ function hasCorrectNodeType(vnode, node, nodeType) {
6000
+ if (getProperty(node, 'nodeType') !== nodeType) {
6001
+ if (process.env.NODE_ENV !== 'production') {
6002
+ logError('Hydration mismatch: incorrect node type received', vnode.owner);
6003
+ }
6004
+ return false;
6005
+ }
6006
+ return true;
6007
+ }
6008
+ function isMatchingElement(vnode, elm) {
6009
+ if (vnode.sel.toLowerCase() !== getProperty(elm, 'tagName').toLowerCase()) {
6010
+ if (process.env.NODE_ENV !== 'production') {
6011
+ logError(`Hydration mismatch: expecting element with tag "${vnode.sel.toLowerCase()}" but found "${getProperty(elm, 'tagName').toLowerCase()}".`, vnode.owner);
6012
+ }
6013
+ return false;
6014
+ }
6015
+ const hasIncompatibleAttrs = validateAttrs(vnode, elm);
6016
+ const hasIncompatibleClass = validateClassAttr(vnode, elm);
6017
+ const hasIncompatibleStyle = validateStyleAttr(vnode, elm);
6018
+ return hasIncompatibleAttrs && hasIncompatibleClass && hasIncompatibleStyle;
6019
+ }
6020
+ function validateAttrs(vnode, elm) {
6021
+ const { data: { attrs = {} }, } = vnode;
6022
+ let nodesAreCompatible = true;
6023
+ // Validate attributes, though we could always recovery from those by running the update mods.
6024
+ // Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
6025
+ for (const [attrName, attrValue] of Object.entries(attrs)) {
6026
+ const elmAttrValue = getAttribute(elm, attrName);
6027
+ if (String(attrValue) !== elmAttrValue) {
6028
+ if (process.env.NODE_ENV !== 'production') {
6029
+ logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "${attrName}" has different values, expected "${attrValue}" but found "${elmAttrValue}"`, vnode.owner);
6030
+ }
6031
+ nodesAreCompatible = false;
6032
+ }
6033
+ }
6034
+ return nodesAreCompatible;
6035
+ }
6036
+ function validateClassAttr(vnode, elm) {
6037
+ const { data: { className, classMap }, } = vnode;
6038
+ let nodesAreCompatible = true;
6039
+ let vnodeClassName;
6040
+ if (!shared.isUndefined(className) && String(className) !== getProperty(elm, 'className')) {
6041
+ // className is used when class is bound to an expr.
6042
+ nodesAreCompatible = false;
6043
+ vnodeClassName = className;
6044
+ }
6045
+ else if (!shared.isUndefined(classMap)) {
6046
+ // classMap is used when class is set to static value.
6047
+ const classList = getClassList(elm);
6048
+ let computedClassName = '';
6049
+ // all classes from the vnode should be in the element.classList
6050
+ for (const name in classMap) {
6051
+ computedClassName += ' ' + name;
6052
+ if (!classList.contains(name)) {
6053
+ nodesAreCompatible = false;
6054
+ }
6055
+ }
6056
+ vnodeClassName = computedClassName.trim();
6057
+ if (classList.length > shared.keys(classMap).length) {
6058
+ nodesAreCompatible = false;
6059
+ }
6060
+ }
6061
+ if (!nodesAreCompatible) {
6062
+ if (process.env.NODE_ENV !== 'production') {
6063
+ logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "class" has different values, expected "${vnodeClassName}" but found "${getProperty(elm, 'className')}"`, vnode.owner);
6064
+ }
6065
+ }
6066
+ return nodesAreCompatible;
6067
+ }
6068
+ function validateStyleAttr(vnode, elm) {
6069
+ const { data: { style, styleDecls }, } = vnode;
6070
+ const elmStyle = getAttribute(elm, 'style') || '';
6071
+ let vnodeStyle;
6072
+ let nodesAreCompatible = true;
6073
+ if (!shared.isUndefined(style) && style !== elmStyle) {
6074
+ nodesAreCompatible = false;
6075
+ vnodeStyle = style;
6076
+ }
6077
+ else if (!shared.isUndefined(styleDecls)) {
6078
+ const parsedVnodeStyle = parseStyleText(elmStyle);
6079
+ const expectedStyle = [];
6080
+ // styleMap is used when style is set to static value.
6081
+ for (let i = 0, n = styleDecls.length; i < n; i++) {
6082
+ const [prop, value, important] = styleDecls[i];
6083
+ expectedStyle.push(`${prop}: ${value + (important ? ' important!' : '')}`);
6084
+ const parsedPropValue = parsedVnodeStyle[prop];
6085
+ if (shared.isUndefined(parsedPropValue)) {
6086
+ nodesAreCompatible = false;
6087
+ }
6088
+ else if (!parsedPropValue.startsWith(value)) {
6089
+ nodesAreCompatible = false;
6090
+ }
6091
+ else if (important && !parsedPropValue.endsWith('!important')) {
6092
+ nodesAreCompatible = false;
6093
+ }
6094
+ }
6095
+ if (shared.keys(parsedVnodeStyle).length > styleDecls.length) {
6096
+ nodesAreCompatible = false;
6097
+ }
6098
+ vnodeStyle = shared.ArrayJoin.call(expectedStyle, ';');
6099
+ }
6100
+ if (!nodesAreCompatible) {
6101
+ if (process.env.NODE_ENV !== 'production') {
6102
+ logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "style" has different values, expected "${vnodeStyle}" but found "${elmStyle}".`, vnode.owner);
6103
+ }
6104
+ }
6105
+ return nodesAreCompatible;
6106
+ }
6107
+
6067
6108
  /*
6068
6109
  * Copyright (c) 2018, salesforce.com, inc.
6069
6110
  * All rights reserved.
@@ -6096,7 +6137,7 @@ exports.getAssociatedVMIfPresent = getAssociatedVMIfPresent;
6096
6137
  exports.getComponentDef = getComponentDef;
6097
6138
  exports.getComponentHtmlPrototype = getComponentHtmlPrototype;
6098
6139
  exports.getUpgradableConstructor = getUpgradableConstructor;
6099
- exports.hydrateRootElement = hydrateRootElement;
6140
+ exports.hydrateRoot = hydrateRoot;
6100
6141
  exports.isComponentConstructor = isComponentConstructor;
6101
6142
  exports.readonly = readonly;
6102
6143
  exports.register = register;
@@ -6151,4 +6192,4 @@ exports.swapTemplate = swapTemplate;
6151
6192
  exports.track = track;
6152
6193
  exports.unwrap = unwrap;
6153
6194
  exports.wire = wire;
6154
- /* version: 2.11.1 */
6195
+ /* version: 2.11.3-238prod.0 */