From e5299554d0849bf1e009c2fa29f4310c38787188 Mon Sep 17 00:00:00 2001 From: yushangjiang <504427021@qq.com> Date: Wed, 26 Feb 2020 23:01:53 +0800 Subject: [PATCH 1/2] fix(componentRenderUtils): a wrong judge in shouldUpdateComponent (#677) --- packages/runtime-core/src/componentRenderUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/runtime-core/src/componentRenderUtils.ts b/packages/runtime-core/src/componentRenderUtils.ts index 6b3be672792..b7646d72a8b 100644 --- a/packages/runtime-core/src/componentRenderUtils.ts +++ b/packages/runtime-core/src/componentRenderUtils.ts @@ -183,7 +183,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) From a88c2c8a23b6a63d4ecfa406ec7c0cf48bf3ae7b Mon Sep 17 00:00:00 2001 From: yushangjiang <504427021@qq.com> Date: Thu, 27 Feb 2020 21:37:57 +0800 Subject: [PATCH 2/2] fix(componentRenderUtils): keep component root's patch flag the same as component-tag (#677) --- packages/runtime-core/src/componentRenderUtils.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/runtime-core/src/componentRenderUtils.ts b/packages/runtime-core/src/componentRenderUtils.ts index b7646d72a8b..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