Module: HTMLAttributesUtils

Defined in:
lib/html_attributes_utils.rb

Constant Summary collapse

DEFAULT_MERGEABLE_ATTRIBUTES =

DEFAULT_MERGEABLE_ATTRIBUTES is a list of HTML attributes where the value contain multiple elements separated by spaces. We use it to target values to split so the arrays can be cleanly merged.

They are stored as nested arrays so when we’re walking multiple levels on the deep merge the structure can be identified. This means the library works with the Rails-preferred format of ‘aria: { describedby: “xyz” }` rather than `“aria-describdby” => “xyz”`

[
  %i(class),
  %i(aria controls),
  %i(aria describedby),
  %i(aria flowto),
  %i(aria labelledby),
  %i(data aria_controls),
  %i(aria owns),
  %i(rel),
].freeze