I know there is this question on multiple inheritance/composition. However, it seems like this question is more about how to reuse functionality from multiple existing eleme
If you need to have just a single import that has support for being applied to multiple elements, your element could include multiple element definitions which may or may not take advantage of Polymer.mixin
in order to share functionality between your decorating elements.
So pascal-decorator.html
could contain Polymer element definitions for <pascal-span>
and <pascal-button>
, both of which mixin logic from some object defined within pascal-decorator.html
. You can then do <button is="pascal-button">
and <button is="pascal-span">
whilst the logic for doing so remains inside the same import.
The alternative (if you strictly want to do this all in one custom element, which imo, makes this less clean) is to do something like checking against the type of element being extended, which could either be done in the manner you linked to or by checking as part of your element registration process.
In general, I personally prefer to figure out what logic I may need to share between elements that could be decorated, isolate that functionality into an element and then just import them into dedicated elements that have knowledge about the tag (e.g <addy-button>
, <addy-video>
etc).