PolymerElements / iron-component-page

A reusable landing page for elements
36 stars 32 forks source link

Polymer 2.0 Element is not working with iron-component-page #117

Closed phani1kumar closed 7 years ago

phani1kumar commented 7 years ago

Description

Created a polymer 2.0 component using polymer init 2-x-el this generator I've got from https://www.npmjs.com/package/generator-polymer-init-2-x-el

After creating the element, changed the ../polymer/polymer.html to ../polymer/polymer-element.html

Ran polymer serve

Expected outcome

The new blank element template is shown. But it fails with "No documentation found"

Actual outcome

"No documentation found" is displayed

Steps to reproduce

  1. create a new polymer 2 element using polymer init 2-x-el
  2. run polymer serve.
  3. browse the url /components/kkk-homepage.html custom-element from the components re-mapped url. -->

Browsers Affected

tony19 commented 7 years ago

It seems the iron-component-page currently does not parse custom elements that are defined with class expressions like this:

customElements.define('my-element', class extends Polymer.Element {
  static get is() { return 'my-element'; }

  static get config() {
    return {
      properties: {
        prop1: {
          type: String,
          value: 'my-element'
        }
      }
    };
  }
});

Rewriting it as a class declaration (as shown below) allows the iron-component-page to parse the docs for the element. iron-component-page still does not parse the docs for the properties declared in config().

class MyElement extends Polymer.Element {
  static get is() { return 'my-element'; }

  static get config() {
    return {
      properties: {
        prop1: {
          type: String,
          value: 'my-element'
        }
      }
    };
  }
}
customElements.define(MyElement.is, MyElement);
phani1kumar commented 7 years ago

Thank you @tony19 , I tested this and it works fine. Apologies for a late response on this one.