Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change ./ext/string requires to react/ext/string #55

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/react/component.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require "./ext/string"
require "react/ext/string"
require 'active_support/core_ext/class/attribute'
require 'react/callbacks'
require "react/ext/hash"
Expand Down
26 changes: 13 additions & 13 deletions lib/react/element.rb
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
require "./ext/string"
require "react/ext/string"

module React
class Element < `(function(){var r = React;var f = function(){};var c = r.createClass({render:function(){return null;}});f.prototype = Object.getPrototypeOf(r.createElement(c));return f;})()`
def self.new
raise "use React.create_element instead"
end

def element_type
`self.type`
end

def key
Native(`self.key`)
end

def props
Hash.new(`self.props`)
end

def ref
Native(`self.ref`)
end

def on(event_name)
name = event_name.to_s.event_camelize


if React::Event::BUILT_IN_EVENTS.include?("on#{name}")
prop_key = "on#{name}"
callback = %x{
Expand All @@ -41,15 +41,15 @@ def on(event_name)
}
}
end

`self.props[#{prop_key}] = #{callback}`

self
end

def children
nodes = `self.props.children`

if `React.Children.count(nodes)` == 0
`[]`
elsif `React.Children.count(nodes)` == 1
Expand Down Expand Up @@ -85,11 +85,11 @@ def each(&block)
end
end
end

nodes
end
end

def to_n
self
end
Expand Down