Polymer 2.0 has a compatibility level that still supports the old Polymer function syntax. Most preview 2.0 elements, if not all, still retain the old syntax. Violation of changes is mainly associated with dom-module markup.
If you are creating new elements, it is recommended that you move on to class-based syntax. If, however, you transfer 1.0 elements to 2.0 and these elements rely on Polymer behavior, I donβt think you have a choice at this point, but to preserve the old syntax.
In class-based syntax, you can freely model multiple inheritance of mixins class elements with something like this
let Mixin = (superclass) => new MixinBuilder(superclass); class MixinBuilder { constructor(superclass) { this.superclass = superclass; } with(...mixins) { return mixins.reduce((c, mixin) => mixin(c), this.superclass); } } const MyMixin = subclass => class extends subclass { _test(){ } } const MyMixinTwo = subclass => class extends subclass { _testTwo(){ } } class MyElement extends Mixin(Polymer.Element).with(MyMixin,MyMixin2) { static get is() { return 'my-element' } }
You can split MixinBuilder into your own file, and then reference it as an HTML import dependency when creating elements using mixins.
tachyon1337
source share