Skip to content

Commit a9d920f

Browse files
authored
Merge pull request #460 from SimonBackx/fixed-counter-reset
Fixed counter-reset not working in combination with inline styles
2 parents 56a996a + 169739a commit a9d920f

File tree

5 files changed

+30
-6
lines changed

5 files changed

+30
-6
lines changed

lib/inline.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ function inlineDocument($, css, options) {
124124
return;
125125
}
126126

127+
if (!el.counterProps) {
128+
el.counterProps = el.parent && el.parent.counterProps
129+
? Object.create(el.parent.counterProps)
130+
: {};
131+
}
132+
127133
if (pseudoElementType) {
128134
var pseudoElPropName = 'pseudo' + pseudoElementType;
129135
var pseudoEl = el[pseudoElPropName];
@@ -150,12 +156,6 @@ function inlineDocument($, css, options) {
150156
editedElements.push(el);
151157
}
152158

153-
if (!el.counterProps) {
154-
el.counterProps = el.parent && el.parent.counterProps
155-
? Object.create(el.parent.counterProps)
156-
: {};
157-
}
158-
159159
function resetCounter(el, value) {
160160
var tokens = value.split(/\s+/);
161161

test/cases/juice-content/counter-reset.css

Whitespace-only changes.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<html>
2+
<head>
3+
<style>
4+
p {
5+
color: red;
6+
}
7+
</style>
8+
</head>
9+
<body>
10+
<p style="counter-reset: li;">Cool!</p>
11+
</body>
12+
</html>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"removeStyleTags": true,
3+
"inlinePseudoElements": true
4+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<html>
2+
<head>
3+
4+
</head>
5+
<body>
6+
<p style="color: red; counter-reset: li;">Cool!</p>
7+
</body>
8+
</html>

0 commit comments

Comments
 (0)