Class: Dommy::CustomEvent

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

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_set__, #bubbles?, #default_prevented?, #immediate_propagation_stopped?, #init_event, #propagation_stopped?

Methods included from Bridge::Methods

included

Constructor Details

#initialize(type, init = nil) ⇒ CustomEvent

Returns a new instance of CustomEvent.



604
605
606
607
# File 'lib/dommy/event.rb', line 604

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

Instance Attribute Details

#detailObject (readonly)

Returns the value of attribute detail.



602
603
604
# File 'lib/dommy/event.rb', line 602

def detail
  @detail
end

Instance Method Details

#__js_call__(method, args) ⇒ Object



616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
# File 'lib/dommy/event.rb', line 616

def __js_call__(method, args)
  case method
  when "initCustomEvent"
    # Deprecated initCustomEvent(type, bubbles=false, cancelable=false,
    # detail=null). Like initEvent, the type is mandatory and the whole call
    # is a no-op while the event is being dispatched.
    raise Bridge::TypeError, "initCustomEvent requires a type argument" if args.empty?

    unless @dispatch_flag
      init_event(args[0], args[1], args[2])
      @detail = args[3]
    end
    nil
  else
    super
  end
end

#__js_get__(key) ⇒ Object



609
610
611
612
613
# File 'lib/dommy/event.rb', line 609

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

  super
end