Skip to content

Commit

Permalink
fix: typing for static element comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
jhefferman-sfdc committed Jan 3, 2025
1 parent 9c74f88 commit bfe4c54
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions packages/@lwc/engine-core/src/framework/hydration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ function hydrateStaticElement(elm: Node, vnode: VStatic, renderer: RendererAPI):
if (
isTypeElement(elm) &&
isTypeElement(vnode.fragment) &&
areStaticNodesCompatible(vnode.fragment, elm, vnode, renderer)
areStaticElementsCompatible(vnode.fragment, elm, vnode, renderer)
) {
return hydrateStaticElementParts(elm, vnode, renderer);
}
Expand Down Expand Up @@ -729,30 +729,30 @@ function validateStyleAttr(
return nodesAreCompatible;
}

function areStaticNodesCompatible(
clientNode: Node,
serverNode: Node,
function areStaticElementsCompatible(
clientElement: Element,
serverElement: Element,
vnode: VStatic,
renderer: RendererAPI
) {
const { getProperty, getAttribute } = renderer;
const { parts } = vnode;
let isCompatibleElements = true;

if (getProperty(clientNode, 'tagName') !== getProperty(serverNode, 'tagName')) {
if (getProperty(clientElement, 'tagName') !== getProperty(serverElement, 'tagName')) {
if (process.env.NODE_ENV !== 'production') {
queueHydrationError('node', serverNode);
queueHydrationError('node', serverElement);
}
return false;
}

const clientAttrsNames: string[] = getProperty(clientNode, 'getAttributeNames').call(
clientNode
const clientAttrsNames: string[] = getProperty(clientElement, 'getAttributeNames').call(
clientElement
);

clientAttrsNames.forEach((attrName) => {
const clientAttributeValue = getAttribute(clientNode, attrName);
const serverAttributeValue = getAttribute(serverNode, attrName);
const clientAttributeValue = getAttribute(clientElement, attrName);
const serverAttributeValue = getAttribute(serverElement, attrName);
if (clientAttributeValue !== serverAttributeValue) {
// Check if the root element attributes have expressions, if it does then we need to delegate hydration
// validation to haveCompatibleStaticParts.
Expand Down

0 comments on commit bfe4c54

Please sign in to comment.