Skip to content

Feature Request: Support Arrays values in DOMTokenList-style #892

Description

@myabc

Stimulus currently provides an Array-type for values. However it is encoded as JSON, which while necessary for complex objects, feels un-HTML-like for simple arrays of strings. At a practical level, it means extra care has to be made to escape values.

DOMTokenList is used in many places in Web APIs, such as classList and aria-described-by attributes. Ideally we would mimic that.

  static values = {
    permittedTypes: 'List' // or possibly DOMTokenList
  }

  connect() {
    this.permittedTypesValue.forEach((permittedType) => {
       console.log(permiitedType);
    });
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions