From de98e0b232509d5f40c135d540a70e415272ff85 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 3 May 2017 15:35:00 +0200 Subject: node_modules --- .../react-dom/lib/ReactTestReconcileTransaction.js | 128 +++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 node_modules/react-dom/lib/ReactTestReconcileTransaction.js (limited to 'node_modules/react-dom/lib/ReactTestReconcileTransaction.js') diff --git a/node_modules/react-dom/lib/ReactTestReconcileTransaction.js b/node_modules/react-dom/lib/ReactTestReconcileTransaction.js new file mode 100644 index 000000000..ecc1818d1 --- /dev/null +++ b/node_modules/react-dom/lib/ReactTestReconcileTransaction.js @@ -0,0 +1,128 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * + */ +'use strict'; + +var _assign = require('object-assign'); + +var CallbackQueue = require('./CallbackQueue'); +var PooledClass = require('./PooledClass'); +var Transaction = require('./Transaction'); +var ReactUpdateQueue = require('./ReactUpdateQueue'); + +/** + * Provides a `CallbackQueue` queue for collecting `onDOMReady` callbacks during + * the performing of the transaction. + */ +var ON_DOM_READY_QUEUEING = { + /** + * Initializes the internal `onDOMReady` queue. + */ + initialize: function () { + this.reactMountReady.reset(); + }, + + /** + * After DOM is flushed, invoke all registered `onDOMReady` callbacks. + */ + close: function () { + this.reactMountReady.notifyAll(); + } +}; + +/** + * 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 = [ON_DOM_READY_QUEUEING]; + +/** + * Currently: + * - The order that these are listed in the transaction is critical: + * - Suppresses events. + * - Restores selection range. + * + * Future: + * - Restore document/overflow scroll positions that were unintentionally + * modified via DOM insertions above the top viewport boundary. + * - Implement/integrate with customized constraint based layout system and keep + * track of which dimensions must be remeasured. + * + * @class ReactTestReconcileTransaction + */ +function ReactTestReconcileTransaction(testOptions) { + this.reinitializeTransaction(); + this.testOptions = testOptions; + this.reactMountReady = CallbackQueue.getPooled(this); +} + +var Mixin = { + /** + * @see Transaction + * @abstract + * @final + * @return {array} List of operation wrap procedures. + * TODO: convert to array + */ + getTransactionWrappers: function () { + return TRANSACTION_WRAPPERS; + }, + + /** + * @return {object} The queue to collect `onDOMReady` callbacks with. + * TODO: convert to ReactMountReady + */ + getReactMountReady: function () { + return this.reactMountReady; + }, + + /** + * @return {object} the options passed to ReactTestRenderer + */ + getTestOptions: function () { + return this.testOptions; + }, + + /** + * @return {object} The queue to collect React async events. + */ + getUpdateQueue: function () { + return ReactUpdateQueue; + }, + + /** + * Save current transaction state -- if the return value from this method is + * passed to `rollback`, the transaction will be reset to that state. + */ + checkpoint: function () { + // reactMountReady is the our only stateful wrapper + return this.reactMountReady.checkpoint(); + }, + + rollback: function (checkpoint) { + this.reactMountReady.rollback(checkpoint); + }, + + /** + * `PooledClass` looks for this, and will invoke this before allowing this + * instance to be reused. + */ + destructor: function () { + CallbackQueue.release(this.reactMountReady); + this.reactMountReady = null; + } +}; + +_assign(ReactTestReconcileTransaction.prototype, Transaction, ReactTestReconcileTransaction, Mixin); + +PooledClass.addPoolingTo(ReactTestReconcileTransaction); + +module.exports = ReactTestReconcileTransaction; \ No newline at end of file -- cgit v1.2.3