Class: Dommy::PopStateEvent

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

Overview

PopStateEvent — fired on history back/forward. Exposes the history entry’s serialized state via ‘event.state` (the spec property; framework routers like Turbo read `event.state.turbo` to recognise their own navigations and restore the cached page). A plain `Event` subclass per spec — NOT a CustomEvent, so it has no `detail` and `instanceof CustomEvent` is false.

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_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) ⇒ PopStateEvent

Returns a new instance of PopStateEvent.



522
523
524
525
# File 'lib/dommy/event.rb', line 522

def initialize(type, init = nil)
  super
  @state = read_init(init, "state")
end

Instance Attribute Details

#stateObject (readonly)

Returns the value of attribute state.



520
521
522
# File 'lib/dommy/event.rb', line 520

def state
  @state
end

Instance Method Details

#__js_get__(key) ⇒ Object



527
528
529
530
531
# File 'lib/dommy/event.rb', line 527

def __js_get__(key)
  return @state if key == "state"

  super
end