Sha256: 4a061c2883fe8e80a99378c5d319d706575e02da4f64d862b70eed9729da2d90
Contents?: true
Size: 714 Bytes
Versions: 54
Compression:
Stored size: 714 Bytes
Contents
# frozen_string_literal: true module Alchemy # Returns a dom id used for elements html id tag. # # Uses the elements name and its position on the page. # If the element is nested in a parent element it prefixes # the id with the parent elements dom_id. # # Register your own dom id class with # # Alchemy::Element.dom_id_class = MyDomIdClass # class Element < BaseRecord class DomId def initialize(element) @element = element @parent_element = element.parent_element end def call [parent_element&.dom_id, element.name, element.position].compact.join("-") end private attr_reader :element, :parent_element end end end
Version data entries
54 entries across 54 versions & 1 rubygems