lib/hatemile/implementation/accessible_navigation_implementation.rb
##
# Generate an anchor for the element.
#
# @param element [Hatemile::Util::Html::HTMLDOMElement] The element.
# @param data_attribute [String] The name of attribute that links the
#   element with the anchor.
# @param anchor_class [String] The HTML class of anchor.
# @return [Hatemile::Util::Html::HTMLDOMElement] The anchor.
Generate an anchor for the element.
Generate an anchor for the element .
def generate_anchor_for(element, data_attribute, anchor_class)
        @id_generator.generate_id(element)
        anchor = nil
        if @parser.find(
          "[#{data_attribute}=\"#{element.get_attribute('id')}\"]"
        ).first_result.nil?
          if element.get_tag_name == 'A'
            anchor = element
          else
            anchor = @parser.create_element('a')
            @id_generator.generate_id(anchor)
            anchor.set_attribute('class', anchor_class)
            element.insert_before(anchor)
          end
          unless anchor.has_attribute?('name')
            anchor.set_attribute('name', anchor.get_attribute('id'))
          end
          anchor.set_attribute(data_attribute, element.get_attribute('id'))
        end
        anchor
      end
def generate_anchor_for ( element , data_attribute , anchor_class ) @id_generator . generate_id ( element ) anchor = nil if @parser . find ( "[#{data_attribute}=\"#{element.get_attribute('id')}\"]" ) . first_result . nil? if element . get_tag_name == 'A' anchor = element else anchor = @parser . create_element ( 'a' ) @id_generator . generate_id ( anchor ) anchor . set_attribute ( 'class' , anchor_class ) element . insert_before ( anchor ) end unless anchor . has_attribute? ( 'name' ) anchor . set_attribute ( 'name' , anchor . get_attribute ( 'id' ) ) end anchor . set_attribute ( data_attribute , element . get_attribute ( 'id' ) ) end anchor end
Generate an anchor for the element.
Generate an anchor for the element .
None
Hatemile::Util::Html::HTMLDOMElement
element
None
data_attribute
The name of attribute that links the element with the anchor.
The name of attribute that links the element with the anchor .
anchor_class
The HTML class of anchor.
The HTML class of anchor .