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

Commit 75486c9

Browse files
committed
Singular predicates; they test a single argument.
1 parent 4408438 commit 75486c9

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

lib/react/api.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def self.create_element(type, properties = {}, &block)
7474
params << @@component_classes[type]
7575
elsif type.kind_of?(Class)
7676
params << create_native_react_class(type)
77-
elsif React.html_tags?(type)
77+
elsif React.html_tag?(type)
7878
params << type
7979
elsif type.is_a? String
8080
return React::Element.new(type)
@@ -109,7 +109,7 @@ def self.convert_props(properties)
109109
elsif ["style", "dangerously_set_inner_HTML"].include? key
110110
props[lower_camelize(key)] = value.to_n
111111
else
112-
props[React.html_attrs?(lower_camelize(key)) ? lower_camelize(key) : key] = value
112+
props[React.html_attr?(lower_camelize(key)) ? lower_camelize(key) : key] = value
113113
end
114114
end
115115
props.shallow_to_n

lib/react/component.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def method_missing(n, *args, &block)
196196
node_only = true
197197
name = name.gsub(/_as_node$/, "")
198198
end
199-
unless (React.html_tags?(name) || name == 'present' || name == '_p_tag' || (name = component?(name, self)))
199+
unless (React.html_tag?(name) || name == 'present' || name == '_p_tag' || (name = component?(name, self)))
200200
return super
201201
end
202202

lib/react/top_level.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ module React
3535
viewBox x1 x2 x xlinkActuate xlinkArcrole xlinkHref xlinkRole
3636
xlinkShow xlinkTitle xlinkType xmlBase xmlLang xmlSpace y1 y2 y)
3737

38-
def self.html_tags?(name)
38+
def self.html_tag?(name)
3939
tags = HTML_TAGS
4040
`
4141
for(var i = 0; i < tags.length; i++){
@@ -46,7 +46,7 @@ def self.html_tags?(name)
4646
`
4747
end
4848

49-
def self.html_attrs?(name)
49+
def self.html_attr?(name)
5050
attrs = ATTRIBUTES
5151
`
5252
for(var i = 0; i < attrs.length; i++){

spec/react/top_level_component_spec.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,24 +61,24 @@ def render_top_level(controller, component_name)
6161
expect(render_top_level("Controller", "::Components::Component1")).to eq('<span>Components::Component1</span>')
6262
end
6363

64-
it 'React.html_tags? will return true for normal html tags' do
65-
expect(React.html_tags?('a')).to eq(true)
66-
expect(React.html_tags?('div')).to eq(true)
64+
it 'React.html_tag? will return true for normal html tags' do
65+
expect(React.html_tag?('a')).to eq(true)
66+
expect(React.html_tag?('div')).to eq(true)
6767
end
6868

69-
it 'React.html_tags? will return true for svg element names' do
70-
expect(React.html_tags?('svg')).to eq(true)
71-
expect(React.html_tags?('circle')).to eq(true)
69+
it 'React.html_tag? will return true for svg element names' do
70+
expect(React.html_tag?('svg')).to eq(true)
71+
expect(React.html_tag?('circle')).to eq(true)
7272
end
7373

74-
it 'React.html_attrs? will return true for normal html attribute names' do
75-
expect(React.html_attrs?('id')).to eq(true)
76-
expect(React.html_attrs?('data')).to eq(true)
74+
it 'React.html_attr? will return true for normal html attribute names' do
75+
expect(React.html_attr?('id')).to eq(true)
76+
expect(React.html_attr?('data')).to eq(true)
7777
end
7878

79-
it 'React.html_attrs? will return true for svg attribute names' do
80-
expect(React.html_attrs?('cx')).to eq(true)
81-
expect(React.html_attrs?('strokeWidth')).to eq(true)
79+
it 'React.html_attr? will return true for svg attribute names' do
80+
expect(React.html_attr?('cx')).to eq(true)
81+
expect(React.html_attr?('strokeWidth')).to eq(true)
8282
end
8383
end
8484
end

0 commit comments

Comments
 (0)