Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support pseudo-elements #48

Merged
merged 1 commit into from
Dec 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion lib/style-transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@
var inGlobal = false
var inSubSelector = false
var inQuotes = false
var inPseudo = false
var quoteChar = null

for (var k = 0; k < selector.length; k++) {
Expand Down Expand Up @@ -254,6 +255,14 @@
piece += chr
continue
}
} else if (inPseudo) {
if (' ' === chr) {
inPseudo = false
_line += piece + ' '
piece = ''
} else {
piece += chr
}
} else {
// potential beginning of :global()
if (chr === ':'
Expand All @@ -272,6 +281,11 @@
_line += piece + suffix + ' '
piece = ''
}
} else if (chr === ':') {
// pseudo-class or preudo-element
_line += piece + suffix
piece = chr
inPseudo = true
} else {
piece += chr
}
Expand All @@ -282,7 +296,10 @@

// flush remainder
if (piece.length) {
_line += piece + suffix
_line += piece
if (!inPseudo) {
_line += suffix
}
}

if (isLast) {
Expand Down
20 changes: 20 additions & 0 deletions test/fixtures/transform.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,26 @@ p, h1 {
animation-delay: 100ms;
}

p:hover {
color: red;
}

p::before {
color: red;
}

:hover {
color: red;
}

::before {
color: red;
}

:hover p {
color: red;
}

@keyframes hahaha {
from { top: 0 }
to { top: 100 }
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/transform.out.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.