reactrb 0.8.8 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +24 -3
  3. data/.gitignore +3 -0
  4. data/.rubocop.yml +1154 -3
  5. data/.travis.yml +20 -0
  6. data/Appraisals +20 -0
  7. data/CHANGELOG.md +28 -3
  8. data/Gemfile +4 -5
  9. data/README.md +6 -9
  10. data/Rakefile +6 -1
  11. data/config.ru +7 -6
  12. data/gemfiles/opal_0.8_react_13.gemfile +13 -0
  13. data/gemfiles/opal_0.8_react_14.gemfile +13 -0
  14. data/gemfiles/opal_0.8_react_15.gemfile +13 -0
  15. data/gemfiles/opal_0.9_react_13.gemfile +13 -0
  16. data/gemfiles/opal_0.9_react_14.gemfile +13 -0
  17. data/gemfiles/opal_0.9_react_15.gemfile +13 -0
  18. data/lib/generators/reactive_ruby/test_app/templates/assets/javascripts/components.rb +1 -1
  19. data/lib/rails-helpers/top_level_rails_component.rb +1 -1
  20. data/lib/react-sources/react-server.js +2 -0
  21. data/lib/react/api.rb +13 -12
  22. data/lib/react/children.rb +30 -0
  23. data/lib/react/component.rb +27 -46
  24. data/lib/react/component/class_methods.rb +28 -32
  25. data/lib/react/component/dsl_instance_methods.rb +4 -34
  26. data/lib/react/component/params.rb +6 -0
  27. data/lib/react/component/props_wrapper.rb +22 -27
  28. data/lib/react/component/should_component_update.rb +98 -0
  29. data/lib/react/component/tags.rb +45 -4
  30. data/lib/react/element.rb +26 -13
  31. data/lib/react/object.rb +15 -0
  32. data/lib/react/react-source.rb +9 -0
  33. data/lib/react/rendering_context.rb +97 -93
  34. data/lib/react/state.rb +27 -21
  35. data/lib/react/test.rb +16 -0
  36. data/lib/react/test/dsl.rb +17 -0
  37. data/lib/react/test/matchers/render_html_matcher.rb +49 -0
  38. data/lib/react/test/rspec.rb +15 -0
  39. data/lib/react/test/session.rb +46 -0
  40. data/lib/react/top_level.rb +50 -14
  41. data/lib/react/validator.rb +5 -5
  42. data/lib/reactive-ruby/isomorphic_helpers.rb +0 -7
  43. data/lib/reactive-ruby/version.rb +1 -1
  44. data/lib/reactrb.rb +14 -14
  45. data/lib/reactrb/deep-compare.rb +24 -0
  46. data/lib/sources/react-latest.js +2 -0
  47. data/lib/sources/react-v13.js +4 -1
  48. data/lib/sources/react-v14.js +3 -84
  49. data/lib/sources/react-v15.js +3 -0
  50. data/logo1.png +0 -0
  51. data/logo2.png +0 -0
  52. data/logo3.png +0 -0
  53. data/path_release_steps.md +1 -1
  54. data/reactrb.gemspec +2 -3
  55. data/spec/react/children_spec.rb +76 -0
  56. data/spec/react/component/base_spec.rb +3 -7
  57. data/spec/react/component_spec.rb +181 -60
  58. data/spec/react/dsl_spec.rb +26 -19
  59. data/spec/react/element_spec.rb +16 -1
  60. data/spec/react/native_library_spec.rb +20 -0
  61. data/spec/react/opal_jquery_extensions_spec.rb +27 -0
  62. data/spec/react/param_declaration_spec.rb +47 -78
  63. data/spec/react/react_spec.rb +7 -9
  64. data/spec/react/state_spec.rb +29 -0
  65. data/spec/react/test/dsl_spec.rb +43 -0
  66. data/spec/react/test/matchers/render_html_matcher_spec.rb +83 -0
  67. data/spec/react/test/rspec_spec.rb +62 -0
  68. data/spec/react/test/session_spec.rb +100 -0
  69. data/spec/react/test/utils_spec.rb +45 -0
  70. data/spec/react/top_level_component_spec.rb +33 -5
  71. data/spec/react/tutorial/tutorial_spec.rb +5 -5
  72. data/spec/react/validator_spec.rb +10 -13
  73. data/spec/reactive-ruby/component_loader_spec.rb +3 -0
  74. data/spec/reactive-ruby/rails/asset_pipeline_spec.rb +5 -4
  75. data/spec/spec_helper.rb +6 -3
  76. data/spec/support/react/spec_helpers.rb +9 -2
  77. metadata +47 -124
  78. data/example/examples/Gemfile +0 -7
  79. data/example/examples/app/basics.js.rb +0 -42
  80. data/example/examples/app/items.rb +0 -11
  81. data/example/examples/app/jquery.js +0 -5
  82. data/example/examples/app/nodes.rb +0 -61
  83. data/example/examples/app/react-router.js +0 -6
  84. data/example/examples/app/react_api_demo.rb +0 -29
  85. data/example/examples/app/rerendering.rb +0 -72
  86. data/example/examples/app/reuse.rb +0 -59
  87. data/example/examples/app/show.rb +0 -52
  88. data/example/examples/config.ru +0 -38
  89. data/example/rails-tutorial/.gitignore +0 -17
  90. data/example/rails-tutorial/Gemfile +0 -51
  91. data/example/rails-tutorial/README.rdoc +0 -28
  92. data/example/rails-tutorial/Rakefile +0 -6
  93. data/example/rails-tutorial/app/assets/images/.keep +0 -0
  94. data/example/rails-tutorial/app/assets/javascripts/application.rb +0 -15
  95. data/example/rails-tutorial/app/assets/stylesheets/application.css +0 -15
  96. data/example/rails-tutorial/app/controllers/application_controller.rb +0 -6
  97. data/example/rails-tutorial/app/controllers/concerns/.keep +0 -0
  98. data/example/rails-tutorial/app/controllers/home_controller.rb +0 -6
  99. data/example/rails-tutorial/app/helpers/application_helper.rb +0 -2
  100. data/example/rails-tutorial/app/mailers/.keep +0 -0
  101. data/example/rails-tutorial/app/models/.keep +0 -0
  102. data/example/rails-tutorial/app/models/concerns/.keep +0 -0
  103. data/example/rails-tutorial/app/views/components.rb +0 -3
  104. data/example/rails-tutorial/app/views/components/home/show.rb +0 -47
  105. data/example/rails-tutorial/app/views/layouts/application.html.erb +0 -14
  106. data/example/rails-tutorial/bin/bundle +0 -3
  107. data/example/rails-tutorial/bin/rails +0 -8
  108. data/example/rails-tutorial/bin/rake +0 -8
  109. data/example/rails-tutorial/bin/setup +0 -29
  110. data/example/rails-tutorial/bin/spring +0 -15
  111. data/example/rails-tutorial/config.ru +0 -4
  112. data/example/rails-tutorial/config/application.rb +0 -26
  113. data/example/rails-tutorial/config/boot.rb +0 -3
  114. data/example/rails-tutorial/config/database.yml +0 -25
  115. data/example/rails-tutorial/config/environment.rb +0 -5
  116. data/example/rails-tutorial/config/environments/development.rb +0 -41
  117. data/example/rails-tutorial/config/environments/production.rb +0 -79
  118. data/example/rails-tutorial/config/environments/test.rb +0 -42
  119. data/example/rails-tutorial/config/initializers/assets.rb +0 -11
  120. data/example/rails-tutorial/config/initializers/backtrace_silencers.rb +0 -7
  121. data/example/rails-tutorial/config/initializers/cookies_serializer.rb +0 -3
  122. data/example/rails-tutorial/config/initializers/filter_parameter_logging.rb +0 -4
  123. data/example/rails-tutorial/config/initializers/inflections.rb +0 -16
  124. data/example/rails-tutorial/config/initializers/mime_types.rb +0 -4
  125. data/example/rails-tutorial/config/initializers/session_store.rb +0 -3
  126. data/example/rails-tutorial/config/initializers/wrap_parameters.rb +0 -14
  127. data/example/rails-tutorial/config/locales/en.yml +0 -23
  128. data/example/rails-tutorial/config/routes.rb +0 -59
  129. data/example/rails-tutorial/config/secrets.yml +0 -22
  130. data/example/rails-tutorial/db/seeds.rb +0 -7
  131. data/example/rails-tutorial/lib/assets/.keep +0 -0
  132. data/example/rails-tutorial/lib/tasks/.keep +0 -0
  133. data/example/rails-tutorial/log/.keep +0 -0
  134. data/example/rails-tutorial/public/404.html +0 -67
  135. data/example/rails-tutorial/public/422.html +0 -67
  136. data/example/rails-tutorial/public/500.html +0 -66
  137. data/example/rails-tutorial/public/favicon.ico +0 -0
  138. data/example/rails-tutorial/public/robots.txt +0 -5
  139. data/example/rails-tutorial/test/controllers/.keep +0 -0
  140. data/example/rails-tutorial/test/fixtures/.keep +0 -0
  141. data/example/rails-tutorial/test/helpers/.keep +0 -0
  142. data/example/rails-tutorial/test/integration/.keep +0 -0
  143. data/example/rails-tutorial/test/mailers/.keep +0 -0
  144. data/example/rails-tutorial/test/models/.keep +0 -0
  145. data/example/rails-tutorial/test/test_helper.rb +0 -10
  146. data/example/rails-tutorial/vendor/assets/javascripts/.keep +0 -0
  147. data/example/rails-tutorial/vendor/assets/stylesheets/.keep +0 -0
  148. data/example/sinatra-tutorial/.DS_Store +0 -0
  149. data/example/sinatra-tutorial/Gemfile +0 -5
  150. data/example/sinatra-tutorial/README.md +0 -8
  151. data/example/sinatra-tutorial/_comments.json +0 -42
  152. data/example/sinatra-tutorial/app/example.rb +0 -290
  153. data/example/sinatra-tutorial/app/jquery.js +0 -5
  154. data/example/sinatra-tutorial/config.ru +0 -58
  155. data/example/sinatra-tutorial/public/base.css +0 -62
  156. data/example/todos/Gemfile +0 -11
  157. data/example/todos/README.md +0 -37
  158. data/example/todos/Rakefile +0 -8
  159. data/example/todos/app/application.rb +0 -22
  160. data/example/todos/app/components/app.react.rb +0 -61
  161. data/example/todos/app/components/footer.react.rb +0 -31
  162. data/example/todos/app/components/todo_item.react.rb +0 -46
  163. data/example/todos/app/components/todo_list.react.rb +0 -25
  164. data/example/todos/app/models/todo.rb +0 -19
  165. data/example/todos/config.ru +0 -14
  166. data/example/todos/index.html.haml +0 -16
  167. data/example/todos/spec/todo_spec.rb +0 -28
  168. data/example/todos/vendor/base.css +0 -410
  169. data/example/todos/vendor/bg.png +0 -0
  170. data/example/todos/vendor/jquery.js +0 -4
@@ -1,22 +1,54 @@
1
1
  require "native"
2
2
  require 'active_support'
3
+ require 'react/component/tags'
3
4
  require 'react/component/base'
4
5
 
5
6
  module React
6
7
 
7
8
  ATTRIBUTES = %w(accept acceptCharset accessKey action allowFullScreen allowTransparency alt
8
- async autoComplete autoPlay cellPadding cellSpacing charSet checked classID
9
- className cols colSpan content contentEditable contextMenu controls coords
10
- crossOrigin data dateTime defer dir disabled download draggable encType form
11
- formAction formEncType formMethod formNoValidate formTarget frameBorder height
12
- hidden href hrefLang htmlFor httpEquiv icon id label lang list loop manifest
13
- marginHeight marginWidth max maxLength media mediaGroup method min multiple
14
- muted name noValidate open pattern placeholder poster preload radioGroup
15
- readOnly rel required role rows rowSpan sandbox scope scrolling seamless
16
- selected shape size sizes span spellCheck src srcDoc srcSet start step style
17
- tabIndex target title type useMap value width wmode dangerouslySetInnerHTML)
18
-
9
+ async autoComplete autoPlay cellPadding cellSpacing charSet checked classID
10
+ className cols colSpan content contentEditable contextMenu controls coords
11
+ crossOrigin data dateTime defer dir disabled download draggable encType form
12
+ formAction formEncType formMethod formNoValidate formTarget frameBorder height
13
+ hidden href hrefLang htmlFor httpEquiv icon id label lang list loop manifest
14
+ marginHeight marginWidth max maxLength media mediaGroup method min multiple
15
+ muted name noValidate open pattern placeholder poster preload radioGroup
16
+ readOnly rel required role rows rowSpan sandbox scope scrolling seamless
17
+ selected shape size sizes span spellCheck src srcDoc srcSet start step style
18
+ tabIndex target title type useMap value width wmode dangerouslySetInnerHTML) +
19
+ #SVG ATTRIBUTES
20
+ %w(clipPath cx cy d dx dy fill fillOpacity fontFamily
21
+ fontSize fx fy gradientTransform gradientUnits markerEnd
22
+ markerMid markerStart offset opacity patternContentUnits
23
+ patternUnits points preserveAspectRatio r rx ry spreadMethod
24
+ stopColor stopOpacity stroke strokeDasharray strokeLinecap
25
+ strokeOpacity strokeWidth textAnchor transform version
26
+ viewBox x1 x2 x xlinkActuate xlinkArcrole xlinkHref xlinkRole
27
+ xlinkShow xlinkTitle xlinkType xmlBase xmlLang xmlSpace y1 y2 y)
19
28
  HASH_ATTRIBUTES = %w(data aria)
29
+ HTML_TAGS = React::Component::Tags::HTML_TAGS
30
+
31
+ def self.html_tag?(name)
32
+ tags = HTML_TAGS
33
+ %x{
34
+ for(var i = 0; i < tags.length; i++) {
35
+ if(tags[i] === name)
36
+ return true;
37
+ }
38
+ return false;
39
+ }
40
+ end
41
+
42
+ def self.html_attr?(name)
43
+ attrs = ATTRIBUTES
44
+ %x{
45
+ for(var i = 0; i < attrs.length; i++) {
46
+ if(attrs[i] === name)
47
+ return true;
48
+ }
49
+ return false;
50
+ }
51
+ end
20
52
 
21
53
  def self.create_element(type, properties = {}, &block)
22
54
  React::API.create_element(type, properties, &block)
@@ -78,7 +110,7 @@ Element.instance_eval do
78
110
  selector.dom_node
79
111
  rescue
80
112
  selector
81
- end if selector.respond_to? :dom_node
113
+ end if `#{selector}.$dom_node !== undefined`
82
114
  `$(#{selector})`
83
115
  end
84
116
 
@@ -87,10 +119,14 @@ Element.instance_eval do
87
119
  end
88
120
 
89
121
  define_method :render do |container = nil, params = {}, &block|
90
- klass = Class.new(React::Component::Base)
122
+ if `#{self.to_n}._reactrb_component_class === undefined`
123
+ `#{self.to_n}._reactrb_component_class = #{Class.new(React::Component::Base)}`
124
+ end
125
+ klass = `#{self.to_n}._reactrb_component_class`
91
126
  klass.class_eval do
92
127
  render(container, params, &block)
93
128
  end
94
- React.render(React.create_element(klass), self)
129
+
130
+ React.render(React.create_element(`#{self.to_n}._reactrb_component_class`), self)
95
131
  end
96
132
  end if Object.const_defined?('Element')
@@ -1,11 +1,11 @@
1
1
  module React
2
-
3
2
  class Validator
4
3
  attr_accessor :errors
5
- private :errors
4
+ attr_reader :props_wrapper
5
+ private :errors, :props_wrapper
6
6
 
7
- def initialize(component_class)
8
- @component_class = component_class
7
+ def initialize(props_wrapper = Class.new(Component::PropsWrapper))
8
+ @props_wrapper = props_wrapper
9
9
  end
10
10
 
11
11
  def self.build(&block)
@@ -70,7 +70,7 @@ module React
70
70
 
71
71
  def define_rule(name, options = {})
72
72
  rules[name] = coerce_native_hash_values(options)
73
- @component_class.define_param(name, options[:type]) unless name == :params
73
+ props_wrapper.define_param(name, options[:type])
74
74
  end
75
75
 
76
76
  def errors
@@ -6,19 +6,12 @@ module React
6
6
 
7
7
  if RUBY_ENGINE != 'opal'
8
8
  def self.load_context(ctx, controller, name = nil)
9
- puts "************************** React Server Context Initialized #{name} *********************************************"
10
9
  @context = Context.new("#{controller.object_id}-#{Time.now.to_i}", ctx, controller, name)
11
10
  end
12
11
  else
13
12
  def self.load_context(unique_id = nil, name = nil)
14
13
  # can be called on the client to force re-initialization for testing purposes
15
14
  if !unique_id || !@context || @context.unique_id != unique_id
16
- if on_opal_server?
17
- message = "************************ React Prerendering Context Initialized #{name} ***********************"
18
- else
19
- message = "************************ React Browser Context Initialized ****************************"
20
- end
21
- log(message)
22
15
  @context = Context.new(unique_id)
23
16
  end
24
17
  @context
@@ -1,3 +1,3 @@
1
1
  module React
2
- VERSION = '0.8.8'
2
+ VERSION = "0.9.0"
3
3
  end
@@ -2,39 +2,38 @@
2
2
 
3
3
  if RUBY_ENGINE == 'opal'
4
4
  if `window.React === undefined || window.React.version === undefined`
5
- raise "No React.js Available\n\n"\
6
- "React.js must be defined before requiring 'reactrb'\n"\
7
- "'reactrb' has been tested with react v13, v14, and v15.\n\n"\
8
- "IF USING 'react-rails':\n"\
9
- " add 'require \"react\"' immediately before the 'require \"reactive-ruby\" "\
10
- "directive in 'views/components.rb'.\n"\
11
- "IF USING WEBPACK:\n"\
12
- " add 'react' to your webpack manifest.\n"\
13
- "OTHERWISE TO GET THE LATEST TESTED VERSION\n"\
14
- " add 'require \"react-latest\"' immediately before the require of 'reactrb',\n"\
15
- "OR TO USE A SPECIFIC VERSION\n"\
16
- " add 'require \"react-v1x\"' immediately before the require of 'reactrb'."
5
+ raise [
6
+ "No React.js Available",
7
+ "",
8
+ "A global `React` must be defined before requiring 'reactrb'",
9
+ "",
10
+ "To USE THE BUILT-IN SOURCE: ",
11
+ " add 'require \"react/react-source\"' immediately before the 'require \"reactrb\" directive.",
12
+ "IF USING WEBPACK:",
13
+ " add 'react' to your webpack manifest."
14
+ ].join("\n")
17
15
  end
18
16
  require 'react/hash'
19
17
  require 'react/top_level'
20
18
  require 'react/observable'
19
+ require 'react/validator'
21
20
  require 'react/component'
22
21
  require 'react/component/dsl_instance_methods'
22
+ require 'react/component/should_component_update'
23
23
  require 'react/component/tags'
24
24
  require 'react/component/base'
25
25
  require 'react/element'
26
26
  require 'react/event'
27
27
  require 'react/api'
28
- require 'react/validator'
29
28
  require 'react/rendering_context'
30
29
  require 'react/state'
30
+ require 'react/object'
31
31
  require 'reactive-ruby/isomorphic_helpers'
32
32
  require 'rails-helpers/top_level_rails_component'
33
33
  require 'reactive-ruby/version'
34
34
 
35
35
  else
36
36
  require 'opal'
37
- require 'opal-browser'
38
37
  # rubocop:disable Lint/HandleExceptions
39
38
  begin
40
39
  require 'opal-jquery'
@@ -49,4 +48,5 @@ else
49
48
 
50
49
  Opal.append_path File.expand_path('../', __FILE__).untaint
51
50
  Opal.append_path File.expand_path('../sources/', __FILE__).untaint
51
+ require "react/react-source"
52
52
  end
@@ -0,0 +1,24 @@
1
+ # rubocop:disable Style/FileName
2
+ # require 'reactrb/deep-compare' to get 0.9 deep compare behavior
3
+ module React
4
+ module Component
5
+ module ShouldComponentUpdate
6
+
7
+ def props_changed?(next_params)
8
+ next_params != props
9
+ end
10
+
11
+ def call_needs_update(next_params, native_next_state)
12
+ component = self
13
+ next_params.define_singleton_method(:changed?) do
14
+ next_params != props
15
+ end
16
+ next_state = Hash.new(native_next_state)
17
+ next_state.define_singleton_method(:changed?) do
18
+ component.native_state_changed?(native_next_state)
19
+ end
20
+ needs_update?(next_params, next_state)
21
+ end
22
+ end
23
+ end
24
+ end
@@ -1,3 +1,5 @@
1
+ console.error("Warning: loading `react-latest` directly is deprecated. Replace the requires with `react/react-source`.");
2
+
1
3
  /**
2
4
  * React (with addons) v15.0.1
3
5
  */
@@ -1,3 +1,6 @@
1
+ console.error("Warning: loading `react-v13` directly is deprecated. ")
2
+ console.error("Replace the requires with `react/react-source` and add `gem 'react-rails', '~> 1.3.3'` to your Gemfile.");
3
+
1
4
  /**
2
5
  * React (with addons) v0.13.3
3
6
  */
@@ -21639,4 +21642,4 @@ if ("production" !== "development") {
21639
21642
  module.exports = warning;
21640
21643
 
21641
21644
  },{"129":129}]},{},[1])(1)
21642
- });
21645
+ });
@@ -1,3 +1,6 @@
1
+ console.error("Warning: loading `react-v14` directly is deprecated. ")
2
+ console.error("Replace the requires with `react/react-source` and add `gem 'react-rails', '~> 1.6.2'` to your Gemfile.");
3
+
1
4
  /**
2
5
  * React (with addons) v0.14.8
3
6
  */
@@ -20816,87 +20819,3 @@ module.exports = warning;
20816
20819
  })(function(React) {
20817
20820
  return React.__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
20818
20821
  });
20819
- /**
20820
- * ReactDOM v0.14.8
20821
- *
20822
- * Copyright 2013-2015, Facebook, Inc.
20823
- * All rights reserved.
20824
- *
20825
- * This source code is licensed under the BSD-style license found in the
20826
- * LICENSE file in the root directory of this source tree. An additional grant
20827
- * of patent rights can be found in the PATENTS file in the same directory.
20828
- *
20829
- */
20830
- // Based off https://github.com/ForbesLindesay/umd/blob/master/template.js
20831
- ;(function(f) {
20832
- // CommonJS
20833
- if (typeof exports === "object" && typeof module !== "undefined") {
20834
- module.exports = f(require('react'));
20835
-
20836
- // RequireJS
20837
- } else if (typeof define === "function" && define.amd) {
20838
- define(['react'], f);
20839
-
20840
- // <script>
20841
- } else {
20842
- var g;
20843
- if (typeof window !== "undefined") {
20844
- g = window;
20845
- } else if (typeof global !== "undefined") {
20846
- g = global;
20847
- } else if (typeof self !== "undefined") {
20848
- g = self;
20849
- } else {
20850
- // works providing we're not in "use strict";
20851
- // needed for Java 8 Nashorn
20852
- // see https://github.com/facebook/react/issues/3037
20853
- g = this;
20854
- }
20855
- g.ReactDOM = f(g.React);
20856
- }
20857
-
20858
- })(function(React) {
20859
- return React.__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
20860
- });
20861
- /**
20862
- * ReactDOMServer v0.14.8
20863
- *
20864
- * Copyright 2013-2015, Facebook, Inc.
20865
- * All rights reserved.
20866
- *
20867
- * This source code is licensed under the BSD-style license found in the
20868
- * LICENSE file in the root directory of this source tree. An additional grant
20869
- * of patent rights can be found in the PATENTS file in the same directory.
20870
- *
20871
- */
20872
- // Based off https://github.com/ForbesLindesay/umd/blob/master/template.js
20873
- ;(function(f) {
20874
- // CommonJS
20875
- if (typeof exports === "object" && typeof module !== "undefined") {
20876
- module.exports = f(require('react'));
20877
-
20878
- // RequireJS
20879
- } else if (typeof define === "function" && define.amd) {
20880
- define(['react'], f);
20881
-
20882
- // <script>
20883
- } else {
20884
- var g;
20885
- if (typeof window !== "undefined") {
20886
- g = window;
20887
- } else if (typeof global !== "undefined") {
20888
- g = global;
20889
- } else if (typeof self !== "undefined") {
20890
- g = self;
20891
- } else {
20892
- // works providing we're not in "use strict";
20893
- // needed for Java 8 Nashorn
20894
- // see https://github.com/facebook/react/issues/3037
20895
- g = this;
20896
- }
20897
- g.ReactDOMServer = f(g.React);
20898
- }
20899
-
20900
- })(function(React) {
20901
- return React.__SECRET_DOM_SERVER_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
20902
- });
@@ -1,3 +1,6 @@
1
+ console.error("Warning: loading `react-v15` directly is deprecated. ")
2
+ console.error("Replace the requires with `react/react-source` and add `gem 'react-rails', '~> 1.9.0'` to your Gemfile.");
3
+
1
4
  /**
2
5
  * React (with addons) v15.0.1
3
6
  */
Binary file
Binary file
Binary file
@@ -4,6 +4,6 @@ For example assuming you are releasing fix to 0.8.18
4
4
  1. Checkout 0-8-stable
5
5
  2. Update tests, fix the bug and commit the changes.
6
6
  3. Build & Release to RubyGems (Remember the version in version.rb should already be 0.8.19)
7
- 4. Create a tag 'v0.8.19' pointing to that commit. (`tag v0.8.19`)
7
+ 4. Create a tag 'v0.8.19' pointing to that commit.
8
8
  5. Bump the version in 0-8-stable to 0.8.20 so it will be ready for the next patch level release.
9
9
  6. Commit the version bump, and do a `git push --tags` so the new tag goes up
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
20
20
 
21
21
  s.add_dependency 'opal', '>= 0.8.0'
22
22
  s.add_dependency 'opal-activesupport', '>= 0.2.0'
23
- s.add_dependency 'opal-browser', '0.2.0'
23
+ s.add_dependency 'react-rails'
24
24
  s.add_development_dependency 'rake'
25
25
  s.add_development_dependency 'rspec-rails', '3.3.3'
26
26
  s.add_development_dependency 'timecop'
@@ -30,9 +30,8 @@ Gem::Specification.new do |s|
30
30
 
31
31
  # For Test Rails App
32
32
  s.add_development_dependency 'rails', '4.2.4'
33
- s.add_development_dependency 'react-rails'
33
+ s.add_development_dependency 'mime-types', '< 3'
34
34
  s.add_development_dependency 'opal-rails'
35
- s.add_development_dependency 'pry'
36
35
  if RUBY_PLATFORM == 'java'
37
36
  s.add_development_dependency 'jdbc-sqlite3'
38
37
  s.add_development_dependency 'activerecord-jdbcsqlite3-adapter'
@@ -0,0 +1,76 @@
1
+ require 'spec_helper'
2
+
3
+ if opal?
4
+ describe React::Children do
5
+ let(:component) {
6
+ Class.new do
7
+ include React::Component
8
+ def render
9
+ div { 'lorem' }
10
+ end
11
+ end
12
+ }
13
+ let(:childs) { [React.create_element('a'), React.create_element('li')] }
14
+ let(:element) { React.create_element(component) { childs } }
15
+ let(:children) { described_class.new(`#{element.to_n}.props.children`) }
16
+
17
+ before(:each) do
18
+ renderElementToDocument(element)
19
+ end
20
+
21
+ it 'is enumerable' do
22
+ nodes = children.map { |elem| elem.element_type }
23
+ expect(nodes).to eq(['a', 'li'])
24
+ end
25
+
26
+ it 'returns an Enumerator when not providing a block' do
27
+ nodes = children.each
28
+ expect(nodes).to be_a(Enumerator)
29
+ expect(nodes.size).to eq(2)
30
+ end
31
+
32
+ describe '#each' do
33
+ it 'returns an array of elements' do
34
+ nodes = children.each { |elem| elem.element_type }
35
+ expect(nodes).to be_a(Array)
36
+ expect(nodes.map(&:class)).to eq(childs.map(&:class))
37
+ end
38
+ end
39
+
40
+ describe '#length' do
41
+ it 'returns the number of child elements' do
42
+ expect(children.length).to eq(2)
43
+ end
44
+ end
45
+
46
+ describe 'with single child element' do
47
+ let(:childs) { [React.create_element('a')] }
48
+
49
+ it 'is enumerable containing single element' do
50
+ nodes = children.map { |elem| elem.element_type }
51
+ expect(nodes).to eq(['a'])
52
+ end
53
+
54
+ describe '#length' do
55
+ it 'returns the number of child elements' do
56
+ expect(children.length).to eq(1)
57
+ end
58
+ end
59
+ end
60
+
61
+ describe 'with no child element' do
62
+ let(:element) { React.create_element(component) }
63
+
64
+ it 'is enumerable containing no elements' do
65
+ nodes = children.map { |elem| elem.element_type }
66
+ expect(nodes).to eq([])
67
+ end
68
+
69
+ describe '#length' do
70
+ it 'returns the number of child elements' do
71
+ expect(children.length).to eq(0)
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end