Skip to content

Commit

Permalink
fix: isPseudoElement() supports :first-letter and :first-line (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ybiquitous authored Mar 30, 2022
1 parent 5c71f29 commit 7f450cb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/__tests__/guards.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ test('pseudo element guard', '::first-line', (t, tree) => {
t.false(parser.isNamespace(n));
});

test('special pseudo element guard', ':before:after', (t, tree) => {
[node(tree), node(tree, 1)].forEach((n) => {
test('special pseudo element guard', ':before:after:first-letter:first-line', (t, tree) => {
[node(tree), node(tree, 1), node(tree, 2), node(tree, 3)].forEach((n) => {
t.true(parser.isPseudo(n));
t.false(parser.isPseudoClass(n));
t.true(parser.isPseudoElement(n));
Expand All @@ -89,8 +89,8 @@ test('special pseudo element guard', ':before:after', (t, tree) => {
});
});

test('special pseudo element guard (uppercase)', ':BEFORE:AFTER', (t, tree) => {
[node(tree), node(tree, 1)].forEach((n) => {
test('special pseudo element guard (uppercase)', ':BEFORE:AFTER:FIRST-LETTER:FIRST-LINE', (t, tree) => {
[node(tree), node(tree, 1), node(tree, 2), node(tree, 3)].forEach((n) => {
t.true(parser.isPseudo(n));
t.false(parser.isPseudoClass(n));
t.true(parser.isPseudoElement(n));
Expand Down
2 changes: 2 additions & 0 deletions src/selectors/guards.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ export function isPseudoElement (node) {
node.value.startsWith("::")
|| node.value.toLowerCase() === ":before"
|| node.value.toLowerCase() === ":after"
|| node.value.toLowerCase() === ":first-letter"
|| node.value.toLowerCase() === ":first-line"
);
}
export function isPseudoClass (node) {
Expand Down

0 comments on commit 7f450cb

Please sign in to comment.