VanillaJS means only using web components without any framework / shell in pure JS.
You need to register your custom element, cross out the element and take care of data binding.
Both x-tagand Polymerprovide convenient and stubborn shell around the web components, greatly reducing the template code.
IMHO Polymer ( , ..)
x-tag:
xtag.register('x-accordion', {
extends: 'div',
lifecycle:{
created: function(){
},
inserted: function(){
},
removed: function(){
},
attributeChanged: function(){
}
},
events: {
'click:delegate(x-toggler)': function(){
}
},
accessors: {
'togglers': {
get: function(){
},
set: function(value){
}
}
},
methods: {
nextToggler: function(){
},
previousToggler: function(){
}
}
});
Polymer:
<polymer-element name="polymer-accordion" extends="div" on-click="{{toggle}}">
<template>
</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>