Buslowicz / twc

TypeScript based, boilerplate-less, Polymer toolbox friendly Polymer Modules
32 stars 1 forks source link

Extending HTML elements #37

Closed tpluscode closed 7 years ago

tpluscode commented 7 years ago

Polymer-TS comes with the @extend annotation used to extend native elements. TWC should support something similar

@extend('button')
export class FancyButton { }

to produce

<dom-module id="fancy-button">
  <script>
    Polymer({
      is: "fancy-button",
      extends: 'button'
    });
  </script>
</dom-module>
Buslowicz commented 7 years ago

Due to ability to compile to both Polymer v1 and Polymer v2 (coming soon), and v2 does not support type extensions. Due to this, it will not be possible to extend native elements until Polymer v2 does that. More info here: https://www.polymer-project.org/2.0/docs/upgrade

I will add that to readme as well :).

tpluscode commented 7 years ago

Oh, you're right. I keep forgetting that is="" is now deprecated.

Composition over inheritance is the way to go!