Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
dom/event: simplify .currentTarget and .type polyfills
  • Loading branch information
meh committed Jan 27, 2014
1 parent 3f69ad6 commit c091d86
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
14 changes: 2 additions & 12 deletions opal/browser/dom/event.rb
Expand Up @@ -197,21 +197,11 @@ def initialize(event, callback = nil)
end

def name
if @callback
@callback.name
else
`#@native.type`
end
`#@native.type`
end

def on
return @on if @on

if @callback
@callback.target
else
Target.convert(`#@native.currentTarget`)
end
@on || Target.convert(`#@native.currentTarget`)
end

def target
Expand Down
5 changes: 5 additions & 0 deletions opal/browser/dom/event/base.rb
Expand Up @@ -70,6 +70,11 @@ def call(e)

def to_proc
@proc ||= -> event {
%x{
event.currentTarget = self.target.native;
event.type = self.name;
}

event = Event.new(event, self)

unless event.stopped?
Expand Down

0 comments on commit c091d86

Please sign in to comment.