tools: Vulcanize doesn't understand ES6 class-based declarations that use `beforeRegister` to set `is`

It seems that vulcanize is currently not correctly finding out the name (the is attribute) of the Polymer elements definition written as an ES6/ES2015 Class. When multiple elements definition as classes are present we get the following error/warning printed for each additional elements:

Ignoring duplicate element definition: undefined

Below is the minimal source file to replicate the issue:

my-element.html

<html>
<head>
  <link rel="import" href="bower_components/polymer/polymer.html">
</head>
<body>
<dom-module id="my-element">
  <template>
    <div>Hello World</div>
  </template>

</dom-module>
<script>
  class MyElement {
    beforeRegister() {
      this.is = 'my-element';
    }
  }
  Polymer(MyElement);

  class MyElement2 {
    beforeRegister() {
      this.is = 'my-element-2';
    }
  }
  Polymer(MyElement2);

  class MyElement3 {
    beforeRegister() {
      this.is = 'my-element-3';
    }
  }
  Polymer(MyElement3);
</script>
</body>
</html>

Then run vulcanize my-element.html > /dev/null and you’ll get the following output on the console:

Ignoring duplicate element definition: undefined
Ignoring duplicate element definition: undefined

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 19 (9 by maintainers)

Most upvoted comments

@mtsgrd Still not fixed apparently 😃 You can work around it since typically you’d need to transpile your ES6 code to ES5 with Babel.js to obtain large browser support. And ES5 code is not impacted.