Comments (5)
This is correct behavior. The template element's content property is a
documentFragment reflection of the current contents of the template tag.
This needs documentation, can you or Arron take a look at adding something
to our docs that talks about how this works? (see the spec on W3)
On Sep 25, 2013 4:54 AM, "sole" [email protected] wrote:
There's a mention to elements in the latest blog post:
But no example. I have tried doing this:
This is just a test.and
xtag.register('test-thing', {
lifecycle: {
created: function() {
var tpl = document.getElementById('testTemplate').content;
this.innerHTML = tpl.cloneNode(true);
}
}});
var thing = document.createElement('test-thing');document.body.appendChild(thing);but I just get a big [object DocumentFragment] string instead of the
content I expected. I feel like there should be an easier way to do this
with X-Tag but I just haven't found it...—
Reply to this email directly or view it on GitHubhttps://github.com//issues/33
.
from core.
I'd love to add the documentation but I don't know how to do that! (I mean using template with x-tag). Correct what I did and I can update the docs :-)
Or @pennyfx please help --I think this went off his radar 📻
from core.
xtag.register('test-thing', {
lifecycle: {
created: function() {
while(this.lastChild){
this.removeChild(this.lastChild);
}
this.appendChild(document.getElementById('testTemplate').content.cloneNode(true));
}
}
});
var thing = document.createElement('test-thing');
document.body.appendChild(thing);
In the example above, you don't really need the while loop because the element is empty to begin with. I'm not sure an element ever has children at the 'created' moment of its lifecycle.
from core.
I added a blurb about the template. http://www.x-tags.org/docs#template
from core.
Ahh, the trick was to appendChild
the cloned template contents. Makes sense--adding it as innerHTML
was actually converting it to a string.
Thank you for adding the blurb, however although it's "almost there", I don't think it's obvious enough that you can use it for building components; I've tried to expand the docs with an example. Have a look at this PR: x-tag/x-tags-org#13
from core.
Related Issues (20)
- this.innerHTML in V2 throws recursion error. HOT 33
- enhancement question HOT 4
- this.outerHTML is undefined HOT 5
- Setter on attr camel cases doesn't set the proper dashed attribute value. HOT 6
- Using setAttribute is unstable HOT 3
- Is this project still supported? Are any additional releases planned? HOT 1
- template attr from last commit
- v2 docs Pseudos versus Jasmine tests
- include information about ie9 -ie11 compat HOT 3
- experimenting with type renders
- Ability to define placeholder for inner HTML HOT 3
- V1 lifecycle compatibility HOT 4
- Website :: Clock not operating properly on safari mobile HOT 4
- IDEA: V1 FINAL PATCH HOT 4
- XTagElement is not defined HOT 3
- Issues @ x-tag.github.io/docs
- package.json needs to be updated HOT 2
- lit-element? I'm confused :/
- Migration guide || equivalents of inserted/...? HOT 1
- Status of project HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from core.