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

Let's merge 0-8-stable to master #164

Merged
merged 58 commits into from
Oct 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
54a66d7
closes #142 closes #143
catmando May 19, 2016
1be83c7
[React::Children] Fix the spec
zetachang Sep 17, 2016
fc37df3
Squashed commit of the following:
zetachang Sep 17, 2016
cdc751d
Make v13 test back and skip it at runtime
zetachang Sep 17, 2016
9710d3f
Setup Appraisal to test multiple reactjs build provided by “react-rai…
zetachang Sep 17, 2016
8639e04
Unbroke test
zetachang Sep 17, 2016
d389abc
Update props validation spec to match reactjs v15
zetachang Sep 20, 2016
0537300
Fix Utils spec
zetachang Sep 20, 2016
90ae8c8
[TravisCI] test matrix for react v13-v15
zetachang Sep 20, 2016
52981e2
Make root Gemfile is also installed
zetachang Sep 20, 2016
d136e15
[React::Test::Session] Fix for reactjs-v15
zetachang Sep 22, 2016
69172cf
[Test Infra] Add opal-0.9 to Appraisals
zetachang Sep 22, 2016
010ae27
[opal-0.9] Fix validator_spec
zetachang Sep 22, 2016
4cef660
[opal-0.9] Fix ruby specs
zetachang Sep 22, 2016
f37c475
[opal-0.9] Fix dsl spec
zetachang Sep 22, 2016
9d0abb3
Restrict opal-rails to 0.8.1 for opal 0.8
zetachang Sep 24, 2016
a194644
Pass parent BUNDLE_GEMFILE when shell out
zetachang Sep 24, 2016
6686d0f
Fix asset_pipeline_spec
zetachang Sep 24, 2016
005cbfe
[opal-0.9] Fix React::Children
zetachang Sep 24, 2016
5330f23
Fix tutorial spec
zetachang Sep 25, 2016
d88afd7
[opal-0.9] Fix DSL spec
zetachang Sep 25, 2016
5e0c2ed
Increase test timeout
zetachang Sep 25, 2016
1ef23d7
Add runtime check for task.timeout
zetachang Sep 25, 2016
caacdec
[travis-ci] Ignore jruby opal-0.9 react 14 & 15
zetachang Sep 25, 2016
47b1f21
adds haml like data param typing, closes #99
adamcreekroad Jun 14, 2016
5a3d69d
Add render class method
zetachang Sep 27, 2016
f747191
closes #148
catmando Jun 15, 2016
4727fbc
WIP
catmando Jun 23, 2016
fb8c151
[travis-ci] display phantomjs version
zetachang Sep 27, 2016
9472d8a
refactored handling of tags and method_missing
catmando Jun 24, 2016
d6fce16
Fix missing requires & move React::Children back
zetachang Sep 30, 2016
cc46cf5
Make React::HTML_TAGS back to keep backward compatibility
zetachang Sep 30, 2016
b0968af
Make React::HASH_ATTRIBUTES back
zetachang Sep 30, 2016
72f22f1
Move svg tags back
zetachang Sep 30, 2016
8a6236f
Fix DSL spec
zetachang Sep 30, 2016
742b02b
Move back the handling of `p` tag
zetachang Sep 30, 2016
f9eb077
Fix #params accessing with the updated PropsWrapper
zetachang Sep 30, 2016
66f077c
fixed spec
catmando Jun 27, 2016
2bae76f
ready to release
catmando Jun 28, 2016
e3df4bc
look up non sibling ancestor components
catmando Jun 28, 2016
6cdee7a
added _as_node support to NativeLibrary
catmando Jun 29, 2016
9fc7272
added check for legacy react native components
catmando Jun 29, 2016
780e61e
cant find components in anonymous scopes fixed
catmando Jun 29, 2016
a2ae4be
closes #151
catmando Jun 30, 2016
4b8d04d
closes #153
catmando Jul 13, 2016
10347fe
[ElementSpec] fix warning format matching
zetachang Oct 2, 2016
c994c1a
closes 154
catmando Jul 13, 2016
807efce
closes #152
catmando Jul 13, 2016
1933a3a
added test spec to make sure nested native libraries work
catmando Jul 15, 2016
04f7f44
closes #155
catmando Jul 16, 2016
6d67f63
Add missing require to reactive-ruby
zetachang Oct 2, 2016
91d17f3
closes #157 closes #158
catmando Jul 19, 2016
bcc36f7
Squash changes of baf71b4d 95397b41 ea6271da 08c4028f
zetachang Oct 2, 2016
25b8231
Readress #158
zetachang Sep 12, 2016
ea87551
opal 10.x compatibility fixes
catmando Jul 8, 2016
cefbe2e
[travis ci] exclude jruby opal 0.9 react v13 setup
zetachang Oct 2, 2016
36720b9
Fix spec in react v13 & v14
zetachang Oct 2, 2016
45906da
[Test] opal-rspec tests setup for running in both opal 0.8 & 0.9
zetachang Oct 2, 2016
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ node_modules

spec/test_app
Gemfile.lock

/gemfiles/*.lock
/tmp
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1154,3 +1154,6 @@ Style/WordArray:
Description: 'Use %w or %W for arrays of words.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-w'
Enabled: false

Style/CommandLiteral:
EnforcedStyle: mixed
20 changes: 20 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,26 @@ rvm:
- 2.0.0
- 2.1
- jruby-19mode
before_script:
- phantomjs --version
script:
- bundle exec rake test_app
- bundle exec rake
gemfile:
- gemfiles/opal_0.8_react_13.gemfile
- gemfiles/opal_0.8_react_14.gemfile
- gemfiles/opal_0.8_react_15.gemfile
- gemfiles/opal_0.9_react_13.gemfile
- gemfiles/opal_0.9_react_14.gemfile
- gemfiles/opal_0.9_react_15.gemfile

# These two setup seems to run indefinitely long
# further investigation required.
matrix:
exclude:
- rvm: jruby-19mode
gemfile: gemfiles/opal_0.9_react_13.gemfile
- rvm: jruby-19mode
gemfile: gemfiles/opal_0.9_react_14.gemfile
- rvm: jruby-19mode
gemfile: gemfiles/opal_0.9_react_15.gemfile
20 changes: 20 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
opal_versions = ['0.8', '0.9']
react_versions_map = {
'13' => '~> 1.3.3',
'14' => '~> 1.6.2',
'15' => '~> 1.8.2'
}
opal_rails_versions_map = {
'0.8' => '~> 0.8.1',
'0.9' => '~> 0.9.0',
}

opal_versions.each do |opal_v|
react_versions_map.each do |react_v, react_rails_v|
appraise "opal-#{opal_v}-react-#{react_v}" do
gem 'opal', "~> #{opal_v}.0"
gem 'opal-rails', opal_rails_versions_map[opal_v]
gem 'react-rails', react_rails_v, require: false
end
end
end
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ Whitespace conventions:
- 1 spaces before normal text
-->

## [0.8.9] - Unreleased

### Fixed

- Gets rid of react warnings about updating state during render (#155)
- Multiple HAML classes (i.e. div.foo.bar) was not working (regression introduced in 0.8.8)
- Don't send nil (null) to form components as the value string (#157)
- Process `params` (props) correctly when using `Element#on` or `Element#render` (#158)
- Deprecate shallow param compare (#156)


## [0.8.8] - 2016-07-13

### Added
Expand Down
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
source 'https://rubygems.org'
gemspec

group :development do
gem "appraisal"
end
13 changes: 12 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,25 @@ require 'bundler'
Bundler.require
Bundler::GemHelper.install_tasks

# Store the BUNDLE_GEMFILE env, since rake or rspec seems to clean it
# while invoking task.
ENV['REAL_BUNDLE_GEMFILE'] = ENV['BUNDLE_GEMFILE']

require 'rspec/core/rake_task'
require 'opal/rspec/rake_task'

begin
require "react-rails"
rescue NameError
end

RSpec::Core::RakeTask.new('ruby:rspec')
Opal::RSpec::RakeTask.new('opal:rspec') do |s|

Opal::RSpec::RakeTask.new('opal:rspec') do |s, task|
s.append_path React::Rails::AssetVariant.new(addons: true).react_directory
s.append_path 'spec/vendor'
s.index_path = 'spec/index.html.erb'
task.timeout = 80000 if task
end

task :test do
Expand Down
145 changes: 145 additions & 0 deletions component-name-lookup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
#### Notes on how component names are looked up

Given:

```ruby

class Blat < React::Component::Base

render do
Bar()
Foo::Bar()
end

end

class Bar < React::Component::Base
end

module Foo

class Bar < React::Component::Base

render do
Blat()
Baz()
end
end

class Baz < React::Component::Base
end

end
```

The problem is that method lookup is different than constant lookup. We can prove it by running this code:

```ruby
def try_it(test, &block)
puts "trying #{test}"
result = yield
puts "success#{': '+result.to_s if result}"
rescue Exception => e
puts "failed: #{e}"
ensure
puts "---------------------------------"
end

module Boom

Bar = 12

def self.Bar
puts " Boom::Bar says hi"
end

class Baz
def doit
try_it("Bar()") { Bar() }
try_it("Boom::Bar()") {Boom::Bar()}
try_it("Bar") { Bar }
try_it("Boom::Bar") { Boom::Bar }
end
end
end



Boom::Baz.new.doit
```

which prints:

```text
trying Bar()
failed: Bar: undefined method `Bar' for #<Boom::Baz:0x774>
---------------------------------
trying Boom::Bar()
Boom::Bar says hi
success
---------------------------------
trying Bar
success: 12
---------------------------------
trying Boom::Bar
success: 12
---------------------------------
```

[try-it](http://opalrb.org/try/?code:def%20try_it(test%2C%20%26block)%0A%20%20puts%20%22trying%20%23%7Btest%7D%22%0A%20%20result%20%3D%20yield%0A%20%20puts%20%22success%23%7B%27%3A%20%27%2Bresult.to_s%20if%20result%7D%22%0Arescue%20Exception%20%3D%3E%20e%0A%20%20puts%20%22failed%3A%20%23%7Be%7D%22%0Aensure%0A%20%20puts%20%22---------------------------------%22%0Aend%0A%0Amodule%20Boom%0A%20%20%0A%20%20Bar%20%3D%2012%0A%20%20%0A%20%20def%20self.Bar%0A%20%20%20%20puts%20%22%20%20%20Boom%3A%3ABar%20says%20hi%22%0A%20%20end%0A%0A%20%20class%20Baz%0A%20%20%20%20def%20doit%0A%20%20%20%20%20%20try_it(%22Bar()%22)%20%7B%20Bar()%20%7D%0A%20%20%20%20%20%20try_it(%22Boom%3A%3ABar()%22)%20%7BBoom%3A%3ABar()%7D%0A%20%20%20%20%20%20try_it(%22Bar%22)%20%7B%20Bar%20%7D%0A%20%20%20%20%20%20try_it(%22Boom%3A%3ABar%22)%20%7B%20Boom%3A%3ABar%20%7D%0A%20%20%20%20end%0A%20%20end%0Aend%0A%20%20%0A%0A%0ABoom%3A%3ABaz.new.doit)


What we need to do is:

1. when defining a component class `Foo`, also define in the same scope that Foo is being defined a method `self.Foo` that will accept Foo's params and child block, and render it.

2. As long as a name is qualified with at least one scope (i.e. `ModName::Foo()`) everything will work out, but if we say just `Foo()` then the only way I believe out of this is to handle it via method_missing, and let method_missing do a const_get on the method_name (which will return the class) and then render that component.

#### details

To define `self.Foo` in the same scope level as the class `Foo`, we need code like this:

```ruby
def register_component_dsl_method(component)
split_name = component.name && component.name.split('::')
return unless split_name && split_name.length > 2
component_name = split_name.last
parent = split_name.inject([Module]) { |nesting, next_const| nesting + [nesting.last.const_get(next_const)] }[-2]
class << parent
define_method component_name do |*args, &block|
React::RenderingContext.render(name, *args, &block)
end
define_method "#{component_name}_as_node" do |*args, &block|
React::Component.deprecation_warning("..._as_node is deprecated. Render component and then use the .node method instead")
send(component_name, *args, &block).node
end
end
end

module React
module Component
def self.included(base)
...
register_component_dsl_method(base.name)
end
end
end
```

The component's method_missing function will look like this:

```ruby
def method_missing(name, *args, &block)
if name =~ /_as_node$/
React::Component.deprecation_warning("..._as_node is deprecated. Render component and then use the .node method instead")
method_missing(name.gsub(/_as_node$/,""), *args, &block).node
else
component = const_get name if defined? name
React::RenderingContext.render(nil, component, *args, &block)
end
end
```

### other related issues

The Kernel#p method conflicts with the <p> tag. However the p method can be invoked on any object so we are going to go ahead and use it, and deprecate the para method.
37 changes: 27 additions & 10 deletions config.ru
Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
require 'bundler'
Bundler.require

require "opal-rspec"
require "react/source"
require "opal/rspec"
require "opal-jquery"

Opal.append_path File.expand_path('../spec', __FILE__)
begin
require "react-rails"
rescue NameError
end

run Opal::Server.new { |s|
s.main = 'opal/rspec/sprockets_runner'
s.append_path 'spec'
s.append_path File.dirname(::React::Source.bundled_path_for("react-with-addons.js"))
s.debug = true
s.index_path = 'spec/reactjs/index.html.erb'
}
if Opal::RSpec.const_defined?("SprocketsEnvironment")
sprockets_env = Opal::RSpec::SprocketsEnvironment.new
sprockets_env.cache = Sprockets::Cache::FileStore.new("tmp")
sprockets_env.add_spec_paths_to_sprockets
run Opal::Server.new(sprockets: sprockets_env) { |s|
s.main = 'opal/rspec/sprockets_runner'
s.append_path React::Rails::AssetVariant.new(addons: true).react_directory
s.debug = false
s.append_path 'spec/vendor'
s.index_path = 'spec/index.html.erb'
}
else
run Opal::Server.new { |s|
s.main = 'opal/rspec/sprockets_runner'
s.append_path React::Rails::AssetVariant.new(addons: true).react_directory
s.append_path 'spec'
s.append_path 'spec/vendor'
s.debug = false
s.index_path = 'spec/index.html.erb'
}
end
13 changes: 13 additions & 0 deletions gemfiles/opal_0.8_react_13.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "opal", "~> 0.8.0"
gem "opal-rails", "~> 0.8.1"
gem "react-rails", "~> 1.3.3", :require => false

group :development do
gem "appraisal"
end

gemspec :path => "../"
13 changes: 13 additions & 0 deletions gemfiles/opal_0.8_react_14.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "opal", "~> 0.8.0"
gem "opal-rails", "~> 0.8.1"
gem "react-rails", "~> 1.6.2", :require => false

group :development do
gem "appraisal"
end

gemspec :path => "../"
13 changes: 13 additions & 0 deletions gemfiles/opal_0.8_react_15.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "opal", "~> 0.8.0"
gem "opal-rails", "~> 0.8.1"
gem "react-rails", "~> 1.8.2", :require => false

group :development do
gem "appraisal"
end

gemspec :path => "../"
13 changes: 13 additions & 0 deletions gemfiles/opal_0.9_react_13.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "opal", "~> 0.9.0"
gem "opal-rails", "~> 0.9.0"
gem "react-rails", "~> 1.3.3", :require => false

group :development do
gem "appraisal"
end

gemspec :path => "../"
13 changes: 13 additions & 0 deletions gemfiles/opal_0.9_react_14.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "opal", "~> 0.9.0"
gem "opal-rails", "~> 0.9.0"
gem "react-rails", "~> 1.6.2", :require => false

group :development do
gem "appraisal"
end

gemspec :path => "../"
13 changes: 13 additions & 0 deletions gemfiles/opal_0.9_react_15.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "opal", "~> 0.9.0"
gem "opal-rails", "~> 0.9.0"
gem "react-rails", "~> 1.8.2", :require => false

group :development do
gem "appraisal"
end

gemspec :path => "../"
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require 'opal'
require 'react'
require 'reactive-ruby'
require_tree './components'
Loading