You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.7 KiB
58 lines
1.7 KiB
10 years ago
|
/**
|
||
|
* Copyright 2014-2015, 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.
|
||
|
*
|
||
|
* @providesModule ReactComponentEnvironment
|
||
|
*/
|
||
|
|
||
|
'use strict';
|
||
|
|
||
|
var invariant = require("./invariant");
|
||
|
|
||
|
var injected = false;
|
||
|
|
||
|
var ReactComponentEnvironment = {
|
||
|
|
||
|
/**
|
||
|
* Optionally injectable environment dependent cleanup hook. (server vs.
|
||
|
* browser etc). Example: A browser system caches DOM nodes based on component
|
||
|
* ID and must remove that cache entry when this instance is unmounted.
|
||
|
*/
|
||
|
unmountIDFromEnvironment: null,
|
||
|
|
||
|
/**
|
||
|
* Optionally injectable hook for swapping out mount images in the middle of
|
||
|
* the tree.
|
||
|
*/
|
||
|
replaceNodeWithMarkupByID: null,
|
||
|
|
||
|
/**
|
||
|
* Optionally injectable hook for processing a queue of child updates. Will
|
||
|
* later move into MultiChildComponents.
|
||
|
*/
|
||
|
processChildrenUpdates: null,
|
||
|
|
||
|
injection: {
|
||
|
injectEnvironment: function(environment) {
|
||
|
("production" !== process.env.NODE_ENV ? invariant(
|
||
|
!injected,
|
||
|
'ReactCompositeComponent: injectEnvironment() can only be called once.'
|
||
|
) : invariant(!injected));
|
||
|
ReactComponentEnvironment.unmountIDFromEnvironment =
|
||
|
environment.unmountIDFromEnvironment;
|
||
|
ReactComponentEnvironment.replaceNodeWithMarkupByID =
|
||
|
environment.replaceNodeWithMarkupByID;
|
||
|
ReactComponentEnvironment.processChildrenUpdates =
|
||
|
environment.processChildrenUpdates;
|
||
|
injected = true;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
};
|
||
|
|
||
|
module.exports = ReactComponentEnvironment;
|