Skip to content

Commit

Permalink
capricorn86#1168@trivial: Merge replace() and split().
Browse files Browse the repository at this point in the history
* String.prototype.split() accepts RegExp.
* RegExp's g flag is ignored in split() so that g flag was removed.
  • Loading branch information
takenspc committed Nov 28, 2023
1 parent 5824775 commit 1f5a301
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions packages/happy-dom/src/dom-token-list/DOMTokenList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,7 @@ export default class DOMTokenList implements IDOMTokenList {
private _getTokenList(): string[] {
let attr = this._ownerElement.getAttribute(this._attributeName) ?? '';
attr = attr.replace(/^[\t\n\f\r ]+|[\t\n\f\r ]+$/g, '');
attr = attr.replace(/[\t\n\f\r ]+/g, ' ');
return attr === '' ? [] : Array.from(new Set(attr.split(' ')));
return attr === '' ? [] : Array.from(new Set(attr.split(/[\t\n\f\r ]+/)));
}

/**
Expand Down

0 comments on commit 1f5a301

Please sign in to comment.