web-component-analyzer icon indicating copy to clipboard operation
web-component-analyzer copied to clipboard

Polymer analyzer: add event parsing when a property is defined with notify true

Open jpradelle opened this issue 3 years ago • 0 comments

Analysis of Polymer custom components doesn't report Polymer events of properties with notify: true attribute.

This pull request adds it according to documentation: https://polymer-library.polymer-project.org/3.0/docs/devguide/data-system#change-events

Example of analyzed source
import {PolymerElement, html} from '@polymer/polymer/polymer-element';

/**
 * @polymer
 *
 * @fires test-event {CustomEvent<{foo: string}>} - Demo test event
 */
export class PolymerTest extends PolymerElement {
  static get properties() {
    return {
      fooBar: {
        type: String,
        notify: true
      },

      testType: {
        type: String
      }
    };
  }

  static get template() {
    return html`
      <p>Hello</p>
    `;
  }
}

customElements.define('polymer-test', PolymerTest);
Markdown result with pull request code

polymer-test

Events

Event Type Description
foo-bar-changed CustomEvent<{value: *, path: ?string}> Fired when the fooBar property changes
test-event CustomEvent<{foo: string}> Demo test event
Markdown result without pull request code

Events

Event Type Description
test-event CustomEvent<{foo: string}> Demo test event

jpradelle avatar Dec 07 '22 17:12 jpradelle