Sha256: 452b1167365bcbc95cf6ab60a907e8d2afb0be000349c3f8798d25869017d1c3

Contents?: true

Size: 726 Bytes

Versions: 3

Compression:

Stored size: 726 Bytes

Contents

Element.instance_eval do
  def self.find(selector)
    selector = begin
      selector.dom_node
    rescue
      selector
    end if `#{selector}.$dom_node !== undefined`
    `$(#{selector})`
  end

  def self.[](selector)
    find(selector)
  end

  define_method :render do |container = nil, params = {}, &block|
    if `#{self.to_n}._reactrb_component_class === undefined`
      `#{self.to_n}._reactrb_component_class = #{Class.new(React::Component::Base)}`
    end
    klass = `#{self.to_n}._reactrb_component_class`
    klass.class_eval do
      render(container, params, &block)
    end

    React.render(React.create_element(`#{self.to_n}._reactrb_component_class`), self)
  end
end if Object.const_defined?('Element')

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hyper-react-0.12.1 lib/react/ext/opal-jquery/element.rb
hyper-react-0.12.0 lib/react/ext/opal-jquery/element.rb
hyper-react-0.11.0 lib/react/ext/opal-jquery/element.rb