open-wc / custom-elements-manifest

Custom Elements Manifest is a file format that describes custom elements in your project.
https://custom-elements-manifest.open-wc.org/
243 stars 45 forks source link

ignored variables in `@property` decorator #283

Open scottnath opened 2 weeks ago

scottnath commented 2 weeks ago

When using a variable to declare an attribute of a property, the variable is ignored.

playground reproduction

this class:

import { LitElement } from 'lit-element';

const meow = 'meow-meow'

export class MyElement extends LitElement {
  static get properties() {
    return {
      fooFoo: { type: String, attribute: 'foo-foo' },
      meowMeow: { type: String, attribute: meow }
    }
  }
  ...

Ends up with these attributes:

  "attributes": [
    {
      "name": "foo-foo",
      "type": {
        "text": "string"
      },
      "fieldName": "fooFoo"
    },
    {
      "name": "meowMeow",
      "type": {
        "text": "string"
      },
      "fieldName": "meowMeow"
    }
  ],

Expected behavior

The variable should be processed to get the correct name of the attribute:

  "attributes": [
    {
      "name": "foo-foo",
      "type": {
        "text": "string"
      },
      "fieldName": "fooFoo"
    },
    {
      "name": "meow-meow",
      "type": {
        "text": "string"
      },
      "fieldName": "meowMeow"
    }
  ],

thanks for any help, Scott