Sha256: bcc8ff6e4308b9a5c4bb34bd123291869e4316af42f23dd237970bb703b674f5

Contents?: true

Size: 561 Bytes

Versions: 1

Compression:

Stored size: 561 Bytes

Contents

require 'ostruct'

module Browser; module DOM; class Event

class Custom < Event
  def self.supported?
    not $$[:CustomEvent].nil?
  end

  def self.create(name, &block)
    data = OpenStruct.new
    block.call(data) if block

    new(`new CustomEvent(#{name}, { detail: #{data.to_n} })`)
  end

  def initialize(native)
    super(native); @native = native # TODO: remove this when super is fixed

    @detail = Hash.new(`#{native}.detail`)
  end

  def method_missing(id, *)
    return @detail[id] if @detail.has_key?(id)

    super
  end
end

end; end; end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
opal-browser-0.1.0.beta1 opal/browser/dom/event/custom.rb