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

Commit fab4124

Browse files
committed
Fix unmount_component_at_node test
1 parent ef892d2 commit fab4124

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

lib/react/top_level_render.rb

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
11
module React
22
def self.render(element, container)
33
container = `container.$$class ? container[0] : container`
4+
5+
cb = %x{
6+
function(){
7+
setTimeout(function(){
8+
#{yield if block_given?}
9+
}, 0)
10+
}
11+
}
12+
413
if !(`typeof ReactDOM === 'undefined'`)
5-
native = `ReactDOM.render(#{element.to_n}, container, function(){#{yield if block_given?}})` # v0.15+
14+
native = `ReactDOM.render(#{element.to_n}, container, cb)` # v0.15+
615
elsif !(`typeof React.renderToString === 'undefined'`)
7-
native = `React.render(#{element.to_n}, container, function(){#{yield if block_given?}})`
16+
native = `React.render(#{element.to_n}, container, cb)`
817
else
918
raise "render is not defined. In React >= v15 you must import it with ReactDOM"
1019
end
1120

1221
if `#{native}._getOpalInstance !== undefined`
1322
`#{native}._getOpalInstance()`
14-
elsif `React.findDOMNode !== undefined && #{native}.nodeType == undefined`
23+
elsif `React.findDOMNode !== undefined && #{native}.nodeType === undefined`
1524
`React.findDOMNode(#{native})`
1625
else
1726
native

0 commit comments

Comments
 (0)