diff --git a/packages/happy-dom/src/dom-token-list/DOMTokenList.ts b/packages/happy-dom/src/dom-token-list/DOMTokenList.ts index c5d4aa5a9..a36a24102 100644 --- a/packages/happy-dom/src/dom-token-list/DOMTokenList.ts +++ b/packages/happy-dom/src/dom-token-list/DOMTokenList.ts @@ -224,7 +224,7 @@ export default class DOMTokenList implements IDOMTokenList { } // It is possible to make this statement shorter by using Array.from() and Set, but this is faster when comparing using a bench test. const list = []; - for (const item of attr.split(ATTRIBUTE_SPLIT_REGEXP)) { + for (const item of attr.trim().split(ATTRIBUTE_SPLIT_REGEXP)) { if (!list.includes(item)) { list.push(item); }