cleanPseudoContent: Add null check for 'el'
Error happens during h1 {string-set: headline content(text);}
, causing pagedjs chunker to crash.
Message:
Uncaught (in promise) TypeError: Cannot read property 'replace' of undefined
at cleanPseudoContent (paged.polyfill.js:29120)
at StringSets.afterPageLayout (paged.polyfill.js:29225)
at paged.polyfill.js:360
at Array.forEach (<anonymous>)
at Hook.trigger (paged.polyfill.js:359)
at Chunker.layout (paged.polyfill.js:2519)
at async Chunker.renderAsync (paged.polyfill.js:2440)
Possible fix /Workaround:
function cleanPseudoContent(el, trim = "\"' ") {
>> if(el == null) return;
return el
.replace(new RegExp(`^[${trim}]+`), "")
.replace(new RegExp(`[${trim}]+$`), "")
.replace(/["']/g, match => {
return "\\" + match;
})
.replace(/[\n]/g, match => {
return "\\00000A";
});
}