diff --git a/packages/runtime-core/src/componentRenderUtils.ts b/packages/runtime-core/src/componentRenderUtils.ts index 6b3be672792..8738da5660f 100644 --- a/packages/runtime-core/src/componentRenderUtils.ts +++ b/packages/runtime-core/src/componentRenderUtils.ts @@ -64,6 +64,13 @@ export function renderComponentRoot( result = normalizeVNode( instance.render!.call(proxyToUse, proxyToUse, renderCache) ) + // root node should inherit class/style in component tag and patch + if (vnode.patchFlag & PatchFlags.CLASS) { + result.patchFlag |= PatchFlags.CLASS + } + if (vnode.patchFlag & PatchFlags.STYLE) { + result.patchFlag |= PatchFlags.STYLE + } } else { // functional const render = Component as FunctionalComponent @@ -183,7 +190,7 @@ export function shouldUpdateComponent( return hasPropsChanged(prevProps!, nextProps!) } else { if (patchFlag & PatchFlags.CLASS) { - return prevProps!.class === nextProps!.class + return prevProps!.class !== nextProps!.class } if (patchFlag & PatchFlags.STYLE) { return hasPropsChanged(prevProps!.style, nextProps!.style)