Skip to content

Commit

Permalink
Merge 3c17e3e into 73866a4
Browse files Browse the repository at this point in the history
  • Loading branch information
rpetrich authored Aug 17, 2018
2 parents 73866a4 + 3c17e3e commit b02865a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/render-queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ export function enqueueRender(component) {

/** Rerender all enqueued dirty components */
export function rerender() {
let p, list = items;
items = [];
while ( (p = list.pop()) ) {
let p;
while ( (p = items.pop()) ) {
if (p._dirty) renderComponent(p);
}
}
19 changes: 19 additions & 0 deletions test/browser/lifecycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -1440,6 +1440,25 @@ describe('Lifecycle methods', () => {


describe('Lifecycle DOM Timing', () => {
it('should render in a single microtask', () => {
class Counter extends Component {
constructor() {
super();
this.state = { count: 0 };
}
render(props, { count }) {
if (count < 2) {
this.setState({ count: count + 1 });
}
return count;
}
}
render(<Counter />, scratch);
rerender();
expect(scratch.textContent).to.equal("2");
rerender();
});

it('should be invoked when dom does (DidMount, WillUnmount) or does not (WillMount, DidUnmount) exist', () => {
let setState;
class Outer extends Component {
Expand Down

0 comments on commit b02865a

Please sign in to comment.