react / react-0.13.3 / examples / basic-commonjs / node_modules / reactify / node_modules / react-tools / src / browser / ui / React.js
81155 views/**1* Copyright 2013-2014, Facebook, Inc.2* All rights reserved.3*4* This source code is licensed under the BSD-style license found in the5* LICENSE file in the root directory of this source tree. An additional grant6* of patent rights can be found in the PATENTS file in the same directory.7*8* @providesModule React9*/1011"use strict";1213var DOMPropertyOperations = require('DOMPropertyOperations');14var EventPluginUtils = require('EventPluginUtils');15var ReactChildren = require('ReactChildren');16var ReactComponent = require('ReactComponent');17var ReactCompositeComponent = require('ReactCompositeComponent');18var ReactContext = require('ReactContext');19var ReactCurrentOwner = require('ReactCurrentOwner');20var ReactElement = require('ReactElement');21var ReactElementValidator = require('ReactElementValidator');22var ReactDOM = require('ReactDOM');23var ReactDOMComponent = require('ReactDOMComponent');24var ReactDefaultInjection = require('ReactDefaultInjection');25var ReactInstanceHandles = require('ReactInstanceHandles');26var ReactLegacyElement = require('ReactLegacyElement');27var ReactMount = require('ReactMount');28var ReactMultiChild = require('ReactMultiChild');29var ReactPerf = require('ReactPerf');30var ReactPropTypes = require('ReactPropTypes');31var ReactServerRendering = require('ReactServerRendering');32var ReactTextComponent = require('ReactTextComponent');3334var assign = require('Object.assign');35var deprecated = require('deprecated');36var onlyChild = require('onlyChild');3738ReactDefaultInjection.inject();3940var createElement = ReactElement.createElement;41var createFactory = ReactElement.createFactory;4243if (__DEV__) {44createElement = ReactElementValidator.createElement;45createFactory = ReactElementValidator.createFactory;46}4748// TODO: Drop legacy elements once classes no longer export these factories49createElement = ReactLegacyElement.wrapCreateElement(50createElement51);52createFactory = ReactLegacyElement.wrapCreateFactory(53createFactory54);5556var render = ReactPerf.measure('React', 'render', ReactMount.render);5758var React = {59Children: {60map: ReactChildren.map,61forEach: ReactChildren.forEach,62count: ReactChildren.count,63only: onlyChild64},65DOM: ReactDOM,66PropTypes: ReactPropTypes,67initializeTouchEvents: function(shouldUseTouch) {68EventPluginUtils.useTouchEvents = shouldUseTouch;69},70createClass: ReactCompositeComponent.createClass,71createElement: createElement,72createFactory: createFactory,73constructAndRenderComponent: ReactMount.constructAndRenderComponent,74constructAndRenderComponentByID: ReactMount.constructAndRenderComponentByID,75render: render,76renderToString: ReactServerRendering.renderToString,77renderToStaticMarkup: ReactServerRendering.renderToStaticMarkup,78unmountComponentAtNode: ReactMount.unmountComponentAtNode,79isValidClass: ReactLegacyElement.isValidClass,80isValidElement: ReactElement.isValidElement,81withContext: ReactContext.withContext,8283// Hook for JSX spread, don't use this for anything else.84__spread: assign,8586// Deprecations (remove for 0.13)87renderComponent: deprecated(88'React',89'renderComponent',90'render',91this,92render93),94renderComponentToString: deprecated(95'React',96'renderComponentToString',97'renderToString',98this,99ReactServerRendering.renderToString100),101renderComponentToStaticMarkup: deprecated(102'React',103'renderComponentToStaticMarkup',104'renderToStaticMarkup',105this,106ReactServerRendering.renderToStaticMarkup107),108isValidComponent: deprecated(109'React',110'isValidComponent',111'isValidElement',112this,113ReactElement.isValidElement114)115};116117// Inject the runtime into a devtools global hook regardless of browser.118// Allows for debugging when the hook is injected on the page.119if (120typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&121typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.inject === 'function') {122__REACT_DEVTOOLS_GLOBAL_HOOK__.inject({123Component: ReactComponent,124CurrentOwner: ReactCurrentOwner,125DOMComponent: ReactDOMComponent,126DOMPropertyOperations: DOMPropertyOperations,127InstanceHandles: ReactInstanceHandles,128Mount: ReactMount,129MultiChild: ReactMultiChild,130TextComponent: ReactTextComponent131});132}133134if (__DEV__) {135var ExecutionEnvironment = require('ExecutionEnvironment');136if (ExecutionEnvironment.canUseDOM && window.top === window.self) {137138// If we're in Chrome, look for the devtools marker and provide a download139// link if not installed.140if (navigator.userAgent.indexOf('Chrome') > -1) {141if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') {142console.debug(143'Download the React DevTools for a better development experience: ' +144'http://fb.me/react-devtools'145);146}147}148149var expectedFeatures = [150// shims151Array.isArray,152Array.prototype.every,153Array.prototype.forEach,154Array.prototype.indexOf,155Array.prototype.map,156Date.now,157Function.prototype.bind,158Object.keys,159String.prototype.split,160String.prototype.trim,161162// shams163Object.create,164Object.freeze165];166167for (var i = 0; i < expectedFeatures.length; i++) {168if (!expectedFeatures[i]) {169console.error(170'One or more ES5 shim/shams expected by React are not available: ' +171'http://fb.me/react-warning-polyfills'172);173break;174}175}176}177}178179// Version exists only in the open-source version of React, not in Facebook's180// internal version.181React.version = '0.12.2';182183module.exports = React;184185186