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_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.



483
484
485
486
# File 'lib/dommy/event.rb', line 483

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

Instance Attribute Details

#detailObject (readonly)

Returns the value of attribute detail.



481
482
483
# File 'lib/dommy/event.rb', line 481

def detail
  @detail
end

Instance Method Details

#__js_call__(method, args) ⇒ Object



495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
# File 'lib/dommy/event.rb', line 495

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



488
489
490
491
492
# File 'lib/dommy/event.rb', line 488

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

  super
end