isomorfeus-react 16.10.5 → 16.10.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b2286c84dc8c51cc28fd6940b07a021109025122954b2784c2cb19e51da0b648
4
- data.tar.gz: 778d14cf5a6369e19ef96fad94126df299a15585c95ce346af959579bc3c8c90
3
+ metadata.gz: afd9951ac47f6c2ed3fea7f8135ba03f63c596c52c3f795901fa974d9c36eb2e
4
+ data.tar.gz: 80b4226998ea64b6d12ee0a56959d77ca96e78eebb8f553375a7785d8490a800
5
5
  SHA512:
6
- metadata.gz: 8471a64f958f5f4eea8d77fcf0cc9f9b746de2ce8c6b2c088ca17dfb760498d286fad0dc8408cd7a7b8c492102b9e1a46ec9bf3361317eb474a61ad0ac9466ec
7
- data.tar.gz: fc964591e3c95ae164ba3a910bbc966612f3fc02ac29774e16079b6df22a17b8b9c4a332cc4bd9906ee40f696f2cbdf4668fd392f95c5ee913a69a0cf7c0421e
6
+ metadata.gz: a3f3edfbf9c1a600504dd1125721da402dd8ba4bbe56d026a0b62083425b416eb3de66882f46afaf59b07c8c81ae60b929e34d12062698e001c6248324136fab
7
+ data.tar.gz: 94d226fca0ad5fdf2699d8dfbbad78777248877ae5d665831b395cfbf12008edbb897e7d0d0b2f4810fd35da95ab9f862a517571db8ad8422dd8f64c29542475
data/README.md CHANGED
@@ -22,7 +22,7 @@ Component Types:
22
22
  - [Function and Memo Component](https://github.com/isomorfeus/isomorfeus-react/blob/master/ruby/docs/function_component.md)
23
23
  - [Lucid App, Lucid Component](https://github.com/isomorfeus/isomorfeus-react/blob/master/ruby/docs/lucid_component.md)
24
24
  - [LucidMaterial App, LucidMaterial Component](https://github.com/isomorfeus/isomorfeus-react/blob/master/ruby/docs/lucid_material_component.md) - support for [MaterialUI](https://material-ui.com)
25
- - [React Javascript Component](https://github.com/isomorfeus/isomorfeus-react/blob/master/ruby/docs/javascript_component.md)
25
+ - [React Javascript Components and React Elements](https://github.com/isomorfeus/isomorfeus-react/blob/master/ruby/docs/javascript_component.md)
26
26
 
27
27
  Which component to use?
28
28
  - Usually LucidApp and LucidComponent along with some imported javascript components.
@@ -61,3 +61,8 @@ https://github.com/facebook/react-devtools
61
61
  - clone repo
62
62
  - `bundle install`
63
63
  - `rake`
64
+
65
+ Implementations for the [js-framework-benchmark](https://github.com/krausest/js-framework-benchmark):
66
+
67
+ - [using LucidComponent](https://github.com/janbiedermann/js-framework-benchmark/tree/master/frameworks/keyed/isomorfeus-lucid)
68
+ - [using React::Component](https://github.com/janbiedermann/js-framework-benchmark/tree/master/frameworks/keyed/isomorfeus-react)
@@ -71,7 +71,6 @@ if RUBY_ENGINE == 'opal'
71
71
  require 'react/component/location'
72
72
  require 'react/component/history'
73
73
  require 'react/component/resolution'
74
- require 'react/component/should_component_update'
75
74
  require 'react/component/event_handler'
76
75
  require 'react/component/styles'
77
76
  require 'react/component/mixin'
@@ -4,7 +4,6 @@ module LucidApp
4
4
  base.include(::Native::Wrapper)
5
5
  base.extend(::LucidApp::NativeComponentConstructor)
6
6
  base.extend(::LucidPropDeclaration::Mixin)
7
- base.extend(::React::Component::ShouldComponentUpdate)
8
7
  base.extend(::LucidComponent::EventHandler)
9
8
  base.include(::React::Component::Elements)
10
9
  base.include(::React::Component::API)
@@ -57,14 +57,6 @@ module LucidComponent
57
57
  return this.context;
58
58
  }
59
59
  shouldComponentUpdate(next_props, next_state) {
60
- var next_props_keys = Object.keys(next_props);
61
- var this_props_keys = Object.keys(this.props);
62
- if (next_props_keys.length !== this_props_keys.length) { return true; }
63
-
64
- var next_state_keys = Object.keys(next_state);
65
- var this_state_keys = Object.keys(this.state);
66
- if (next_state_keys.length !== this_state_keys.length) { return true; }
67
-
68
60
  for (var property in next_props) {
69
61
  if (next_props.hasOwnProperty(property)) {
70
62
  if (!this.props.hasOwnProperty(property)) { return true; };
@@ -5,7 +5,6 @@ module LucidMaterial
5
5
  base.include(::Native::Wrapper)
6
6
  base.extend(::LucidMaterial::App::NativeComponentConstructor)
7
7
  base.extend(::LucidPropDeclaration::Mixin)
8
- base.extend(::React::Component::ShouldComponentUpdate)
9
8
  base.extend(::LucidComponent::EventHandler)
10
9
  base.include(::React::Component::Elements)
11
10
  base.include(::React::Component::API)
@@ -58,14 +58,6 @@ module LucidMaterial
58
58
  return this.context;
59
59
  }
60
60
  shouldComponentUpdate(next_props, next_state) {
61
- var next_props_keys = Object.keys(next_props);
62
- var this_props_keys = Object.keys(this.props);
63
- if (next_props_keys.length !== this_props_keys.length) { return true; }
64
-
65
- var next_state_keys = Object.keys(next_state);
66
- var this_state_keys = Object.keys(this.state);
67
- if (next_state_keys.length !== this_state_keys.length) { return true; }
68
-
69
61
  for (var property in next_props) {
70
62
  if (next_props.hasOwnProperty(property)) {
71
63
  if (!this.props.hasOwnProperty(property)) { return true; };
data/lib/react.rb CHANGED
@@ -17,7 +17,6 @@ module React
17
17
  self.lower_camelize = function(snake_cased_word) {
18
18
  var parts = snake_cased_word.split('_');
19
19
  var res = parts[0];
20
- if (parts.length === 1) { return res; }
21
20
  for (var i = 1; i < parts.length; i++) {
22
21
  res += parts[i][0].toUpperCase() + parts[i].slice(1);
23
22
  }
@@ -34,24 +33,25 @@ module React
34
33
  var result = {};
35
34
  var keys = ruby_style_props.$keys();
36
35
  var keys_length = keys.length;
36
+ let key;
37
37
  for (var i = 0; i < keys_length; i++) {
38
- if (keys[i].startsWith("on_")) {
39
- var handler = ruby_style_props['$[]'](keys[i]);
38
+ key = keys[i];
39
+ if (key[0] === 'o' && key[1] === 'n' && key[2] === '_') {
40
+ var handler = ruby_style_props['$[]'](key);
40
41
  if (typeof handler === "function") {
41
- result[Opal.React.lower_camelize(keys[i])] = handler;
42
+ result[Opal.React.lower_camelize(key)] = handler;
42
43
  } else {
43
44
  var active_component = Opal.React.active_component();
44
- result[Opal.React.lower_camelize(keys[i])] = active_component[handler];
45
+ result[Opal.React.lower_camelize(key)] = active_component[handler];
45
46
  }
46
- } else if (keys[i].startsWith("aria_")) {
47
- result[keys[i].replace("_", "-")] = ruby_style_props['$[]'](keys[i]);
48
- } else if (keys[i] === "style") {
49
- var val = ruby_style_props['$[]'](keys[i]);
47
+ } else if (key[0] === 'a' && key.startsWith("aria_")) {
48
+ result[key.replace("_", "-")] = ruby_style_props['$[]'](key);
49
+ } else if (keys === "style") {
50
+ var val = ruby_style_props['$[]'](key);
50
51
  if (typeof val.$$is_hash !== "undefined") { val = val.$to_n() }
51
52
  result["style"] = val;
52
53
  } else {
53
- let key = keys[i];
54
- result[Opal.React.lower_camelize(keys[i])] = ruby_style_props['$[]'](keys[i]);
54
+ result[key.indexOf('_') > 0 ? Opal.React.lower_camelize(key) : key] = ruby_style_props['$[]'](key);
55
55
  }
56
56
  }
57
57
  return result;
@@ -47,6 +47,10 @@ module React
47
47
  def render(&block)
48
48
  `base.render_block = block`
49
49
  end
50
+
51
+ def should_component_update?(&block)
52
+ `base.should_component_update_block = block`
53
+ end
50
54
  end
51
55
  end
52
56
 
@@ -5,7 +5,6 @@ module React
5
5
  base.include(::Native::Wrapper)
6
6
  base.extend(::React::Component::NativeComponentConstructor)
7
7
  base.extend(::LucidPropDeclaration::Mixin)
8
- base.extend(::React::Component::ShouldComponentUpdate)
9
8
  base.extend(::React::Component::EventHandler)
10
9
  base.include(::React::Component::Elements)
11
10
  base.include(::React::Component::API)
@@ -48,40 +48,31 @@ module React
48
48
  return Opal.React.render_buffer.pop();
49
49
  }
50
50
  shouldComponentUpdate(next_props, next_state) {
51
- if (base.has_custom_should_component_update) {
52
- return this.__ruby_instance["$should_component_update"](#{(Hash.new(next_props))}, #{Hash.new(next_state)});
53
- } else {
54
- var next_props_keys = Object.keys(next_props);
55
- var this_props_keys = Object.keys(this.props);
56
- if (next_props_keys.length !== this_props_keys.length) { return true; }
57
-
58
- var next_state_keys = Object.keys(next_state);
59
- var this_state_keys = Object.keys(this.state);
60
- if (next_state_keys.length !== this_state_keys.length) { return true; }
61
-
62
- for (var property in next_props) {
63
- if (next_props.hasOwnProperty(property)) {
64
- if (!this.props.hasOwnProperty(property)) { return true; }
65
- if (property == "children") { if (next_props.children !== this.props.children) { return true; }}
66
- else if (typeof next_props[property] !== "undefined" && next_props[property] !== null &&
67
- typeof next_props[property]['$!='] !== "undefined" &&
68
- typeof this.props[property] !== "undefined" && this.props[property] !== null &&
69
- typeof this.props[property]['$!='] !== "undefined") {
70
- if (#{ !! (`next_props[property]` != `this.props[property]`) }) { return true; }
71
- } else if (next_props[property] !== this.props[property]) { return true; }
72
- }
51
+ if (base.should_component_update_block) {
52
+ return #{!!`this.__ruby_instance`.instance_exec(React::Component::Props.new(`{props: next_props}`), React::Component::State.new(`{state: next_state }`), &`base.should_component_update_block`)};
53
+ }
54
+ for (var property in next_props) {
55
+ if (next_props.hasOwnProperty(property)) {
56
+ if (!this.props.hasOwnProperty(property)) { return true; }
57
+ if (property == "children") { if (next_props.children !== this.props.children) { return true; }}
58
+ else if (typeof next_props[property] !== "undefined" && next_props[property] !== null &&
59
+ typeof next_props[property]['$!='] !== "undefined" &&
60
+ typeof this.props[property] !== "undefined" && this.props[property] !== null &&
61
+ typeof this.props[property]['$!='] !== "undefined") {
62
+ if (#{ !! (`next_props[property]` != `this.props[property]`) }) { return true; }
63
+ } else if (next_props[property] !== this.props[property]) { return true; }
73
64
  }
74
- for (var property in next_state) {
75
- if (next_state.hasOwnProperty(property)) {
76
- if (!this.state.hasOwnProperty(property)) { return true; };
77
- if (next_state[property] !== null && typeof next_state[property]['$!='] !== "undefined" &&
78
- this.state[property] !== null && typeof this.state[property]['$!='] !== "undefined") {
79
- if (#{ !! (`next_state[property]` != `this.state[property]`) }) { return true }
80
- } else if (next_state[property] !== this.state[property]) { return true }
81
- }
65
+ }
66
+ for (var property in next_state) {
67
+ if (next_state.hasOwnProperty(property)) {
68
+ if (!this.state.hasOwnProperty(property)) { return true; };
69
+ if (next_state[property] !== null && typeof next_state[property]['$!='] !== "undefined" &&
70
+ this.state[property] !== null && typeof this.state[property]['$!='] !== "undefined") {
71
+ if (#{ !! (`next_state[property]` != `this.state[property]`) }) { return true }
72
+ } else if (next_state[property] !== this.state[property]) { return true }
82
73
  }
83
- return false;
84
74
  }
75
+ return false;
85
76
  }
86
77
  validateProp(props, propName, componentName) {
87
78
  try { base.$validate_prop(propName, props[propName]) }
data/lib/react/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module React
2
- VERSION = '16.10.5'
2
+ VERSION = '16.10.6'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isomorfeus-react
3
3
  version: !ruby/object:Gem::Version
4
- version: 16.10.5
4
+ version: 16.10.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Biedermann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-07 00:00:00.000000000 Z
11
+ date: 2019-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oj
@@ -217,7 +217,6 @@ files:
217
217
  - lib/react/component/native_component_constructor.rb
218
218
  - lib/react/component/props.rb
219
219
  - lib/react/component/resolution.rb
220
- - lib/react/component/should_component_update.rb
221
220
  - lib/react/component/state.rb
222
221
  - lib/react/component/styles.rb
223
222
  - lib/react/component/unsafe_api.rb
@@ -1,14 +0,0 @@
1
- module React
2
- module Component
3
- module ShouldComponentUpdate
4
- def self.extended(base)
5
- base.define_singleton_method(:should_component_update?) do |&block|
6
- `base.has_custom_should_component_update = true`
7
- define_method(:should_component_update) do |next_props, next_state|
8
- !!block.call(Hash.new(next_props), Hash.new(next_state))
9
- end
10
- end
11
- end
12
- end
13
- end
14
- end