Class: Dommy::EventTarget::Listener

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

Instance Method Summary collapse

Instance Method Details

#capture?Boolean

useCapture: a boolean third argument, or {capture: …} in the options dictionary. A capture listener fires in the capturing phase; a non-capture listener in the bubbling phase (both at the target).

Returns:

  • (Boolean)


243
244
245
# File 'lib/dommy/event.rb', line 243

def capture?
  EventTarget.capture_flag(options)
end

#event_handler?Boolean

True when this listener was registered via an event handler IDL/content attribute (el.onclick = fn / onclick="…"): its return value is processed per the event handler processing algorithm (a false return cancels).

Returns:

  • (Boolean)


229
# File 'lib/dommy/event.rb', line 229

def event_handler? = event_handler ? true : false

#once?Boolean

Returns:

  • (Boolean)


231
232
233
234
235
236
237
238
# File 'lib/dommy/event.rb', line 231

def once?
  case options
  when Hash
    options["once"] || options[:once]
  else
    false
  end
end

#passive?Boolean

{ passive: true } — the listener promises not to call preventDefault, so the event's preventDefault() is neutralized while it runs.

Returns:

  • (Boolean)


249
250
251
252
253
254
255
256
# File 'lib/dommy/event.rb', line 249

def passive?
  case options
  when Hash
    EventTarget.js_truthy?(options.key?("passive") ? options["passive"] : options[:passive])
  else
    false
  end
end