Skip to content

Commit

Permalink
Merge pull request #460 from SimonBackx/fixed-counter-reset
Browse files Browse the repository at this point in the history
Fixed counter-reset not working in combination with inline styles
  • Loading branch information
jrit authored May 6, 2023
2 parents 56a996a + 169739a commit a9d920f
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/inline.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ function inlineDocument($, css, options) {
return;
}

if (!el.counterProps) {
el.counterProps = el.parent && el.parent.counterProps
? Object.create(el.parent.counterProps)
: {};
}

if (pseudoElementType) {
var pseudoElPropName = 'pseudo' + pseudoElementType;
var pseudoEl = el[pseudoElPropName];
Expand All @@ -150,12 +156,6 @@ function inlineDocument($, css, options) {
editedElements.push(el);
}

if (!el.counterProps) {
el.counterProps = el.parent && el.parent.counterProps
? Object.create(el.parent.counterProps)
: {};
}

function resetCounter(el, value) {
var tokens = value.split(/\s+/);

Expand Down
Empty file.
12 changes: 12 additions & 0 deletions test/cases/juice-content/counter-reset.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<html>
<head>
<style>
p {
color: red;
}
</style>
</head>
<body>
<p style="counter-reset: li;">Cool!</p>
</body>
</html>
4 changes: 4 additions & 0 deletions test/cases/juice-content/counter-reset.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"removeStyleTags": true,
"inlinePseudoElements": true
}
8 changes: 8 additions & 0 deletions test/cases/juice-content/counter-reset.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<html>
<head>

</head>
<body>
<p style="color: red; counter-reset: li;">Cool!</p>
</body>
</html>

0 comments on commit a9d920f

Please sign in to comment.