Skip to content

Commit 7f450cb

Browse files
authored
fix: isPseudoElement() supports :first-letter and :first-line (#256)
1 parent 5c71f29 commit 7f450cb

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/__tests__/guards.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ test('pseudo element guard', '::first-line', (t, tree) => {
7979
t.false(parser.isNamespace(n));
8080
});
8181

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

92-
test('special pseudo element guard (uppercase)', ':BEFORE:AFTER', (t, tree) => {
93-
[node(tree), node(tree, 1)].forEach((n) => {
92+
test('special pseudo element guard (uppercase)', ':BEFORE:AFTER:FIRST-LETTER:FIRST-LINE', (t, tree) => {
93+
[node(tree), node(tree, 1), node(tree, 2), node(tree, 3)].forEach((n) => {
9494
t.true(parser.isPseudo(n));
9595
t.false(parser.isPseudoClass(n));
9696
t.true(parser.isPseudoElement(n));

src/selectors/guards.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ export function isPseudoElement (node) {
5656
node.value.startsWith("::")
5757
|| node.value.toLowerCase() === ":before"
5858
|| node.value.toLowerCase() === ":after"
59+
|| node.value.toLowerCase() === ":first-letter"
60+
|| node.value.toLowerCase() === ":first-line"
5961
);
6062
}
6163
export function isPseudoClass (node) {

0 commit comments

Comments
 (0)