diff --git a/example/dist/bundle.js b/example/dist/bundle.js index 5c2b024..194fc9b 100644 --- a/example/dist/bundle.js +++ b/example/dist/bundle.js @@ -1,5 +1,4 @@ require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 1) { - for (var i = 1; i < arguments.length; i++) { - args[i - 1] = arguments[i]; - } - } - queue.push(new Item(fun, args)); - if (queue.length === 1 && !draining) { - runTimeout(drainQueue); - } -}; - -// v8 likes predictible objects -function Item(fun, array) { - this.fun = fun; - this.array = array; -} -Item.prototype.run = function () { - this.fun.apply(null, this.array); -}; -process.title = 'browser'; -process.browser = true; -process.env = {}; -process.argv = []; -process.version = ''; // empty string to avoid regexp issues -process.versions = {}; - -function noop() {} - -process.on = noop; -process.addListener = noop; -process.once = noop; -process.off = noop; -process.removeListener = noop; -process.removeAllListeners = noop; -process.emit = noop; -process.prependListener = noop; -process.prependOnceListener = noop; - -process.listeners = function (name) { return [] } - -process.binding = function (name) { - throw new Error('process.binding is not supported'); -}; - -process.cwd = function () { return '/' }; -process.chdir = function (dir) { - throw new Error('process.chdir is not supported'); -}; -process.umask = function() { return 0; }; - -},{}],9:[function(require,module,exports){ -(function (process){ /** * Copyright 2013-present, Facebook, Inc. * All rights reserved. @@ -1224,7 +1035,7 @@ process.umask = function() { return 0; }; 'use strict'; -if (process.env.NODE_ENV !== 'production') { +if ("production" !== 'production') { var invariant = require('fbjs/lib/invariant'); var warning = require('fbjs/lib/warning'); var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret'); @@ -1243,7 +1054,7 @@ if (process.env.NODE_ENV !== 'production') { * @private */ function checkPropTypes(typeSpecs, values, location, componentName, getStack) { - if (process.env.NODE_ENV !== 'production') { + if ("production" !== 'production') { for (var typeSpecName in typeSpecs) { if (typeSpecs.hasOwnProperty(typeSpecName)) { var error; @@ -1275,8 +1086,7 @@ function checkPropTypes(typeSpecs, values, location, componentName, getStack) { module.exports = checkPropTypes; -}).call(this,require('_process')) -},{"./lib/ReactPropTypesSecret":13,"_process":8,"fbjs/lib/invariant":5,"fbjs/lib/warning":6}],10:[function(require,module,exports){ +},{"./lib/ReactPropTypesSecret":12,"fbjs/lib/invariant":5,"fbjs/lib/warning":6}],9:[function(require,module,exports){ /** * Copyright 2013-present, Facebook, Inc. * All rights reserved. @@ -1290,11 +1100,14 @@ module.exports = checkPropTypes; var emptyFunction = require('fbjs/lib/emptyFunction'); var invariant = require('fbjs/lib/invariant'); +var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret'); module.exports = function() { - // Important! - // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`. - function shim() { + function shim(props, propName, componentName, location, propFullName, secret) { + if (secret === ReactPropTypesSecret) { + // It is still safe when called from React. + return; + } invariant( false, 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' + @@ -1306,6 +1119,8 @@ module.exports = function() { function getShim() { return shim; }; + // Important! + // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`. var ReactPropTypes = { array: shim, bool: shim, @@ -1332,8 +1147,7 @@ module.exports = function() { return ReactPropTypes; }; -},{"fbjs/lib/emptyFunction":3,"fbjs/lib/invariant":5}],11:[function(require,module,exports){ -(function (process){ +},{"./lib/ReactPropTypesSecret":12,"fbjs/lib/emptyFunction":3,"fbjs/lib/invariant":5}],10:[function(require,module,exports){ /** * Copyright 2013-present, Facebook, Inc. * All rights reserved. @@ -1482,7 +1296,7 @@ module.exports = function(isValidElement, throwOnDirectAccess) { PropTypeError.prototype = Error.prototype; function createChainableTypeChecker(validate) { - if (process.env.NODE_ENV !== 'production') { + if ("production" !== 'production') { var manualPropTypeCallCache = {}; var manualPropTypeWarningCount = 0; } @@ -1499,7 +1313,7 @@ module.exports = function(isValidElement, throwOnDirectAccess) { 'Use `PropTypes.checkPropTypes()` to call them. ' + 'Read more at http://fb.me/use-check-prop-types' ); - } else if (process.env.NODE_ENV !== 'production' && typeof console !== 'undefined') { + } else if ("production" !== 'production' && typeof console !== 'undefined') { // Old behavior for people using React.PropTypes var cacheKey = componentName + ':' + propName; if ( @@ -1609,7 +1423,7 @@ module.exports = function(isValidElement, throwOnDirectAccess) { function createEnumTypeChecker(expectedValues) { if (!Array.isArray(expectedValues)) { - process.env.NODE_ENV !== 'production' ? warning(false, 'Invalid argument supplied to oneOf, expected an instance of array.') : void 0; + "production" !== 'production' ? warning(false, 'Invalid argument supplied to oneOf, expected an instance of array.') : void 0; return emptyFunction.thatReturnsNull; } @@ -1652,10 +1466,24 @@ module.exports = function(isValidElement, throwOnDirectAccess) { function createUnionTypeChecker(arrayOfTypeCheckers) { if (!Array.isArray(arrayOfTypeCheckers)) { - process.env.NODE_ENV !== 'production' ? warning(false, 'Invalid argument supplied to oneOfType, expected an instance of array.') : void 0; + "production" !== 'production' ? warning(false, 'Invalid argument supplied to oneOfType, expected an instance of array.') : void 0; return emptyFunction.thatReturnsNull; } + for (var i = 0; i < arrayOfTypeCheckers.length; i++) { + var checker = arrayOfTypeCheckers[i]; + if (typeof checker !== 'function') { + warning( + false, + 'Invalid argument supplid to oneOfType. Expected an array of check functions, but ' + + 'received %s at index %s.', + getPostfixForTypeWarning(checker), + i + ); + return emptyFunction.thatReturnsNull; + } + } + function validate(props, propName, componentName, location, propFullName) { for (var i = 0; i < arrayOfTypeCheckers.length; i++) { var checker = arrayOfTypeCheckers[i]; @@ -1788,6 +1616,9 @@ module.exports = function(isValidElement, throwOnDirectAccess) { // This handles more types than `getPropType`. Only used for error messages. // See `createPrimitiveTypeChecker`. function getPreciseType(propValue) { + if (typeof propValue === 'undefined' || propValue === null) { + return '' + propValue; + } var propType = getPropType(propValue); if (propType === 'object') { if (propValue instanceof Date) { @@ -1799,6 +1630,23 @@ module.exports = function(isValidElement, throwOnDirectAccess) { return propType; } + // Returns a string that is postfixed to a warning about an invalid type. + // For example, "undefined" or "of type array" + function getPostfixForTypeWarning(value) { + var type = getPreciseType(value); + switch (type) { + case 'array': + case 'object': + return 'an ' + type; + case 'boolean': + case 'date': + case 'regexp': + return 'a ' + type; + default: + return type; + } + } + // Returns class name of the object, if any. function getClassName(propValue) { if (!propValue.constructor || !propValue.constructor.name) { @@ -1813,9 +1661,7 @@ module.exports = function(isValidElement, throwOnDirectAccess) { return ReactPropTypes; }; -}).call(this,require('_process')) -},{"./checkPropTypes":9,"./lib/ReactPropTypesSecret":13,"_process":8,"fbjs/lib/emptyFunction":3,"fbjs/lib/invariant":5,"fbjs/lib/warning":6}],12:[function(require,module,exports){ -(function (process){ +},{"./checkPropTypes":8,"./lib/ReactPropTypesSecret":12,"fbjs/lib/emptyFunction":3,"fbjs/lib/invariant":5,"fbjs/lib/warning":6}],11:[function(require,module,exports){ /** * Copyright 2013-present, Facebook, Inc. * All rights reserved. @@ -1825,7 +1671,7 @@ module.exports = function(isValidElement, throwOnDirectAccess) { * of patent rights can be found in the PATENTS file in the same directory. */ -if (process.env.NODE_ENV !== 'production') { +if ("production" !== 'production') { var REACT_ELEMENT_TYPE = (typeof Symbol === 'function' && Symbol.for && Symbol.for('react.element')) || @@ -1847,8 +1693,7 @@ if (process.env.NODE_ENV !== 'production') { module.exports = require('./factoryWithThrowingShims')(); } -}).call(this,require('_process')) -},{"./factoryWithThrowingShims":10,"./factoryWithTypeCheckers":11,"_process":8}],13:[function(require,module,exports){ +},{"./factoryWithThrowingShims":9,"./factoryWithTypeCheckers":10}],12:[function(require,module,exports){ /** * Copyright 2013-present, Facebook, Inc. * All rights reserved. @@ -1864,7 +1709,7 @@ var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'; module.exports = ReactPropTypesSecret; -},{}],14:[function(require,module,exports){ +},{}],13:[function(require,module,exports){ 'use strict'; var PropTypes = require('prop-types'); @@ -2220,7 +2065,7 @@ var Mixin = { module.exports = Mixin; -},{"prop-types":12,"react":undefined,"react-dom":undefined}],15:[function(require,module,exports){ +},{"prop-types":11,"react":undefined,"react-dom":undefined}],14:[function(require,module,exports){ 'use strict'; var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; @@ -2299,7 +2144,7 @@ module.exports = function (mixins) { }); }; -},{"./touchStyles":16,"create-react-class":2,"prop-types":12,"react":undefined}],16:[function(require,module,exports){ +},{"./touchStyles":15,"create-react-class":2,"prop-types":11,"react":undefined}],15:[function(require,module,exports){ 'use strict'; var touchStyles = { @@ -2328,4 +2173,4 @@ module.exports = Component; module.exports.touchStyles = touchStyles; module.exports.Mixin = TappableMixin; -},{"./TappableMixin":14,"./getComponent":15,"./touchStyles":16}]},{},[]); +},{"./TappableMixin":13,"./getComponent":14,"./touchStyles":15}]},{},[]); diff --git a/example/dist/common.js b/example/dist/common.js index c522304..31864c2 100644 --- a/example/dist/common.js +++ b/example/dist/common.js @@ -1379,7 +1379,6 @@ process.chdir = function (dir) { process.umask = function() { return 0; }; },{}],26:[function(require,module,exports){ -(function (process){ /** * Copyright 2013-present, Facebook, Inc. * All rights reserved. @@ -1391,7 +1390,7 @@ process.umask = function() { return 0; }; 'use strict'; -if (process.env.NODE_ENV !== 'production') { +if ("production" !== 'production') { var invariant = require('fbjs/lib/invariant'); var warning = require('fbjs/lib/warning'); var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret'); @@ -1410,7 +1409,7 @@ if (process.env.NODE_ENV !== 'production') { * @private */ function checkPropTypes(typeSpecs, values, location, componentName, getStack) { - if (process.env.NODE_ENV !== 'production') { + if ("production" !== 'production') { for (var typeSpecName in typeSpecs) { if (typeSpecs.hasOwnProperty(typeSpecName)) { var error; @@ -1442,8 +1441,7 @@ function checkPropTypes(typeSpecs, values, location, componentName, getStack) { module.exports = checkPropTypes; -}).call(this,require('_process')) -},{"./lib/ReactPropTypesSecret":29,"_process":25,"fbjs/lib/invariant":16,"fbjs/lib/warning":23}],27:[function(require,module,exports){ +},{"./lib/ReactPropTypesSecret":29,"fbjs/lib/invariant":16,"fbjs/lib/warning":23}],27:[function(require,module,exports){ /** * Copyright 2013-present, Facebook, Inc. * All rights reserved. @@ -1467,7 +1465,6 @@ module.exports = function(isValidElement) { }; },{"./factoryWithTypeCheckers":28}],28:[function(require,module,exports){ -(function (process){ /** * Copyright 2013-present, Facebook, Inc. * All rights reserved. @@ -1616,7 +1613,7 @@ module.exports = function(isValidElement, throwOnDirectAccess) { PropTypeError.prototype = Error.prototype; function createChainableTypeChecker(validate) { - if (process.env.NODE_ENV !== 'production') { + if ("production" !== 'production') { var manualPropTypeCallCache = {}; var manualPropTypeWarningCount = 0; } @@ -1633,7 +1630,7 @@ module.exports = function(isValidElement, throwOnDirectAccess) { 'Use `PropTypes.checkPropTypes()` to call them. ' + 'Read more at http://fb.me/use-check-prop-types' ); - } else if (process.env.NODE_ENV !== 'production' && typeof console !== 'undefined') { + } else if ("production" !== 'production' && typeof console !== 'undefined') { // Old behavior for people using React.PropTypes var cacheKey = componentName + ':' + propName; if ( @@ -1743,7 +1740,7 @@ module.exports = function(isValidElement, throwOnDirectAccess) { function createEnumTypeChecker(expectedValues) { if (!Array.isArray(expectedValues)) { - process.env.NODE_ENV !== 'production' ? warning(false, 'Invalid argument supplied to oneOf, expected an instance of array.') : void 0; + "production" !== 'production' ? warning(false, 'Invalid argument supplied to oneOf, expected an instance of array.') : void 0; return emptyFunction.thatReturnsNull; } @@ -1786,10 +1783,24 @@ module.exports = function(isValidElement, throwOnDirectAccess) { function createUnionTypeChecker(arrayOfTypeCheckers) { if (!Array.isArray(arrayOfTypeCheckers)) { - process.env.NODE_ENV !== 'production' ? warning(false, 'Invalid argument supplied to oneOfType, expected an instance of array.') : void 0; + "production" !== 'production' ? warning(false, 'Invalid argument supplied to oneOfType, expected an instance of array.') : void 0; return emptyFunction.thatReturnsNull; } + for (var i = 0; i < arrayOfTypeCheckers.length; i++) { + var checker = arrayOfTypeCheckers[i]; + if (typeof checker !== 'function') { + warning( + false, + 'Invalid argument supplid to oneOfType. Expected an array of check functions, but ' + + 'received %s at index %s.', + getPostfixForTypeWarning(checker), + i + ); + return emptyFunction.thatReturnsNull; + } + } + function validate(props, propName, componentName, location, propFullName) { for (var i = 0; i < arrayOfTypeCheckers.length; i++) { var checker = arrayOfTypeCheckers[i]; @@ -1922,6 +1933,9 @@ module.exports = function(isValidElement, throwOnDirectAccess) { // This handles more types than `getPropType`. Only used for error messages. // See `createPrimitiveTypeChecker`. function getPreciseType(propValue) { + if (typeof propValue === 'undefined' || propValue === null) { + return '' + propValue; + } var propType = getPropType(propValue); if (propType === 'object') { if (propValue instanceof Date) { @@ -1933,6 +1947,23 @@ module.exports = function(isValidElement, throwOnDirectAccess) { return propType; } + // Returns a string that is postfixed to a warning about an invalid type. + // For example, "undefined" or "of type array" + function getPostfixForTypeWarning(value) { + var type = getPreciseType(value); + switch (type) { + case 'array': + case 'object': + return 'an ' + type; + case 'boolean': + case 'date': + case 'regexp': + return 'a ' + type; + default: + return type; + } + } + // Returns class name of the object, if any. function getClassName(propValue) { if (!propValue.constructor || !propValue.constructor.name) { @@ -1947,8 +1978,7 @@ module.exports = function(isValidElement, throwOnDirectAccess) { return ReactPropTypes; }; -}).call(this,require('_process')) -},{"./checkPropTypes":26,"./lib/ReactPropTypesSecret":29,"_process":25,"fbjs/lib/emptyFunction":8,"fbjs/lib/invariant":16,"fbjs/lib/warning":23}],29:[function(require,module,exports){ +},{"./checkPropTypes":26,"./lib/ReactPropTypesSecret":29,"fbjs/lib/emptyFunction":8,"fbjs/lib/invariant":16,"fbjs/lib/warning":23}],29:[function(require,module,exports){ /** * Copyright 2013-present, Facebook, Inc. * All rights reserved. diff --git a/example/dist/example.js b/example/dist/example.js index fa2f707..a1ecd17 100644 --- a/example/dist/example.js +++ b/example/dist/example.js @@ -119,7 +119,6 @@ var App = createReactClass({ ReactDOM.render(React.createElement(App, null), document.getElementById('app')); },{"create-react-class":3,"react":undefined,"react-dom":undefined,"react-tappable":undefined}],2:[function(require,module,exports){ -(function (process){ /** * Copyright 2013-present, Facebook, Inc. * All rights reserved. @@ -137,7 +136,7 @@ var _assign = require('object-assign'); var emptyObject = require('fbjs/lib/emptyObject'); var _invariant = require('fbjs/lib/invariant'); -if (process.env.NODE_ENV !== 'production') { +if ("production" !== 'production') { var warning = require('fbjs/lib/warning'); } @@ -150,7 +149,7 @@ function identity(fn) { } var ReactPropTypeLocationNames; -if (process.env.NODE_ENV !== 'production') { +if ("production" !== 'production') { ReactPropTypeLocationNames = { prop: 'prop', context: 'context', @@ -434,13 +433,13 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) { } }, childContextTypes: function (Constructor, childContextTypes) { - if (process.env.NODE_ENV !== 'production') { + if ("production" !== 'production') { validateTypeDef(Constructor, childContextTypes, 'childContext'); } Constructor.childContextTypes = _assign({}, Constructor.childContextTypes, childContextTypes); }, contextTypes: function (Constructor, contextTypes) { - if (process.env.NODE_ENV !== 'production') { + if ("production" !== 'production') { validateTypeDef(Constructor, contextTypes, 'context'); } Constructor.contextTypes = _assign({}, Constructor.contextTypes, contextTypes); @@ -457,7 +456,7 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) { } }, propTypes: function (Constructor, propTypes) { - if (process.env.NODE_ENV !== 'production') { + if ("production" !== 'production') { validateTypeDef(Constructor, propTypes, 'prop'); } Constructor.propTypes = _assign({}, Constructor.propTypes, propTypes); @@ -472,7 +471,7 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) { if (typeDef.hasOwnProperty(propName)) { // use a warning instead of an _invariant so components // don't show up in prod but only in __DEV__ - process.env.NODE_ENV !== 'production' ? warning(typeof typeDef[propName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', Constructor.displayName || 'ReactClass', ReactPropTypeLocationNames[location], propName) : void 0; + "production" !== 'production' ? warning(typeof typeDef[propName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', Constructor.displayName || 'ReactClass', ReactPropTypeLocationNames[location], propName) : void 0; } } } @@ -497,11 +496,11 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) { */ function mixSpecIntoComponent(Constructor, spec) { if (!spec) { - if (process.env.NODE_ENV !== 'production') { + if ("production" !== 'production') { var typeofSpec = typeof spec; var isMixinValid = typeofSpec === 'object' && spec !== null; - process.env.NODE_ENV !== 'production' ? warning(isMixinValid, '%s: You\'re attempting to include a mixin that is either null ' + 'or not an object. Check the mixins included by the component, ' + 'as well as any mixins they include themselves. ' + 'Expected object but got %s.', Constructor.displayName || 'ReactClass', spec === null ? null : typeofSpec) : void 0; + "production" !== 'production' ? warning(isMixinValid, '%s: You\'re attempting to include a mixin that is either null ' + 'or not an object. Check the mixins included by the component, ' + 'as well as any mixins they include themselves. ' + 'Expected object but got %s.', Constructor.displayName || 'ReactClass', spec === null ? null : typeofSpec) : void 0; } return; @@ -564,7 +563,7 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) { } } else { proto[name] = property; - if (process.env.NODE_ENV !== 'production') { + if ("production" !== 'production') { // Add verbose displayName to the function, which helps when looking // at profiling tools. if (typeof property === 'function' && spec.displayName) { @@ -663,7 +662,7 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) { */ function bindAutoBindMethod(component, method) { var boundMethod = method.bind(component); - if (process.env.NODE_ENV !== 'production') { + if ("production" !== 'production') { boundMethod.__reactBoundContext = component; boundMethod.__reactBoundMethod = method; boundMethod.__reactBoundArguments = null; @@ -678,9 +677,9 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) { // ignore the value of "this" that the user is trying to use, so // let's warn. if (newThis !== component && newThis !== null) { - process.env.NODE_ENV !== 'production' ? warning(false, 'bind(): React component methods may only be bound to the ' + 'component instance. See %s', componentName) : void 0; + "production" !== 'production' ? warning(false, 'bind(): React component methods may only be bound to the ' + 'component instance. See %s', componentName) : void 0; } else if (!args.length) { - process.env.NODE_ENV !== 'production' ? warning(false, 'bind(): You are binding a component method to the component. ' + 'React does this for you automatically in a high-performance ' + 'way, so you can safely remove this call. See %s', componentName) : void 0; + "production" !== 'production' ? warning(false, 'bind(): You are binding a component method to the component. ' + 'React does this for you automatically in a high-performance ' + 'way, so you can safely remove this call. See %s', componentName) : void 0; return boundMethod; } var reboundMethod = _bind.apply(boundMethod, arguments); @@ -737,8 +736,8 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) { * @final */ isMounted: function () { - if (process.env.NODE_ENV !== 'production') { - process.env.NODE_ENV !== 'production' ? warning(this.__didWarnIsMounted, '%s: isMounted is deprecated. Instead, make sure to clean up ' + 'subscriptions and pending requests in componentWillUnmount to ' + 'prevent memory leaks.', this.constructor && this.constructor.displayName || this.name || 'Component') : void 0; + if ("production" !== 'production') { + "production" !== 'production' ? warning(this.__didWarnIsMounted, '%s: isMounted is deprecated. Instead, make sure to clean up ' + 'subscriptions and pending requests in componentWillUnmount to ' + 'prevent memory leaks.', this.constructor && this.constructor.displayName || this.name || 'Component') : void 0; this.__didWarnIsMounted = true; } return !!this.__isMounted; @@ -764,8 +763,8 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) { // This constructor gets overridden by mocks. The argument is used // by mocks to assert on what gets mounted. - if (process.env.NODE_ENV !== 'production') { - process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly. Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : void 0; + if ("production" !== 'production') { + "production" !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly. Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : void 0; } // Wire up auto-binding @@ -784,7 +783,7 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) { // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; - if (process.env.NODE_ENV !== 'production') { + if ("production" !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (initialState === undefined && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and @@ -810,7 +809,7 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) { Constructor.defaultProps = Constructor.getDefaultProps(); } - if (process.env.NODE_ENV !== 'production') { + if ("production" !== 'production') { // This is a tag to indicate that the use of these method names is ok, // since it's used with createClass. If it's not, then it's likely a // mistake so we'll warn you to use the static property, property @@ -825,9 +824,9 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) { _invariant(Constructor.prototype.render, 'createClass(...): Class specification must implement a `render` method.'); - if (process.env.NODE_ENV !== 'production') { - process.env.NODE_ENV !== 'production' ? warning(!Constructor.prototype.componentShouldUpdate, '%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', spec.displayName || 'A component') : void 0; - process.env.NODE_ENV !== 'production' ? warning(!Constructor.prototype.componentWillRecieveProps, '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', spec.displayName || 'A component') : void 0; + if ("production" !== 'production') { + "production" !== 'production' ? warning(!Constructor.prototype.componentShouldUpdate, '%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', spec.displayName || 'A component') : void 0; + "production" !== 'production' ? warning(!Constructor.prototype.componentWillRecieveProps, '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', spec.displayName || 'A component') : void 0; } // Reduce time spent doing lookups by setting these on the prototype. @@ -845,8 +844,7 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) { module.exports = factory; -}).call(this,require('_process')) -},{"_process":9,"fbjs/lib/emptyObject":5,"fbjs/lib/invariant":6,"fbjs/lib/warning":7,"object-assign":8}],3:[function(require,module,exports){ +},{"fbjs/lib/emptyObject":5,"fbjs/lib/invariant":6,"fbjs/lib/warning":7,"object-assign":8}],3:[function(require,module,exports){ /** * Copyright 2013-present, Facebook, Inc. * All rights reserved. @@ -1145,190 +1143,4 @@ module.exports = shouldUseNative() ? Object.assign : function (target, source) { return to; }; -},{}],9:[function(require,module,exports){ -// shim for using process in browser -var process = module.exports = {}; - -// cached from whatever global is present so that test runners that stub it -// don't break things. But we need to wrap it in a try catch in case it is -// wrapped in strict mode code which doesn't define any globals. It's inside a -// function because try/catches deoptimize in certain engines. - -var cachedSetTimeout; -var cachedClearTimeout; - -function defaultSetTimout() { - throw new Error('setTimeout has not been defined'); -} -function defaultClearTimeout () { - throw new Error('clearTimeout has not been defined'); -} -(function () { - try { - if (typeof setTimeout === 'function') { - cachedSetTimeout = setTimeout; - } else { - cachedSetTimeout = defaultSetTimout; - } - } catch (e) { - cachedSetTimeout = defaultSetTimout; - } - try { - if (typeof clearTimeout === 'function') { - cachedClearTimeout = clearTimeout; - } else { - cachedClearTimeout = defaultClearTimeout; - } - } catch (e) { - cachedClearTimeout = defaultClearTimeout; - } -} ()) -function runTimeout(fun) { - if (cachedSetTimeout === setTimeout) { - //normal enviroments in sane situations - return setTimeout(fun, 0); - } - // if setTimeout wasn't available but was latter defined - if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { - cachedSetTimeout = setTimeout; - return setTimeout(fun, 0); - } - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedSetTimeout(fun, 0); - } catch(e){ - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedSetTimeout.call(null, fun, 0); - } catch(e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error - return cachedSetTimeout.call(this, fun, 0); - } - } - - -} -function runClearTimeout(marker) { - if (cachedClearTimeout === clearTimeout) { - //normal enviroments in sane situations - return clearTimeout(marker); - } - // if clearTimeout wasn't available but was latter defined - if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { - cachedClearTimeout = clearTimeout; - return clearTimeout(marker); - } - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedClearTimeout(marker); - } catch (e){ - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedClearTimeout.call(null, marker); - } catch (e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. - // Some versions of I.E. have different rules for clearTimeout vs setTimeout - return cachedClearTimeout.call(this, marker); - } - } - - - -} -var queue = []; -var draining = false; -var currentQueue; -var queueIndex = -1; - -function cleanUpNextTick() { - if (!draining || !currentQueue) { - return; - } - draining = false; - if (currentQueue.length) { - queue = currentQueue.concat(queue); - } else { - queueIndex = -1; - } - if (queue.length) { - drainQueue(); - } -} - -function drainQueue() { - if (draining) { - return; - } - var timeout = runTimeout(cleanUpNextTick); - draining = true; - - var len = queue.length; - while(len) { - currentQueue = queue; - queue = []; - while (++queueIndex < len) { - if (currentQueue) { - currentQueue[queueIndex].run(); - } - } - queueIndex = -1; - len = queue.length; - } - currentQueue = null; - draining = false; - runClearTimeout(timeout); -} - -process.nextTick = function (fun) { - var args = new Array(arguments.length - 1); - if (arguments.length > 1) { - for (var i = 1; i < arguments.length; i++) { - args[i - 1] = arguments[i]; - } - } - queue.push(new Item(fun, args)); - if (queue.length === 1 && !draining) { - runTimeout(drainQueue); - } -}; - -// v8 likes predictible objects -function Item(fun, array) { - this.fun = fun; - this.array = array; -} -Item.prototype.run = function () { - this.fun.apply(null, this.array); -}; -process.title = 'browser'; -process.browser = true; -process.env = {}; -process.argv = []; -process.version = ''; // empty string to avoid regexp issues -process.versions = {}; - -function noop() {} - -process.on = noop; -process.addListener = noop; -process.once = noop; -process.off = noop; -process.removeListener = noop; -process.removeAllListeners = noop; -process.emit = noop; -process.prependListener = noop; -process.prependOnceListener = noop; - -process.listeners = function (name) { return [] } - -process.binding = function (name) { - throw new Error('process.binding is not supported'); -}; - -process.cwd = function () { return '/' }; -process.chdir = function (dir) { - throw new Error('process.chdir is not supported'); -}; -process.umask = function() { return 0; }; - },{}]},{},[1]); diff --git a/example/dist/pinch.js b/example/dist/pinch.js index 32a02c5..12f4da5 100644 --- a/example/dist/pinch.js +++ b/example/dist/pinch.js @@ -80,7 +80,6 @@ var App = createReactClass({ ReactDOM.render(React.createElement(App, null), document.getElementById('app')); },{"create-react-class":3,"react":undefined,"react-dom":undefined,"react-tappable":undefined}],2:[function(require,module,exports){ -(function (process){ /** * Copyright 2013-present, Facebook, Inc. * All rights reserved. @@ -98,7 +97,7 @@ var _assign = require('object-assign'); var emptyObject = require('fbjs/lib/emptyObject'); var _invariant = require('fbjs/lib/invariant'); -if (process.env.NODE_ENV !== 'production') { +if ("production" !== 'production') { var warning = require('fbjs/lib/warning'); } @@ -111,7 +110,7 @@ function identity(fn) { } var ReactPropTypeLocationNames; -if (process.env.NODE_ENV !== 'production') { +if ("production" !== 'production') { ReactPropTypeLocationNames = { prop: 'prop', context: 'context', @@ -395,13 +394,13 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) { } }, childContextTypes: function (Constructor, childContextTypes) { - if (process.env.NODE_ENV !== 'production') { + if ("production" !== 'production') { validateTypeDef(Constructor, childContextTypes, 'childContext'); } Constructor.childContextTypes = _assign({}, Constructor.childContextTypes, childContextTypes); }, contextTypes: function (Constructor, contextTypes) { - if (process.env.NODE_ENV !== 'production') { + if ("production" !== 'production') { validateTypeDef(Constructor, contextTypes, 'context'); } Constructor.contextTypes = _assign({}, Constructor.contextTypes, contextTypes); @@ -418,7 +417,7 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) { } }, propTypes: function (Constructor, propTypes) { - if (process.env.NODE_ENV !== 'production') { + if ("production" !== 'production') { validateTypeDef(Constructor, propTypes, 'prop'); } Constructor.propTypes = _assign({}, Constructor.propTypes, propTypes); @@ -433,7 +432,7 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) { if (typeDef.hasOwnProperty(propName)) { // use a warning instead of an _invariant so components // don't show up in prod but only in __DEV__ - process.env.NODE_ENV !== 'production' ? warning(typeof typeDef[propName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', Constructor.displayName || 'ReactClass', ReactPropTypeLocationNames[location], propName) : void 0; + "production" !== 'production' ? warning(typeof typeDef[propName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', Constructor.displayName || 'ReactClass', ReactPropTypeLocationNames[location], propName) : void 0; } } } @@ -458,11 +457,11 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) { */ function mixSpecIntoComponent(Constructor, spec) { if (!spec) { - if (process.env.NODE_ENV !== 'production') { + if ("production" !== 'production') { var typeofSpec = typeof spec; var isMixinValid = typeofSpec === 'object' && spec !== null; - process.env.NODE_ENV !== 'production' ? warning(isMixinValid, '%s: You\'re attempting to include a mixin that is either null ' + 'or not an object. Check the mixins included by the component, ' + 'as well as any mixins they include themselves. ' + 'Expected object but got %s.', Constructor.displayName || 'ReactClass', spec === null ? null : typeofSpec) : void 0; + "production" !== 'production' ? warning(isMixinValid, '%s: You\'re attempting to include a mixin that is either null ' + 'or not an object. Check the mixins included by the component, ' + 'as well as any mixins they include themselves. ' + 'Expected object but got %s.', Constructor.displayName || 'ReactClass', spec === null ? null : typeofSpec) : void 0; } return; @@ -525,7 +524,7 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) { } } else { proto[name] = property; - if (process.env.NODE_ENV !== 'production') { + if ("production" !== 'production') { // Add verbose displayName to the function, which helps when looking // at profiling tools. if (typeof property === 'function' && spec.displayName) { @@ -624,7 +623,7 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) { */ function bindAutoBindMethod(component, method) { var boundMethod = method.bind(component); - if (process.env.NODE_ENV !== 'production') { + if ("production" !== 'production') { boundMethod.__reactBoundContext = component; boundMethod.__reactBoundMethod = method; boundMethod.__reactBoundArguments = null; @@ -639,9 +638,9 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) { // ignore the value of "this" that the user is trying to use, so // let's warn. if (newThis !== component && newThis !== null) { - process.env.NODE_ENV !== 'production' ? warning(false, 'bind(): React component methods may only be bound to the ' + 'component instance. See %s', componentName) : void 0; + "production" !== 'production' ? warning(false, 'bind(): React component methods may only be bound to the ' + 'component instance. See %s', componentName) : void 0; } else if (!args.length) { - process.env.NODE_ENV !== 'production' ? warning(false, 'bind(): You are binding a component method to the component. ' + 'React does this for you automatically in a high-performance ' + 'way, so you can safely remove this call. See %s', componentName) : void 0; + "production" !== 'production' ? warning(false, 'bind(): You are binding a component method to the component. ' + 'React does this for you automatically in a high-performance ' + 'way, so you can safely remove this call. See %s', componentName) : void 0; return boundMethod; } var reboundMethod = _bind.apply(boundMethod, arguments); @@ -698,8 +697,8 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) { * @final */ isMounted: function () { - if (process.env.NODE_ENV !== 'production') { - process.env.NODE_ENV !== 'production' ? warning(this.__didWarnIsMounted, '%s: isMounted is deprecated. Instead, make sure to clean up ' + 'subscriptions and pending requests in componentWillUnmount to ' + 'prevent memory leaks.', this.constructor && this.constructor.displayName || this.name || 'Component') : void 0; + if ("production" !== 'production') { + "production" !== 'production' ? warning(this.__didWarnIsMounted, '%s: isMounted is deprecated. Instead, make sure to clean up ' + 'subscriptions and pending requests in componentWillUnmount to ' + 'prevent memory leaks.', this.constructor && this.constructor.displayName || this.name || 'Component') : void 0; this.__didWarnIsMounted = true; } return !!this.__isMounted; @@ -725,8 +724,8 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) { // This constructor gets overridden by mocks. The argument is used // by mocks to assert on what gets mounted. - if (process.env.NODE_ENV !== 'production') { - process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly. Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : void 0; + if ("production" !== 'production') { + "production" !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly. Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : void 0; } // Wire up auto-binding @@ -745,7 +744,7 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) { // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; - if (process.env.NODE_ENV !== 'production') { + if ("production" !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (initialState === undefined && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and @@ -771,7 +770,7 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) { Constructor.defaultProps = Constructor.getDefaultProps(); } - if (process.env.NODE_ENV !== 'production') { + if ("production" !== 'production') { // This is a tag to indicate that the use of these method names is ok, // since it's used with createClass. If it's not, then it's likely a // mistake so we'll warn you to use the static property, property @@ -786,9 +785,9 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) { _invariant(Constructor.prototype.render, 'createClass(...): Class specification must implement a `render` method.'); - if (process.env.NODE_ENV !== 'production') { - process.env.NODE_ENV !== 'production' ? warning(!Constructor.prototype.componentShouldUpdate, '%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', spec.displayName || 'A component') : void 0; - process.env.NODE_ENV !== 'production' ? warning(!Constructor.prototype.componentWillRecieveProps, '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', spec.displayName || 'A component') : void 0; + if ("production" !== 'production') { + "production" !== 'production' ? warning(!Constructor.prototype.componentShouldUpdate, '%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', spec.displayName || 'A component') : void 0; + "production" !== 'production' ? warning(!Constructor.prototype.componentWillRecieveProps, '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', spec.displayName || 'A component') : void 0; } // Reduce time spent doing lookups by setting these on the prototype. @@ -806,8 +805,7 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) { module.exports = factory; -}).call(this,require('_process')) -},{"_process":9,"fbjs/lib/emptyObject":5,"fbjs/lib/invariant":6,"fbjs/lib/warning":7,"object-assign":8}],3:[function(require,module,exports){ +},{"fbjs/lib/emptyObject":5,"fbjs/lib/invariant":6,"fbjs/lib/warning":7,"object-assign":8}],3:[function(require,module,exports){ /** * Copyright 2013-present, Facebook, Inc. * All rights reserved. @@ -1106,190 +1104,4 @@ module.exports = shouldUseNative() ? Object.assign : function (target, source) { return to; }; -},{}],9:[function(require,module,exports){ -// shim for using process in browser -var process = module.exports = {}; - -// cached from whatever global is present so that test runners that stub it -// don't break things. But we need to wrap it in a try catch in case it is -// wrapped in strict mode code which doesn't define any globals. It's inside a -// function because try/catches deoptimize in certain engines. - -var cachedSetTimeout; -var cachedClearTimeout; - -function defaultSetTimout() { - throw new Error('setTimeout has not been defined'); -} -function defaultClearTimeout () { - throw new Error('clearTimeout has not been defined'); -} -(function () { - try { - if (typeof setTimeout === 'function') { - cachedSetTimeout = setTimeout; - } else { - cachedSetTimeout = defaultSetTimout; - } - } catch (e) { - cachedSetTimeout = defaultSetTimout; - } - try { - if (typeof clearTimeout === 'function') { - cachedClearTimeout = clearTimeout; - } else { - cachedClearTimeout = defaultClearTimeout; - } - } catch (e) { - cachedClearTimeout = defaultClearTimeout; - } -} ()) -function runTimeout(fun) { - if (cachedSetTimeout === setTimeout) { - //normal enviroments in sane situations - return setTimeout(fun, 0); - } - // if setTimeout wasn't available but was latter defined - if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { - cachedSetTimeout = setTimeout; - return setTimeout(fun, 0); - } - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedSetTimeout(fun, 0); - } catch(e){ - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedSetTimeout.call(null, fun, 0); - } catch(e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error - return cachedSetTimeout.call(this, fun, 0); - } - } - - -} -function runClearTimeout(marker) { - if (cachedClearTimeout === clearTimeout) { - //normal enviroments in sane situations - return clearTimeout(marker); - } - // if clearTimeout wasn't available but was latter defined - if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { - cachedClearTimeout = clearTimeout; - return clearTimeout(marker); - } - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedClearTimeout(marker); - } catch (e){ - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedClearTimeout.call(null, marker); - } catch (e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. - // Some versions of I.E. have different rules for clearTimeout vs setTimeout - return cachedClearTimeout.call(this, marker); - } - } - - - -} -var queue = []; -var draining = false; -var currentQueue; -var queueIndex = -1; - -function cleanUpNextTick() { - if (!draining || !currentQueue) { - return; - } - draining = false; - if (currentQueue.length) { - queue = currentQueue.concat(queue); - } else { - queueIndex = -1; - } - if (queue.length) { - drainQueue(); - } -} - -function drainQueue() { - if (draining) { - return; - } - var timeout = runTimeout(cleanUpNextTick); - draining = true; - - var len = queue.length; - while(len) { - currentQueue = queue; - queue = []; - while (++queueIndex < len) { - if (currentQueue) { - currentQueue[queueIndex].run(); - } - } - queueIndex = -1; - len = queue.length; - } - currentQueue = null; - draining = false; - runClearTimeout(timeout); -} - -process.nextTick = function (fun) { - var args = new Array(arguments.length - 1); - if (arguments.length > 1) { - for (var i = 1; i < arguments.length; i++) { - args[i - 1] = arguments[i]; - } - } - queue.push(new Item(fun, args)); - if (queue.length === 1 && !draining) { - runTimeout(drainQueue); - } -}; - -// v8 likes predictible objects -function Item(fun, array) { - this.fun = fun; - this.array = array; -} -Item.prototype.run = function () { - this.fun.apply(null, this.array); -}; -process.title = 'browser'; -process.browser = true; -process.env = {}; -process.argv = []; -process.version = ''; // empty string to avoid regexp issues -process.versions = {}; - -function noop() {} - -process.on = noop; -process.addListener = noop; -process.once = noop; -process.off = noop; -process.removeListener = noop; -process.removeAllListeners = noop; -process.emit = noop; -process.prependListener = noop; -process.prependOnceListener = noop; - -process.listeners = function (name) { return [] } - -process.binding = function (name) { - throw new Error('process.binding is not supported'); -}; - -process.cwd = function () { return '/' }; -process.chdir = function (dir) { - throw new Error('process.chdir is not supported'); -}; -process.umask = function() { return 0; }; - },{}]},{},[1]);