From 22a9fe48db88e4f3271394a64e54cc7c84dc5c69 Mon Sep 17 00:00:00 2001 From: Shahar Dawn Or Date: Mon, 25 May 2020 14:24:14 +0700 Subject: [PATCH] perf(class): prevent redundant calls to classList.remove (#634) Fixes #633. Co-authored-by: Simon Friis Vindum --- src/modules/class.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/modules/class.ts b/src/modules/class.ts index 3f3499f..da881da 100755 --- a/src/modules/class.ts +++ b/src/modules/class.ts @@ -16,7 +16,11 @@ function updateClass (oldVnode: VNode, vnode: VNode): void { klass = klass || {} for (name in oldClass) { - if (!klass[name]) { + if ( + oldClass[name] && + !Object.prototype.hasOwnProperty.call(klass, name) + ) { + // was `true` and now not provided elm.classList.remove(name) } }