Skip to content

DOMStringMap::get and DOMStringMap::set should work with hyphens and numbers #448

@g105b

Description

@g105b

When dealing with DOMStringMap, for example when working with data-* attributes, it's possible to use the non-standard get and set functions, that have been added to enhance testability of the library, but also to avoid using dynamic object properties.

The get and set functions are direct mappers to accessing the __get and __set magic methods to set dynamic properties as described in the HTMLElement.dataset documentation.

However, the documentation states the following:

  1. Multiple words within attributes should be split using hyphens, like data-example-attribute.
  2. Multiple words within object properties should be camel-cased, like dataExampleAttribute.

Camel case properties are automatically corrected to hyphen case, but if they're provided as hyphen case they are not converted back to camel case, which causes issues when doing things like $element->dataset->get("example-attribute"));

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNon-breaking improvements to existing behaviourgood first issueSuitable starting point for new contributorshelp wantedExtra input or contributions needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions