admin管理员组文章数量:1429905
can any one give me some idea about difference between polymer,x-tag and vanilla js ?
I have used polymer in my project, but i want parison of polymer,x-tag and vanilla js.
can any one give me some idea about difference between polymer,x-tag and vanilla js ?
I have used polymer in my project, but i want parison of polymer,x-tag and vanilla js.
Share Improve this question asked Jun 30, 2014 at 9:38 Nirav AlagiyaNirav Alagiya 7221 gold badge5 silver badges19 bronze badges 2- Did you tried to google? – Java_User Commented Jun 30, 2014 at 9:39
- @Java_User Yes, i have tried but don't get any clear parison. Thanks for reply. – Nirav Alagiya Commented Jun 30, 2014 at 9:44
2 Answers
Reset to default 5VanillaJS only means using web-ponents without any framework/wrapper in pure JS.
You have to register your custom-element, stamping out the element and taking care of data-binding yourself.
Both x-tag
and Polymer
provide a convenient and opinionated wrapper around web-ponents that greatly reduce boilerplate code.
IMHO the Polymer
library provides the most declerative approach (regarding data-binding, defining templates, etc)
This is how it looks like with x-tag:
xtag.register('x-accordion', {
// extend existing elements
extends: 'div',
lifecycle:{
created: function(){
// fired once at the time a ponent
// is initially created or parsed
},
inserted: function(){
// fired each time a ponent
// is inserted into the DOM
},
removed: function(){
// fired each time an element
// is removed from DOM
},
attributeChanged: function(){
// fired when attributes are set
}
},
events: {
'click:delegate(x-toggler)': function(){
// activate a clicked toggler
}
},
accessors: {
'togglers': {
get: function(){
// return all toggler children
},
set: function(value){
// set the toggler children
}
}
},
methods: {
nextToggler: function(){
// activate the next toggler
},
previousToggler: function(){
// activate the previous toggler
}
}
});
This is how it would look like with Polymer:
<polymer-element name="polymer-accordion" extends="div" on-click="{{toggle}}">
<template>
<!-- shadow DOM here -->
</template>
<script>
Polymer('polymer-accordion' {
created: function() { ... },
ready: function() { ... },
attached: function () { ... },
domReady: function() { ... },
detached: function() { ... },
attributeChanged: function(attrName, oldVal, newVal) {
},
toggle : function() {....},
get togglers() {},
set togglers(value) {},
nextToggler : function() {},
previousToggler : function() {},
});
</script>
</polymer-element>
Web Components is the native implementation in the browsers. Polymer is a library that act as a very thin layer on top of the Web Components technologies. X-Tag is another library that is even thinner because it only relies on one of the four Web Components technologies.
I've written an article about that: http://pascalprecht.github.io/2014/07/21/polymer-vs-x-tag-here-is-the-difference/
本文标签: javascriptcomparison between polymer and xtag and vanilla jsStack Overflow
版权声明:本文标题:javascript - comparison between polymer and x-tag and vanilla js - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744599450a2614980.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论