Skip to content

Instantly share code, notes, and snippets.

@tareko
Created March 10, 2017 11:25
Show Gist options
  • Save tareko/62fd670a88e2a75fce518c39b4c83e78 to your computer and use it in GitHub Desktop.
Save tareko/62fd670a88e2a75fce518c39b4c83e78 to your computer and use it in GitHub Desktop.
HTML5 import
<html>
<head>
<script src="//cdnjs.cloudflare.com/ajax/libs/polymer/0.3.3/platform.js"></script>
<link rel="import" href="messages.html"/>
</head>
<body>
<h2>title</h2>
<script>
alert("document "+document);
var htmlImport = document.querySelector('link[rel="import"]');
var htmlDoc = htmlImport.import;
alert("htmlDoc "+htmlDoc);
var htmlMessage = htmlDoc.querySelector('.message-success');
alert("htmlMessage "+htmlMessage);
document.body.appendChild(htmlMessage.cloneNode(true));
</script>
<p>end</p>
<a href="messages.html">messages</a>
</body>
</html>
<html>
<body>
<div class="message-success">
<h2>Success</h2>
</div>
<div class="message-failure">
<h2>Failure</h2>
</div>
</body>
</html>
@petermr
Copy link

petermr commented Mar 10, 2017

Thanks,
My expectation was that the snippet

<div class="message-success">
      <h2>Success</h2>
</div>

would be included in the document for base.html after the <body> element

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment