linkedom
linkedom copied to clipboard
HTMLTemplateElement toString does not include contents
https://github.com/WebReflection/linkedom/blob/ec5ce8470c50fe2e9ea6e8b339e6ee4f23077c73/esm/html/template-element.js#L19
I see that this related issue is marked as closed https://github.com/WebReflection/linkedom/issues/21
But later modifications removed this functionality
I am using this hack locally to get the functionality I need
const originaltoString = Object.getOwnPropertyDescriptor(Element.prototype, 'toString')!
Object.defineProperties(HTMLTemplateElement.prototype, {
toString: {
value() {
return (
originaltoString.value
.call(this)
.replace(/<\/template>$/, this.content.childNodes.join('')) + '</template>'
)
},
},
})
the test works though ... I am not sure when/where/how you are having issues ... can you share a minimal broken example code instead of your fix? thanks!