isomorfeus-react 16.9.6 → 16.9.7

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: 3db41ef26a24fa9c7fc245c8b438898364fe03203c954a5aafe3c5d871626f88
4
- data.tar.gz: 5967eab20528f06f4f273e1294dd82cd6f53ed66c3c6f212bfcfb7081b984a6b
3
+ metadata.gz: a8597a16d99c067226f1832565d36bf5c9021a4f5b54a1ee2cd23c1c6da4309a
4
+ data.tar.gz: e712d0ebd4a43cf8e6311dfb1cf7b8dacdc1da3aed607f846f28fbd9a95c82dd
5
5
  SHA512:
6
- metadata.gz: 14153b0edb03c88fb5f17716ceee0fddd64a473fee15cde590b89abe012b16b0a765327b0d6a76d0020ac518b5bddd79a35211b71617a87ad682525043b39bbd
7
- data.tar.gz: 9e4ce1d9545488c3873043d34b79f4add71b46e47b883e766af9e8337fdd91183c14d5c5525d2c56fad3d77ed8a697aac291425e8db9925536c35ceea037487f
6
+ metadata.gz: 46507c9416c5c04f684e4ceea2e7667c8c90976ded05c8ddb0e268b7420fc97bb1a41a2a37a57f5aa39d2b0ad5699d4ae74e3e93582251b56aa726c7ff30e497
7
+ data.tar.gz: 5884fb376630de3ae0fe2100dd86dd59c38b9918f9beb79ce38339a43049aa897b353a3e3dfe2630575187786c5515efc94e02e0307e394934db69ee325ed225
@@ -73,7 +73,14 @@ module Isomorfeus
73
73
  end
74
74
 
75
75
  def force_render
76
- top_component.JS.forceUpdate()
76
+ begin
77
+ if top_component
78
+ ReactDOM.find_dom_node(top_component) # if not mounted will raise
79
+ top_component.JS.forceUpdate()
80
+ end
81
+ rescue
82
+ `location.reload()` if on_browser?
83
+ end
77
84
  nil
78
85
  end
79
86
  end
@@ -6,21 +6,26 @@ module Isomorfeus
6
6
  root_element = `document.querySelector('div[data-iso-root]')`
7
7
  component_name = root_element.JS.getAttribute('data-iso-root')
8
8
  Isomorfeus.env = root_element.JS.getAttribute('data-iso-env')
9
- component = component_name.constantize
10
- props_json = root_element.JS.getAttribute('data-iso-props')
11
- props = `Opal.Hash.$new(JSON.parse(props_json))`
12
- hydrated = root_element.JS.getAttribute('data-iso-hydrated')
13
- state_json = root_element.JS.getAttribute('data-iso-state')
14
- if state_json
15
- %x{
16
- var state = JSON.parse(state_json);
17
- var keys = Object.keys(state);
18
- for(var i=0; i < keys.length; i++) {
19
- global.Opal.Isomorfeus.store.native.dispatch({ type: keys[i].toUpperCase(), set_state: state[keys[i]] });
9
+ begin
10
+ component = component_name.constantize
11
+ props_json = root_element.JS.getAttribute('data-iso-props')
12
+ props = `Opal.Hash.$new(JSON.parse(props_json))`
13
+ hydrated = root_element.JS.getAttribute('data-iso-hydrated')
14
+ state_json = root_element.JS.getAttribute('data-iso-state')
15
+ if state_json
16
+ %x{
17
+ var state = JSON.parse(state_json);
18
+ var keys = Object.keys(state);
19
+ for(var i=0; i < keys.length; i++) {
20
+ global.Opal.Isomorfeus.store.native.dispatch({ type: keys[i].toUpperCase(), set_state: state[keys[i]] });
21
+ }
20
22
  }
21
- }
23
+ end
24
+ mount_component(component, props, root_element, hydrated)
25
+ rescue
26
+ @timeout_start = Time.now unless @timeout_start
27
+ `setTimeout(#{mount!}, 100)` if (Time.now - @timeout_start) < 10
22
28
  end
23
- mount_component(component, props, root_element, hydrated)
24
29
  end
25
30
  end
26
31
 
@@ -4,9 +4,22 @@ module LucidMaterial
4
4
  def self.included(base)
5
5
  base.instance_exec do
6
6
  def styles(styles_hash = nil, &block)
7
- styles_hash = block.call if block_given?
8
- `base.jss_styles = #{styles_hash.to_n}` if styles_hash
9
- `Opal.Hash.$new(base.jss_styles)`
7
+ if block_given?
8
+ %x{
9
+ base.jss_styles = function(theme) {
10
+ var result = block.$call(Opal.Hash.$new(theme));
11
+ return result.$to_n();
12
+ }
13
+ }
14
+ nil
15
+ elsif styles_hash
16
+ `base.jss_styles = #{styles_hash.to_n}` if styles_hash
17
+ styles_hash
18
+ elsif `typeof base.jss_styles === 'object'`
19
+ `Opal.Hash.$new(base.jss_styles)`
20
+ else
21
+ nil
22
+ end
10
23
  end
11
24
  end
12
25
 
data/lib/react/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module React
2
- VERSION = '16.9.6'
2
+ VERSION = '16.9.7'
3
3
  end
data/lib/react_dom.rb CHANGED
@@ -6,7 +6,7 @@ module ReactDOM
6
6
  end
7
7
 
8
8
  def find_dom_node(native_react_component)
9
- `Opal.global.ReactDOM.findDomNode(native_react_component)`
9
+ `Opal.global.ReactDOM.findDOMNode(native_react_component)`
10
10
  end
11
11
 
12
12
  def hydrate(native_react_element, container, &block)
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.9.6
4
+ version: 16.9.7
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-08-20 00:00:00.000000000 Z
11
+ date: 2019-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oj