Skip to content
This repository has been archived by the owner on Jul 26, 2022. It is now read-only.

Commit

Permalink
Release v0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeno Rocha committed Apr 26, 2014
1 parent c34f7c6 commit 2180ace
Showing 1 changed file with 20 additions and 55 deletions.
75 changes: 20 additions & 55 deletions dist/my-element.html
Original file line number Diff line number Diff line change
@@ -1,60 +1,25 @@
<!-- Import X-Tag -->
<script src="../../x-tag-core/src/core.js"></script>

<template>
<p>Hello <strong></strong></p>
</template>

<script>
(function(window, document, undefined) {
// Refers to the "importer", which is index.html
var thatDoc = document;

// Refers to the "importee", which is src/my-element.html
var thisDoc = document._currentScript.ownerDocument;

// Gets content from <template>
var template = thisDoc.querySelector('template').content;

xtag.register('my-element', {
lifecycle: {
created: function() {
// Caches <strong> DOM query
this.strong = template.querySelector('strong');

// Creates the shadow root
this.shadowRoot = this.createShadowRoot();

this.uiSetName();
},
attributeChanged: function() {
this.uiSetName();
}
},
accessors: {
name: {
attribute: {},
get: function(){
return this.getAttribute('name') || "World"
},
set: function(value){
this.xtag.data.name = value;
}
}
},
methods: {
uiSetName: function() {
// Sets name value into <strong>
this.strong.textContent = this.name;

// Removes shadow root content
this.shadowRoot.innerHTML = '';

// Adds a template clone into shadow root
var clone = thatDoc.importNode(template, true);
this.shadowRoot.appendChild(clone);
}
}
});
})(window, document);
(function() {
xtag.register('my-element', {
lifecycle: {
// Fires when an instance of the element is created
created: function() {},

// Fires when an instance was inserted into the document
inserted: function() {},

// Fires when an instance was removed from the document
removed: function() {},

// Fires when an attribute was added, removed, or updated
attributeChanged: function(attr, oldVal, newVal) {}
},
events: {},
accessors: {},
methods: {}
});
}());
</script>

0 comments on commit 2180ace

Please sign in to comment.