1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-01-08 16:30:26 +00:00

fix: addClass may cause class pad with space, cause test to fail

This commit is contained in:
linonetwo 2024-10-03 23:14:11 +08:00
parent a19ace31a9
commit 6557017d4e

View File

@ -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(" "));