fix(runtime-core): handle component updates with only class/style bindings

This commit is contained in:
Evan You 2020-02-13 17:27:52 -05:00
parent c6a9787941
commit 35d91f4e18

View File

@ -172,12 +172,20 @@ export function shouldUpdateComponent(
if (patchFlag & PatchFlags.FULL_PROPS) { if (patchFlag & PatchFlags.FULL_PROPS) {
// presence of this flag indicates props are always non-null // presence of this flag indicates props are always non-null
return hasPropsChanged(prevProps!, nextProps!) return hasPropsChanged(prevProps!, nextProps!)
} else if (patchFlag & PatchFlags.PROPS) { } else {
const dynamicProps = nextVNode.dynamicProps! if (patchFlag & PatchFlags.CLASS) {
for (let i = 0; i < dynamicProps.length; i++) { return prevProps!.class === nextProps!.class
const key = dynamicProps[i] }
if (nextProps![key] !== prevProps![key]) { if (patchFlag & PatchFlags.STYLE) {
return true return hasPropsChanged(prevProps!.style, nextProps!.style)
}
if (patchFlag & PatchFlags.PROPS) {
const dynamicProps = nextVNode.dynamicProps!
for (let i = 0; i < dynamicProps.length; i++) {
const key = dynamicProps[i]
if (nextProps![key] !== prevProps![key]) {
return true
}
} }
} }
} }