HTML <pattern> is empty in Firefox (devtools and after document.importNode ())

I would like to use html templates. Using Chrome everything works, but in Firefox the template element has no content ... maybe it just doesn't appear in Debugger, but when I try to instantiate the contents of the template, I also don't get any content.

This template element:

...
<body>
    <template>qwertz</template>
</body>
...

has no content (I expect "qwertz") when I check an item in the Firefox debugger. It seems pretty simple ... but unfortunately I don’t see what I am missing here ...

+4
source share
1 answer

Firefoxs devtools Inspector template DOM.

template Firefox Inspector, :

  • template .
  • DOM.

Firefox devtools "", DOM template.

, template, innerHTML content.


DOM View <template> element


, , :

var templateContent = document.querySelector("template").content,
    templateContentClone = document.importNode(templateContent, true)
document.body.appendChild(templateContentClone)
<!doctype html>
<body>
  <template>qwertz</template>
</body>

, - , / , Document.importNode() Node.cloneNode().

+4

Source: https://habr.com/ru/post/1674139/


All Articles