Class: Dommy::HashChangeEvent

Inherits:
Event
  • Object
show all
Defined in:
lib/dommy/event.rb

Overview

HashChangeEvent — fired on the window when the URL fragment changes (a fragment-navigation link, location.hash = ...). Exposes the full document URL before and after the change as oldURL / newURL (spec USVStrings). A plain Event subclass, NOT a CustomEvent.

Constant Summary

Constants inherited from Event

Event::AT_TARGET, Event::BUBBLING_PHASE, Event::CAPTURING_PHASE, Event::NONE

Instance Attribute Summary collapse

Attributes inherited from Event

#type

Instance Method Summary collapse

Methods inherited from Event

#__internal_clear_propagation_flags__, #__internal_mark_trusted__, #__internal_prepare_for_dispatch__, #__internal_record_path__, #__internal_run_passive__, #__internal_set_current_target__, #__internal_set_dispatch_flag__, #__internal_set_event_phase__, #__js_call__, #__js_set__, #bubbles?, #default_prevented?, #immediate_propagation_stopped?, #init_event, #propagation_stopped?

Methods included from Bridge::Methods

included

Constructor Details

#initialize(type, init = nil) ⇒ HashChangeEvent

Returns a new instance of HashChangeEvent.



727
728
729
730
731
# File 'lib/dommy/event.rb', line 727

def initialize(type, init = nil)
  super
  @old_url = read_init(init, "oldURL").to_s
  @new_url = read_init(init, "newURL").to_s
end

Instance Attribute Details

#new_urlObject (readonly)

Returns the value of attribute new_url.



725
726
727
# File 'lib/dommy/event.rb', line 725

def new_url
  @new_url
end

#old_urlObject (readonly)

Returns the value of attribute old_url.



725
726
727
# File 'lib/dommy/event.rb', line 725

def old_url
  @old_url
end

Instance Method Details

#__js_get__(key) ⇒ Object



733
734
735
736
737
738
739
# File 'lib/dommy/event.rb', line 733

def __js_get__(key)
  case key
  when "oldURL" then @old_url
  when "newURL" then @new_url
  else super
  end
end