Module: Dommy::HyperlinkActivation

Included in:
HTMLAnchorElement, HTMLAreaElement
Defined in:
lib/dommy/html_elements.rb

Overview

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

Returns:

  • (Boolean)


102
103
104
# File 'lib/dommy/html_elements.rb', line 102

def activation_target?
  has_attribute?("href")
end