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

Commit 8a80092

Browse files
committed
fixes regression from commit 823148d
1 parent ee93d60 commit 8a80092

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

Gemfile

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
source 'https://rubygems.org'
22
gem "opal-jquery", git: "https://github.com/opal/opal-jquery.git", branch: "master"
33
gem 'hyperloop-config', git: 'https://github.com/ruby-hyperloop/hyperloop-config.git', branch: 'edge'
4+
gem 'puma', '~> 3.11.0' # As of adding, version 3.12.0 isn't working so we are locking
45
gemspec

lib/react/api.rb

+7-1
Original file line numberDiff line numberDiff line change
@@ -192,16 +192,22 @@ def self.convert_props(args)
192192
elsif arg.is_a? Hash
193193
arg.each do |key, value|
194194
if ['class', 'className', 'class_name'].include? key
195+
next unless value
196+
195197
if value.is_a?(String)
196198
value = value.split(' ')
197199
elsif !value.is_a?(Array)
198200
raise "The class param must be a string or array of strings"
199201
end
200-
properties['className'] = (properties['className'] || []) + value
202+
203+
properties['className'] = [*properties['className'], *value]
201204
elsif key == 'style'
205+
next unless value
206+
202207
if !value.is_a?(Hash)
203208
raise "The style param must be a Hash"
204209
end
210+
205211
properties['style'] = (properties['style'] || {}).merge(value)
206212
elsif React::HASH_ATTRIBUTES.include?(key) && value.is_a?(Hash)
207213
properties[key] = (properties[key] || {}).merge(value)

spec/react/param_declaration_spec.rb

+15
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,21 @@ class Tester < Hyperloop::Component
217217
expect(tp).to have_content('flag: true, a: 1, b: 2, c: 3, d: 4')
218218
end
219219

220+
it 'allows passing nil for class and style params' do
221+
mount 'Tester' do
222+
class Tester < Hyperloop::Component
223+
render do
224+
DIV(id: 'tp', class: nil, style: nil) { 'Tester' }
225+
end
226+
end
227+
end
228+
229+
tp = find('#tp')
230+
231+
expect(tp[:class]).to eq('')
232+
expect(tp[:style]).to eq('')
233+
end
234+
220235
describe "converts params only once" do
221236
it "not on every access" do
222237
mount 'Foo', foo: {bazwoggle: 1} do

0 commit comments

Comments
 (0)