Skip to content

Commit

Permalink
chore: [#1609] Replace startsWith with the equal sign
Browse files Browse the repository at this point in the history
  • Loading branch information
btea authored Nov 13, 2024
1 parent b35bcd6 commit 23f8673
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion packages/happy-dom/src/css/utilities/CSSParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion packages/happy-dom/src/query-selector/SelectorItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion packages/happy-dom/src/query-selector/SelectorParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down

0 comments on commit 23f8673

Please sign in to comment.