Skip to content
This repository has been archived by the owner on Sep 20, 2018. It is now read-only.

Commit

Permalink
[added] react v15.4 support
Browse files Browse the repository at this point in the history
  • Loading branch information
jquense committed Nov 21, 2016
1 parent c0ecc51 commit 3b99824
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"webpack": "^1.12.2"
},
"dependencies": {
"bill": "^3.2.1",
"bill": "^3.2.6",
"dom-helpers": "^2.4.0",
"invariant": "^2.2.0",
"lodash": "^3.10.1",
Expand Down
4 changes: 2 additions & 2 deletions src/element.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ function spyOnUpdate(inst, fn) {
let didUpdate = inst.componentDidUpdate;

inst.componentDidUpdate = function(...args) {
fn(...args)
didUpdate && didUpdate(...args)
fn.apply(this, args)
didUpdate && didUpdate.apply(this, args)
}
}

Expand Down
31 changes: 21 additions & 10 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
import React from 'react';
import ReactDOM from 'react-dom';
import {
getID, getNode, findReactContainerForID
, getReactRootID, _instancesByReactRootID } from 'react/lib/ReactMount';
import ReactTestUtils from'react-addons-test-utils';
import ReactTestUtils from 'react-addons-test-utils';
import invariant from 'invariant';

import bill from 'bill';
import { ifDef } from 'bill/compat';
import { createNode, NODE_TYPES } from 'bill/node';

let ReactMount = {};

try {
ReactMount = ifDef({
'>=15.4.x': () => require('react-dom/lib/ReactMount'),
'*': () => require('react/lib/ReactMount')
})();
} catch (err) { /* empty */ }

let {
getID, getNode, findReactContainerForID
, getReactRootID, _instancesByReactRootID } = ReactMount;

export let isDOMComponent = ReactTestUtils.isDOMComponent;

export function assertLength(collection, method) {
Expand Down Expand Up @@ -176,14 +186,15 @@ export function wrapElement(element, context, prevWrapper) {
}

export let getMountPoint = ifDef({
'<15': function getMountPoint(instance) {
var id = getID(findDOMNode(instance));
return findReactContainerForID(id);
},
'*': function getMountPoint(instance) {
'>=15.x.x': function getMountPoint(instance) {
let privInst = createNode(instance).privateInstance
let container = createNode(privInst._nativeContainerInfo._topLevelWrapper)
let info = privInst._nativeContainerInfo || privInst._hostContainerInfo;
let container = createNode(info._topLevelWrapper)
return findDOMNode(container.instance).parentNode
},
'*': function getMountPoint(instance) {
var id = getID(findDOMNode(instance));
return findReactContainerForID(id);
}
})

Expand Down
1 change: 0 additions & 1 deletion test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ describe('common', ()=> {
})

it('props() should change props', ()=> {

render(<Example name='rikki-tikki-tavi'/>)
.tap(inst => {
inst.first('div > :text').unwrap()
Expand Down

0 comments on commit 3b99824

Please sign in to comment.