An error is thrown in resetCounter when adding an counter-reset inline style to an element in combination with a different style (e.g., in head).
1) juice-content/counter-reset:
Uncaught TypeError: Cannot set properties of undefined (setting 'li')
at resetCounter (lib/inline.js:167:40)
at addProps (lib/inline.js:198:15)
at Element.<anonymous> (lib/inline.js:146:11)
at LoadedCheerio.each (node_modules/cheerio/lib/api/traversing.js:519:26)
at handleRule (lib/inline.js:120:9)
at Array.forEach (<anonymous>)
at inlineDocument (lib/inline.js:36:9)
at juiceDocument (lib/inline.js:459:3)
at module.exports (lib/cheerio.js:61:22)
at onInline (index.js:63:7)
at /Users/.../juice/node_modules/web-resource-inliner/src/html.js:281:13
This error is caused by the fact that the addProps method is called when an element doesn't have styleProps (in the if (!el.styleProps) { block), before a default value for counterProps is set. This is fixed by assigning a default value for counterProps before calling addProps.
A test case is also added to reproduce the issue and to prevent future regressions.
An error is thrown in
resetCounter
when adding ancounter-reset
inline style to an element in combination with a different style (e.g., in head).This error is caused by the fact that the
addProps
method is called when an element doesn't havestyleProps
(in theif (!el.styleProps) {
block), before a default value forcounterProps
is set. This is fixed by assigning a default value forcounterProps
before callingaddProps
.A test case is also added to reproduce the issue and to prevent future regressions.