runem / web-component-analyzer

CLI that analyzes web components and emits documentation
https://runem.github.io/web-component-analyzer
MIT License
507 stars 65 forks source link

Attribute-property matching is too strict #183

Open cifkao opened 4 years ago

cifkao commented 4 years ago

Matching attributes to properties should be case-insensitive and ignore hyphens to support kebab-cased attributes.

Code:

export class MyElement extends HTMLElement {
  static get observedAttributes() { return ['my-attribute']; }
  get myAttribute() {
    return this.getAttribute('my-attribute');
  }
  set myAttribute(value) {
    return this.setAttribute('my-attribute', value);
  }
}
window.customElements.define('my-element', MyElement);

Output:

## Attributes

| Attribute      |
|----------------|
| `my-attribute` |

## Properties

| Property      | Type             |
|---------------|------------------|
| `myAttribute` | `string \| null` |

Expected output:

## Properties

| Property      | Attribute      | Type             |
|---------------|----------------|------------------|
| `myAttribute` | `my-attribute` | `string \| null` |