From 5158ab1e380f2625628a58bfb8d06533bd05a599 Mon Sep 17 00:00:00 2001 From: Juan Tejada Date: Sun, 10 Jan 2016 16:25:31 -0800 Subject: [PATCH] fix(injected-component): Correctly call methods to the injected instance - Adds check to `_runInnerDOMMethod` to check if inner is an UnsafeComponent and relay the call appropriately - Removes duplicated logic from `_setRequiredMethods` --- src/components/injected-component.cjsx | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/components/injected-component.cjsx b/src/components/injected-component.cjsx index d0b22808a..bda5aea52 100644 --- a/src/components/injected-component.cjsx +++ b/src/components/injected-component.cjsx @@ -127,27 +127,26 @@ class InjectedComponent extends React.Component # 2. Any native implementation provided by the DOM # 3. Ourselves, so that the method always has /some/ effect. # - _runInnerDOMMethod: (method) => + _runInnerDOMMethod: (method, args...) => target = null - if @refs.inner and @refs.inner[method] + if @refs.inner instanceof UnsafeComponent and @refs.inner.injected[method]? + target = @refs.inner.injected + else if @refs.inner and @refs.inner[method]? target = @refs.inner else if @refs.inner target = React.findDOMNode(@refs.inner) else target = React.findDOMNode(@) - target[method]?() + target[method].bind(target)(args...) _setRequiredMethods: (methods) => methods.forEach (method) => Object.defineProperty(@, method, configurable: true enumerable: true - get: => - if @refs.inner instanceof UnsafeComponent - @refs.inner.injected[method]?.bind(@refs.inner.injected) - else - @refs.inner[method]?.bind(@refs.inner) + value: (args...)=> + @_runInnerDOMMethod(method, args...) ) _verifyRequiredMethods: =>