Navigation Menu

Skip to content

Commit

Permalink
component: fix instance events
Browse files Browse the repository at this point in the history
  • Loading branch information
meh committed Jan 30, 2014
1 parent cdb7134 commit a1034ed
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 6 deletions.
2 changes: 2 additions & 0 deletions opal/lissio/application.rb
Expand Up @@ -39,6 +39,8 @@ def self.expose(what, options = {})
def_delegators :@router, :navigate, :route

def initialize
super()

@router = Lissio::Router.new(fragment: false)
end

Expand Down
6 changes: 2 additions & 4 deletions opal/lissio/component.rb
Expand Up @@ -142,6 +142,7 @@ def self.css(&block)

def initialize(parent = nil)
@parent = parent
@events = Hash.new { |h, k| h[k] = [] }
end

def tag
Expand All @@ -166,8 +167,7 @@ def element
elem.add_class(*self.class.inheritance)
elem[:id] = tag[:id] if tag[:id]

# FIXME: when [2, *a] is fixed
[self.class.events, @events].compact.each {|events|
[self.class.events, @events].each {|events|
events.each {|name, blocks|
blocks.each {|selector, block|
if Symbol === block
Expand Down Expand Up @@ -202,8 +202,6 @@ def on(name, selector = nil, method = nil, &block)
end
end
else
@events ||= {}

if block
@events[name] << [selector, block]
elsif method
Expand Down
2 changes: 2 additions & 0 deletions opal/lissio/component/alert.rb
Expand Up @@ -8,6 +8,8 @@ def self.new!(message, options = {})
attr_reader :message, :options

def initialize(message, options = {})
super()

@message = message
@options = options
end
Expand Down
4 changes: 3 additions & 1 deletion opal/lissio/component/autocomplete.rb
Expand Up @@ -58,7 +58,9 @@ def initialize(title, results, key, input, select)
end
end

def initialize(&block)
def initialize(parent = nil, &block)
super(parent)

@autocompleters = []

if block.arity.nonzero?
Expand Down
2 changes: 1 addition & 1 deletion opal/lissio/component/container.rb
Expand Up @@ -21,7 +21,7 @@ def to_a
end
end

def initialize(parent, &block)
def initialize(parent = nil, &block)
super(parent)

if block
Expand Down
2 changes: 2 additions & 0 deletions opal/lissio/component/tooltip.rb
Expand Up @@ -12,6 +12,8 @@ class Tooltip < Lissio::Component
def initialize(*args, &block)
if Lissio::Component === args.first
super(args.shift)
else
super()
end

@options = DEFAULTS.merge(args.first)
Expand Down

0 comments on commit a1034ed

Please sign in to comment.