Skip to content

Commit f187393

Browse files
committed
Change unmountRoot to expect only one root
1 parent 3672e24 commit f187393

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

react_ujs/index.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -188,18 +188,17 @@ var ReactRailsUJS = {
188188
},
189189

190190
unmountRoot: function(node) {
191-
var targetRoots = this.roots.filter(
192-
function(rootElement) {
193-
return rootElement["node"] && (rootElement["node"] === node)
194-
}
195-
)
196-
targetRoots.forEach(
191+
var targetRoot = this.findRoot(node);
192+
if (targetRoot) {
193+
return;
194+
}
195+
196+
targetRoot["root"].unmount();
197+
this.roots = this.roots.filter(
197198
function(rootElement) {
198-
rootElement["root"].unmount();
199-
rootElement["root"] = null;
200-
rootElement["node"] = null;
199+
return rootElement["node"] !== node
201200
}
202-
)
201+
);
203202
}
204203
}
205204

0 commit comments

Comments
 (0)