Skip to content

Tie MultiChild queue to ReactReconcileTransaction #1157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/browser/ReactReconcileTransaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var CallbackQueue = require('CallbackQueue');
var PooledClass = require('PooledClass');
var ReactEventEmitter = require('ReactEventEmitter');
var ReactInputSelection = require('ReactInputSelection');
var ReactMultiChildUpdateQueue = require('ReactMultiChildUpdateQueue');
var ReactPutListenerQueue = require('ReactPutListenerQueue');
var Transaction = require('Transaction');

Expand Down Expand Up @@ -98,12 +99,23 @@ var PUT_LISTENER_QUEUEING = {
}
};

var MULTI_CHILD_UPDATE_QUEUEING = {
initialize: function() {
this.multiChildUpdateQueue.reset();
},

close: function() {
this.multiChildUpdateQueue.processUpdates();
}
};

/**
* Executed within the scope of the `Transaction` instance. Consider these as
* being member methods, but with an implied ordering while being isolated from
* each other.
*/
var TRANSACTION_WRAPPERS = [
MULTI_CHILD_UPDATE_QUEUEING,
PUT_LISTENER_QUEUEING,
SELECTION_RESTORATION,
EVENT_SUPPRESSION,
Expand Down Expand Up @@ -134,6 +146,7 @@ function ReactReconcileTransaction() {
this.renderToStaticMarkup = false;
this.reactMountReady = CallbackQueue.getPooled(null);
this.putListenerQueue = ReactPutListenerQueue.getPooled();
this.multiChildUpdateQueue = ReactMultiChildUpdateQueue.getPooled();
}

var Mixin = {
Expand All @@ -159,6 +172,10 @@ var Mixin = {
return this.putListenerQueue;
},

getMultiChildUpdateQueue: function() {
return this.multiChildUpdateQueue;
},

/**
* `PooledClass` looks for this, and will invoke this before allowing this
* instance to be resused.
Expand Down
4 changes: 2 additions & 2 deletions src/browser/ui/ReactDOMComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,12 +377,12 @@ ReactDOMComponent.Mixin = {
if (lastChildren != null && nextChildren == null) {
this.updateChildren(null, transaction);
} else if (lastHasContentOrHtml && !nextHasContentOrHtml) {
this.updateTextContent('');
this.updateTextContent('', transaction);
}

if (nextContent != null) {
if (lastContent !== nextContent) {
this.updateTextContent('' + nextContent);
this.updateTextContent('' + nextContent, transaction);
}
} else if (nextHtml != null) {
if (lastHtml !== nextHtml) {
Expand Down
2 changes: 2 additions & 0 deletions src/browser/ui/__tests__/ReactDOMComponent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ describe('ReactDOMComponent', function() {

expect(stub.getDOMNode().innerHTML).toEqual(':)');
stub.receiveComponent({props: {}}, transaction);
transaction.getMultiChildUpdateQueue().processUpdates();
expect(stub.getDOMNode().innerHTML).toEqual('');
});

Expand All @@ -180,6 +181,7 @@ describe('ReactDOMComponent', function() {

expect(stub.getDOMNode().innerHTML).toEqual('bonjour');
stub.receiveComponent({props: {children: 'adieu'}}, transaction);
transaction.getMultiChildUpdateQueue().processUpdates();
expect(stub.getDOMNode().innerHTML).toEqual('adieu');
});

Expand Down
Loading