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

Commit

Permalink
Release v0.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeno Rocha committed Apr 26, 2014
1 parent c261eb2 commit abe4bee
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hello-world-xtag",
"version": "0.1.0",
"version": "0.1.1",
"description": "Web Component example using X-Tag",
"authors": [
"WebComponents.org"
Expand Down
60 changes: 60 additions & 0 deletions dist/hello-world.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<!-- 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/hello-world.html
var thisDoc = document._currentScript.ownerDocument;

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

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

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

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

// 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);
</script>

0 comments on commit abe4bee

Please sign in to comment.