Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
brainfood
/
astro-wt
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
e01f913d
authored
2024-11-07 18:12:12 -0600
by
Adam Heath
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Add pseudo-element after/before handling; this is not actually used yet
during rendering anywhere.
1 parent
124aa3c4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
1 deletions
lib/html.ts
lib/html.ts
View file @
e01f913
...
...
@@ -37,7 +37,8 @@ const nthChildPos = (node, parent) => filterChildElements(parent).findIndex((chi
const
filterChildElementsMatcher
=
(
context
,
child
,
parent
,
i
)
=>
child
.
type
===
ELEMENT_NODE
type
Matcher
=
(
context
,
node
:
NodeType
,
parent
?:
NodeType
,
i
:
number
,
debug
:
number
)
=>
boolean
type
NodePosition
=
number
|
'before'
|
'after'
type
Matcher
=
(
context
,
node
:
NodeType
,
parent
?:
NodeType
,
i
:
NodePosition
,
debug
:
number
)
=>
boolean
type
MatcherProducer
=
()
=>
Matcher
type
AttrValueMatch
=
(
string
)
=>
string
...
...
@@ -295,6 +296,16 @@ const compileMatcher = (ast: AST, selector: string): MatcherProducer => {
}
case
'universal'
:
return
(
context
,
node
,
parent
,
i
,
debug
)
=>
true
case
'pseudo-element'
:
switch
(
ast
.
name
)
{
case
'after'
:
return
(
context
,
node
,
parent
,
i
,
debug
)
=>
i
===
'after'
case
'before'
:
return
(
context
,
node
,
parent
,
i
,
debug
)
=>
i
===
'before'
default
:
console
.
error
(
'pseudo-class'
,
nodeUtil
.
inspect
({
selector
,
ast
},
{
depth
:
null
,
colors
:
true
}))
throw
new
Error
(
`Unknown pseudo-class:
${
ast
.
name
}
`
)
}
default
:
throw
new
Error
(
`Unhandled ast:
${
ast
.
type
}
`
)
}
...
...
Please
register
or
sign in
to post a comment