Skip to content

iAPI: Add official support for unique IDs #70880

@luisherranz

Description

@luisherranz

What problem does this address?

Since HTML doesn't allow adding multiple attributes with the same name to a single element, yet multiple plugins might need to add directives of the same type, we need a standardized way to assign unique IDs to directives. This would ensure consistency across all directives.

What is your proposed solution?

Based on the conversation in the discussion Differentiating between suffixes and unique-ids in the directive names, we could use a triple-dash to differentiate the suffixes from the unique-ids.

  • data-wp-watch--unique-id -> data-wp-watch---unique-id
  • data-wp-init--unique-id -> data-wp-init---unique-id
  • data-wp-on--suffix--unique-id -> data-wp-on--suffix---unique-id

There are directives that do not need unique IDs, since they affect a single item, and therefore, if more than one directive tries to control it, that could cause problems. Examples:

  • data-wp-style--prop
  • data-wp-class--classname
  • data-wp-text
  • data-wp-bind--attr

For these cases, it is preferable that the conflict is resolved on the server by whatever PHP code is trying to modify that HTML tag. So it has to be an optional choice per directive, not something global.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions