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

Commit 91e0a5f

Browse files
committed
Get master current with patches to 0.7.x
Conflicts: README.md lib/react/component.rb lib/react/component/props_wrapper.rb lib/reactive-ruby/version.rb path_release_steps.md spec/react/dsl_spec.rb spec/react/param_declaration_spec.rb spec/reactive-ruby/rails/asset_pipeline_spec.rb
2 parents 91b34d3 + 6e2fcce commit 91e0a5f

File tree

3 files changed

+65
-1
lines changed

3 files changed

+65
-1
lines changed

lib/react/component/class_methods.rb

+5
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ def collect_other_params_as(name)
8383
props_wrapper.define_method(name) do
8484
@_all_others ||= validator_in_lexical_scope.undefined_props(props)
8585
end
86+
87+
validator_in_lexial_scope = validator
88+
props_wrapper.define_method(name) do
89+
@_all_others ||= validator_in_lexial_scope.undefined_props(props)
90+
end
8691
end
8792

8893
def define_state(*states, &block)

path_release_steps.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ For example assuming you are releasing fix to 0.8.18
66
3. Build & Release to RubyGems (Remember the version in version.rb should already be 0.8.19)
77
4. Create a tag 'v0.8.19' pointing to that commit.
88
5. Bump the version in 0-8-stable to 0.8.20 so it will be ready for the next patch level release.
9+
6. Commit the version bump, and do a `git push --tags` so the new tag goes up

spec/react/param_declaration_spec.rb

+59-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
if opal?
44
describe 'the param macro' do
5-
65
it 'defines collect_other_params_as method on params proxy' do
76
stub_const 'Foo', Class.new(React::Component::Base)
87
Foo.class_eval do
@@ -168,6 +167,65 @@ def render
168167
expect(`window.dummy_log`).to eq(["Warning: Failed propType: In component `Foo`\nProvided prop `foo` could not be converted to BazWoggle"])
169168
end
170169

170+
describe "converts params only once" do
171+
it "not on every access" do
172+
pending 'Fix after merging'
173+
stub_const "BazWoggle", Class.new
174+
BazWoggle.class_eval do
175+
def initialize(kind)
176+
@kind = kind
177+
end
178+
attr_accessor :kind
179+
def self._react_param_conversion(json, validate_only)
180+
new(json[:bazwoggle]) if json[:bazwoggle]
181+
end
182+
end
183+
Foo.class_eval do
184+
param :foo, type: BazWoggle
185+
def render
186+
params.foo.kind = params.foo.kind+1
187+
"#{params.foo.kind}"
188+
end
189+
end
190+
expect(Foo).to render
191+
expect(React.render_to_static_markup(React.create_element(Foo, foo: {bazwoggle: 1}))).to eq('<span>2</span>')
192+
end
193+
194+
it "even if contains an embedded native object" do
195+
pending 'Fix after merging'
196+
stub_const "Bar", Class.new(React::Component::Base)
197+
stub_const "BazWoggle", Class.new
198+
BazWoggle.class_eval do
199+
def initialize(kind)
200+
@kind = kind
201+
end
202+
attr_accessor :kind
203+
def self._react_param_conversion(json, validate_only)
204+
new(JSON.from_object(json[0])[:bazwoggle]) if JSON.from_object(json[0])[:bazwoggle]
205+
end
206+
end
207+
Bar.class_eval do
208+
param :foo, type: BazWoggle
209+
def render
210+
params.foo.kind.to_s
211+
end
212+
end
213+
Foo.class_eval do
214+
export_state :change_me
215+
before_mount do
216+
Foo.change_me! "initial"
217+
end
218+
def render
219+
Bar(foo: Native([`{bazwoggle: #{Foo.change_me}}`]))
220+
end
221+
end
222+
div = `document.createElement("div")`
223+
React.render(React.create_element(Foo, {}), div)
224+
Foo.change_me! "updated"
225+
expect(`div.children[0].innerHTML`).to eq("updated")
226+
end
227+
end
228+
171229
it "will alias a Proc type param" do
172230
Foo.class_eval do
173231
param :foo, type: Proc

0 commit comments

Comments
 (0)