From 6557017d4e8b9e51fb86a0017b5fd37310e01655 Mon Sep 17 00:00:00 2001 From: linonetwo Date: Thu, 3 Oct 2024 23:14:11 +0800 Subject: [PATCH] fix: addClass may cause class pad with space, cause test to fail --- core/modules/utils/dom/dom.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/modules/utils/dom/dom.js b/core/modules/utils/dom/dom.js index 0b71e128c..2037fd37b 100644 --- a/core/modules/utils/dom/dom.js +++ b/core/modules/utils/dom/dom.js @@ -57,7 +57,8 @@ exports.hasClass = function(el,className) { }; exports.addClass = function(el,className) { - var c = (el.getAttribute("class") || "").split(" "); + var classAttr = el.getAttribute("class") || ""; + var c = classAttr.trim() ? classAttr.split(" ") : []; if(c.indexOf(className) === -1) { c.push(className); el.setAttribute("class",c.join(" "));