Support v1 Custom Element syntax

27 views
Skip to first unread message

Bruce Anderson

unread,
May 30, 2016, 4:45:50 PM5/30/16
to Polymer
Are there plans to add an adapter (or something), so that one can define a polymer component using as much of the V1 custom spec as possible?  Something like:


<dom-module id="flag-icon">
 
<template>
   
<div>Country Code: [[CountryCode]]</div>
</template>
</dom>




<script>

class FlagIcon extends HTMLElement {
  constructor
() {
   
super();
   
this._countryCode = null;
 
}

 
static get observedAttributes() { return ["country"]; }

  attributeChangedCallback
(name, oldValue, newValue) {
   
// name will always be "country" due to observedAttributes
   
this._countryCode = newValue;
   
this._updateRendering();
 
}
  connectedCallback
() {
   
this._updateRendering();
 
}

 
get country() {
   
return this._countryCode;
 
}
 
set country(v) {
   
this.setAttribute("country", v);
 
}
}

Polymer.registerV1CustomElement(FlagIcon)




</script>


Reply all
Reply to author
Forward
0 new messages