Skip to content
This repository has been archived by the owner on Dec 16, 2021. It is now read-only.

Commit

Permalink
Should export instance when call renderSubtreeIntoContainer. (#296)
Browse files Browse the repository at this point in the history
  • Loading branch information
windyGex authored and developit committed Feb 7, 2017
1 parent fd00bad commit 57082d6
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ function renderSubtreeIntoContainer(parentComponent, vnode, container, callback)
let wrap = h(ContextProvider, { context: parentComponent.context }, vnode);
let c = render(wrap, container);
if (callback) callback(c);
return c;
return c._component || c.base;
}


Expand Down
31 changes: 30 additions & 1 deletion test/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { render, createClass, createElement, cloneElement, Component, PropTypes } from '../src';
import React, { render, createClass, createElement, cloneElement, Component, PropTypes, unstable_renderSubtreeIntoContainer } from '../src';

describe('preact-compat', () => {
describe('render()', () => {
Expand Down Expand Up @@ -238,4 +238,33 @@ describe('preact-compat', () => {
expect(cloneElement(element)).to.eql(element);
});
});

describe('unstable_renderSubtreeIntoContainer', () => {
it('should export instance', () => {
class Inner extends Component {
render() {
return null;
}
getNode() {
return 'inner';
}
}

class App extends Component {
render() {
return null;
}
componentDidMount() {
this.renderInner();
}
renderInner() {
const wrapper = document.createElement('div');
this.inner = unstable_renderSubtreeIntoContainer(this, <Inner/>, wrapper);
}
}
const root = document.createElement('div');
const app = render(<App/>, root);
expect(typeof app.inner.getNode === 'function').to.equal(true);
});
});
});

0 comments on commit 57082d6

Please sign in to comment.