Module: Dommy::HyperlinkActivation
- Included in:
- HTMLAnchorElement, HTMLAreaElement
- Defined in:
- lib/dommy/html_elements.rb
Overview
<a> — exposes URL-component getters/setters via the href
attribute, plus reflected target / download / rel / type.
Follow-the-hyperlink activation behavior shared by and . A
non-canceled click on a hyperlink (with an href, no download attribute)
navigates to its resolved URL: a same-document fragment change fires
hashchange and updates :target; anything else is handed to the navigation
delegate (which performs the real navigation, or records it by default).
Instance Method Summary collapse
Instance Method Details
#activation_behavior(_event) ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/dommy/html_elements.rb', line 106 def activation_behavior(_event) return unless has_attribute?("href") # download turns the click into a save, not a navigation — out of scope. return if has_attribute?("download") target = anchor_href win = @document&.default_view return if target.to_s.empty? || win.nil? || win.location.nil? # A cross-document link hands off to the delegate without pre-mutating the # location; a same-document fragment still updates the hash + :target. win.location.__internal_navigate_to__(target, source: :link, sync_cross_doc: false) end |
#activation_target? ⇒ Boolean
102 103 104 |
# File 'lib/dommy/html_elements.rb', line 102 def activation_target? has_attribute?("href") end |