Skip to content
This repository was archived by the owner on Oct 19, 2018. It is now read-only.

Commit 5de8c5c

Browse files
committed
Only camelize default attributes
1 parent 64c8851 commit 5de8c5c

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

lib/react/api.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def self.create_element(type, properties = {}, &block)
6464
if key == "class_name" && value.is_a?(Hash)
6565
props[lower_camelize(key)] = `React.addons.classSet(#{value.to_n})`
6666
else
67-
props[lower_camelize(key)] = value
67+
props[React::ATTRIBUTES.include?(lower_camelize(key)) ? lower_camelize(key) : key] = value
6868
end
6969
end
7070
params << props

lib/react/top_level.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module React
2121
muted name noValidate open pattern placeholder poster preload radioGroup
2222
readOnly rel required role rows rowSpan sandbox scope scrolling seamless
2323
selected shape size sizes span spellCheck src srcDoc srcSet start step style
24-
tabIndex target title type useMap value width wmode)
24+
tabIndex target title type useMap value width wmode dangerously_set_inner_HTML)
2525

2626
def self.create_element(type, properties = {}, &block)
2727
React::API.create_element(type, properties, &block)

spec/react_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ def render
9191
element = React.create_element("div", foo: "bar")
9292
expect(element.props.foo).to eq("bar")
9393
end
94+
95+
it "should not camel-case custom property" do
96+
element = React.create_element("div", foo_bar: "foo")
97+
expect(element.props.foo_bar).to eq("foo")
98+
end
9499
end
95100

96101
describe "class_name helpers (React.addons.classSet)" do

0 commit comments

Comments
 (0)