diff --git a/packages/happy-dom/src/cookie/urilities/CookieStringUtility.ts b/packages/happy-dom/src/cookie/urilities/CookieStringUtility.ts index 11409bfca..c7d90faec 100644 --- a/packages/happy-dom/src/cookie/urilities/CookieStringUtility.ts +++ b/packages/happy-dom/src/cookie/urilities/CookieStringUtility.ts @@ -57,7 +57,7 @@ export default class CookieStringUtility { cookie.domain = value; break; case 'path': - cookie.path = value.startsWith('/') ? value : `/${value}`; + cookie.path = value[0] === '/' ? value : `/${value}`; break; case 'httponly': cookie.httpOnly = true; diff --git a/packages/happy-dom/src/css/utilities/CSSParser.ts b/packages/happy-dom/src/css/utilities/CSSParser.ts index c8b31baab..c9f474a4c 100644 --- a/packages/happy-dom/src/css/utilities/CSSParser.ts +++ b/packages/happy-dom/src/css/utilities/CSSParser.ts @@ -88,7 +88,7 @@ export default class CSSParser { newRule.parentStyleSheet = parentStyleSheet; cssRules.push(newRule); parentRule = newRule; - } else if (selectorText.startsWith('@')) { + } else if (selectorText[0] === '@') { // Unknown rule. // We will create a new rule to let it grab its content, but we will not add it to the cssRules array. const newRule = new CSSRule(PropertySymbol.illegalConstructor, window); diff --git a/packages/happy-dom/src/nodes/html-hyperlink-element/HTMLHyperlinkElementUtility.ts b/packages/happy-dom/src/nodes/html-hyperlink-element/HTMLHyperlinkElementUtility.ts index f5f85e3a4..a923e0f03 100644 --- a/packages/happy-dom/src/nodes/html-hyperlink-element/HTMLHyperlinkElementUtility.ts +++ b/packages/happy-dom/src/nodes/html-hyperlink-element/HTMLHyperlinkElementUtility.ts @@ -299,7 +299,7 @@ export default class HTMLHyperlinkElementUtility { */ public getHash(): string { const href = this.element.getAttribute('href'); - if (href.startsWith('#')) { + if (href[0] === '#') { return href; } let url: URL; diff --git a/packages/happy-dom/src/query-selector/SelectorItem.ts b/packages/happy-dom/src/query-selector/SelectorItem.ts index 5c407543b..81b7cdf1f 100644 --- a/packages/happy-dom/src/query-selector/SelectorItem.ts +++ b/packages/happy-dom/src/query-selector/SelectorItem.ts @@ -330,7 +330,7 @@ export default class SelectorItem { return null; case 'has': let priorityWeightForHas = 0; - if (pseudo.arguments.startsWith('+')) { + if (pseudo.arguments[0] === '+') { const nextSibling = element.nextElementSibling; if (!nextSibling) { return null; diff --git a/packages/happy-dom/src/query-selector/SelectorParser.ts b/packages/happy-dom/src/query-selector/SelectorParser.ts index eb960dcd1..88590a45f 100644 --- a/packages/happy-dom/src/query-selector/SelectorParser.ts +++ b/packages/happy-dom/src/query-selector/SelectorParser.ts @@ -329,7 +329,7 @@ export default class SelectorParser { // The ":has()" pseudo selector doesn't allow for it to be nested inside another ":has()" pseudo selector, as it can lead to cyclic querying. if (!args.includes(':has(')) { for (const group of this.getSelectorGroups( - args.startsWith('+') ? args.replace('+', '') : args, + args[0] === '+' ? args.replace('+', '') : args, options )) { hasSelectorItems.push(group[0]);