Skip to content

Instantly share code, notes, and snippets.

Last active February 28, 2016 02:31
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
From Zero to Polymer: Step 03 - HTML import
<!DOCTYPE html>
<html lang="en">
<link rel="import" href="my-element.html">
<!-- my-element.html -->
<template id="my-element-template">
<p>My <b>custom element</b> markup!</p>
// thisDoc refers to the "importee", which is my-element.html
var thisDoc = document.currentScript.ownerDocument;
// thatDoc refers to the "importer", which is index.html
var thatDoc = document;
var MyElementProto = Object.create(HTMLElement.prototype);
MyElementProto.createdCallback = function() {
var t = thisDoc.querySelector('#my-element-template');
var clone = thisDoc.importNode(t.content, true);
var MyElement = thatDoc.registerElement(
'my-element', { prototype: MyElementProto }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment