hotwired / hotwired/stimulus

Feature Request: Support Arrays values in `DOMTokenList`-style

Open
#892 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
13.1k
Forks
441
PR merge metrics
No merged PRs in 30d

Description

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);
    });
  }

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file or test is named in the issue. Start with Stimulus's existing Array value documentation at reference/values#types and compare the requested behavior with the DOMTokenList reference; done means a documented value type supports simple string arrays without JSON-style encoding.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.