<template> tags, cloneNode and importNode

I’'ve started using web components (without Polymer or any other framework).
I had not come across the importNode method before getting into web components. Its basically cloneNode but for a node from an external document (like an iframe).
One tutorial on using template tags uses cloneNode rather than importNode.
My question: Is a template seen as an ‘external’ document, even when it is within the body of a HTML document? Is the tutorial wrong? In other cases I’ve always seen importNode. Why is importNode better in this case?

Hi @0llieW,

That’s an interesting question. I did a little research to see if I could find out what the difference is, but as far as I can tell it’s historical - in modern browsers there doesn’t seem to be any different between using cloneNode or importNode in this case.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.