From 9cfafc30b569ddca0916199df43f0b804a4b0a0d Mon Sep 17 00:00:00 2001 From: Pierre Paridans Date: Tue, 6 Jul 2021 10:39:51 +0200 Subject: [PATCH] [IMP] vdom: performance improvement Port from original snabbdom project: snabbdom/snabbdom#634 The issue is that before this commit, the removeClass method was sometimes called even if it is not useful. See this comment for more detail: https://github.com/snabbdom/snabbdom/issues/633#issue-618706258 --- src/vdom/modules.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/vdom/modules.ts b/src/vdom/modules.ts index 413e9f24..27535492 100644 --- a/src/vdom/modules.ts +++ b/src/vdom/modules.ts @@ -231,7 +231,8 @@ function updateClass(oldVnode: VNode, vnode: VNode): void { elm = vnode.elm as Element; for (name in oldClass) { - if (name && !klass[name]) { + if (name && !klass[name] && !Object.prototype.hasOwnProperty.call(klass, name)) { + // was `true` and now not provided elm.classList.remove(name); } }