jsdom / jsdom

A JavaScript implementation of various web standards, for use with Node.js

Repository from Github https://github.comjsdom/jsdomRepository from Github https://github.comjsdom/jsdom

error when use jsdom to parse tag template

nkbai opened this issue · comments

wrong case:

    it('test template', () => {
        const dom = new JSDOM(`
<templatex name="taro_tmpl">
  <block >
    <template is="tmpl_0_container" />
  </block>
</templatex>

<templatex name="tmpl_0_catch-view">
    <block >
      <templatex is="tmpl_0_container" />
    </block>
</templatex>
`, {contentType: "text/html"});
        const payButton = dom.window.document.querySelector("templatex");
        console.log("content=", payButton.innerHTML)
    })

the output content=

      <block>
        <template is="tmpl_0_container">
      
    
    
    <templatex name="tmpl_0_catch-view">
        <block>
          <templatex is="tmpl_0_container">
        </templatex></block>
    </templatex>
    </template></block>

output meet expect case:

    it('test templatex', () => {
        const dom = new JSDOM(`
<templatex name="taro_tmpl">
  <block >
    <templatex is="tmpl_0_container" />
  </block>
</templatex>

<templatex name="tmpl_0_catch-view">
    <block >
      <templatex is="tmpl_0_container" />
    </block>
</templatex>
`, {contentType: "text/html"});
        const payButton = dom.window.document.querySelector("templatex");
        console.log("content=", payButton.innerHTML)
    })

the output content=

<block>
        <templatex is="tmpl_0_container">
      </templatex></block>

I want to know why the tag template affect the content, and how to get the correct innerHTML content when we are using the tag template.

Unfortunately this issue does not follow the format required by our issue template, and so we cannot help with it. Please feel free to edit it to follow the format, importantly including not using any third-party libraries that declare global functions like it and also testing the same code in a web browser, and then reply to the thread and we might be able to help.