Closed dgp1130 closed 1 year ago
I'm afraid I don't think this lib will do the same behavior as browser on this.
template
on browser is a special element, we cannot do this now, because this lib is just a html passing tool, and , we suspect it will be fast.
node-html-parser
seems to render text from<template />
tags in thetextContent
property of child elements:This is contrary to browsers where
<template />
elements are ignored.I'm using
DOMParser
for the example here, but doing the same thing on this actual DOM in a browser has the same output.Two nuances here to keep in mind:
<template />
tag. Note that the correct output isHello, World
because there was a space prior to the<template />
. This is also true withHello, <template></template> World!
, where all the whitespace is retained.<template shadowrootmode="open">Hello!</template>
. The behavior here is awkward, since in the browser you'd never actually observe this in the real DOM, since it would get converted into a real shadow root. Shadow roots are printed withtextContent
, but it's an open question whether that would be the intuitive behavior here. Personally, I think this should be interpreted as a shadow root and included intextContent
, but I can see others disagreeing with me.I'm on
node-html-parser@6.1.5
, which is the current latest.