diff --git a/browser/components/loop/content/conversation.html b/browser/components/loop/content/conversation.html index ce981c7afb38..f088f47d2817 100644 --- a/browser/components/loop/content/conversation.html +++ b/browser/components/loop/content/conversation.html @@ -26,7 +26,7 @@ window.OTProperties.cssURL = window.OTProperties.assetURL + 'css/ot.css'; - + diff --git a/browser/components/loop/content/js/conversation.js b/browser/components/loop/content/js/conversation.js index a679ce2179b5..37be62902bf6 100644 --- a/browser/components/loop/content/js/conversation.js +++ b/browser/components/loop/content/js/conversation.js @@ -86,27 +86,27 @@ loop.conversation = (function(OT, mozL10n) { "visually-hidden": !this.state.showDeclineMenu }); return ( - React.DOM.div( {className:conversationPanelClass}, - React.DOM.h2(null, __("incoming_call")), - React.DOM.div( {className:"button-group incoming-call-action-group"}, - React.DOM.div( {className:"button-chevron-menu-group"}, - React.DOM.div( {className:"button-group-chevron"}, - React.DOM.div( {className:"button-group"}, - React.DOM.button( {className:btnClassDecline, onClick:this._handleDecline}, + React.DOM.div({className: conversationPanelClass}, + React.DOM.h2(null, __("incoming_call")), + React.DOM.div({className: "button-group incoming-call-action-group"}, + React.DOM.div({className: "button-chevron-menu-group"}, + React.DOM.div({className: "button-group-chevron"}, + React.DOM.div({className: "button-group"}, + React.DOM.button({className: btnClassDecline, onClick: this._handleDecline}, __("incoming_call_decline_button") - ), - React.DOM.div( {className:"btn-chevron", - onClick:this._toggleDeclineMenu} + ), + React.DOM.div({className: "btn-chevron", + onClick: this._toggleDeclineMenu} ) - ), - React.DOM.ul( {className:declineDropdownMenuClasses}, - React.DOM.li( {className:"btn-block", onClick:this._handleDeclineBlock}, + ), + React.DOM.ul({className: declineDropdownMenuClasses}, + React.DOM.li({className: "btn-block", onClick: this._handleDeclineBlock}, __("incoming_call_decline_and_block_button") ) ) ) - ), - React.DOM.button( {className:btnClassAccept, onClick:this._handleAccept}, + ), + React.DOM.button({className: btnClassAccept, onClick: this._handleAccept}, __("incoming_call_answer_button") ) ) diff --git a/browser/components/loop/content/js/panel.js b/browser/components/loop/content/js/panel.js index 5d8dade50d05..84588040a91e 100644 --- a/browser/components/loop/content/js/panel.js +++ b/browser/components/loop/content/js/panel.js @@ -77,22 +77,22 @@ loop.panel = (function(_, mozL10n) { __("display_name_available_status"); return ( - React.DOM.div( {className:"footer component-spacer"}, - React.DOM.div( {className:"do-not-disturb"}, - React.DOM.p( {className:"dnd-status", onClick:this.showDropdownMenu}, - React.DOM.span(null, availabilityText), - React.DOM.i( {className:availabilityStatus}) - ), - React.DOM.ul( {className:availabilityDropdown, - onMouseLeave:this.hideDropdownMenu}, - React.DOM.li( {onClick:this.changeAvailability("available"), - className:"dnd-menu-item dnd-make-available"}, - React.DOM.i( {className:"status status-available"}), + React.DOM.div({className: "footer component-spacer"}, + React.DOM.div({className: "do-not-disturb"}, + React.DOM.p({className: "dnd-status", onClick: this.showDropdownMenu}, + React.DOM.span(null, availabilityText), + React.DOM.i({className: availabilityStatus}) + ), + React.DOM.ul({className: availabilityDropdown, + onMouseLeave: this.hideDropdownMenu}, + React.DOM.li({onClick: this.changeAvailability("available"), + className: "dnd-menu-item dnd-make-available"}, + React.DOM.i({className: "status status-available"}), React.DOM.span(null, __("display_name_available_status")) - ), - React.DOM.li( {onClick:this.changeAvailability("do-not-disturb"), - className:"dnd-menu-item dnd-make-unavailable"}, - React.DOM.i( {className:"status status-dnd"}), + ), + React.DOM.li({onClick: this.changeAvailability("do-not-disturb"), + className: "dnd-menu-item dnd-make-unavailable"}, + React.DOM.i({className: "status status-dnd"}), React.DOM.span(null, __("display_name_dnd_status")) ) ) @@ -113,21 +113,21 @@ loop.panel = (function(_, mozL10n) { var privacy_notice_url = navigator.mozLoop.getLoopCharPref('legal.privacy_url'); var tosHTML = __("legal_text_and_links2", { "terms_of_use": React.renderComponentToStaticMarkup( - React.DOM.a( {href:terms_of_use_url, target:"_blank"}, + React.DOM.a({href: terms_of_use_url, target: "_blank"}, __("legal_text_tos") ) ), "privacy_notice": React.renderComponentToStaticMarkup( - React.DOM.a( {href:privacy_notice_url, target:"_blank"}, + React.DOM.a({href: privacy_notice_url, target: "_blank"}, __("legal_text_privacy") ) ), }); navigator.mozLoop.setLoopCharPref('seenToS', 'seen'); - return React.DOM.p( {className:"terms-service", - dangerouslySetInnerHTML:{__html: tosHTML}}); + return React.DOM.p({className: "terms-service", + dangerouslySetInnerHTML: {__html: tosHTML}}); } else { - return React.DOM.div(null ); + return React.DOM.div(null); } } }); @@ -139,11 +139,11 @@ loop.panel = (function(_, mozL10n) { render: function() { return ( - React.DOM.div( {className:"component-spacer share generate-url"}, - React.DOM.div( {className:"description"}, - React.DOM.p( {className:"description-content"}, this.props.summary) - ), - React.DOM.div( {className:"action"}, + React.DOM.div({className: "component-spacer share generate-url"}, + React.DOM.div({className: "description"}, + React.DOM.p({className: "description-content"}, this.props.summary) + ), + React.DOM.div({className: "action"}, this.props.children ) ) @@ -210,10 +210,10 @@ loop.panel = (function(_, mozL10n) { // from the react lib. var cx = React.addons.classSet; return ( - PanelLayout( {summary:__("share_link_header_text")}, - React.DOM.div( {className:"invite"}, - React.DOM.input( {type:"url", value:this.state.callUrl, readOnly:"true", - className:cx({'pending': this.state.pending})} ) + PanelLayout({summary: __("share_link_header_text")}, + React.DOM.div({className: "invite"}, + React.DOM.input({type: "url", value: this.state.callUrl, readOnly: "true", + className: cx({'pending': this.state.pending})}) ) ) ); @@ -232,10 +232,10 @@ loop.panel = (function(_, mozL10n) { render: function() { return ( React.DOM.div(null, - CallUrlResult( {client:this.props.client, - notifier:this.props.notifier} ), - ToSView(null ), - AvailabilityDropdown(null ) + CallUrlResult({client: this.props.client, + notifier: this.props.notifier}), + ToSView(null), + AvailabilityDropdown(null) ) ); } @@ -302,8 +302,8 @@ loop.panel = (function(_, mozL10n) { var client = new loop.Client({ baseServerUrl: navigator.mozLoop.serverUrl }); - this.loadReactComponent(PanelView( {client:client, - notifier:this._notifier} )); + this.loadReactComponent(PanelView({client: client, + notifier: this._notifier})); } }); diff --git a/browser/components/loop/content/panel.html b/browser/components/loop/content/panel.html index 7b4a79c646c3..87df6481cb4b 100644 --- a/browser/components/loop/content/panel.html +++ b/browser/components/loop/content/panel.html @@ -15,7 +15,7 @@
- + diff --git a/browser/components/loop/content/shared/js/views.js b/browser/components/loop/content/shared/js/views.js index 8a6c3d55ab90..7d6ee8bc3466 100644 --- a/browser/components/loop/content/shared/js/views.js +++ b/browser/components/loop/content/shared/js/views.js @@ -140,9 +140,9 @@ loop.shared.views = (function(_, OT, l10n) { render: function() { return ( /* jshint ignore:start */ - React.DOM.button( {className:this._getClasses(), - title:this._getTitle(), - onClick:this.handleClick}) + React.DOM.button({className: this._getClasses(), + title: this._getTitle(), + onClick: this.handleClick}) /* jshint ignore:end */ ); } @@ -181,16 +181,16 @@ loop.shared.views = (function(_, OT, l10n) { render: function() { /* jshint ignore:start */ return ( - React.DOM.ul( {className:"conversation-toolbar"}, - React.DOM.li(null, React.DOM.button( {className:"btn btn-hangup", - onClick:this.handleClickHangup, - title:__("hangup_button_title")})), - React.DOM.li(null, MediaControlButton( {action:this.handleToggleVideo, - enabled:this.props.video.enabled, - scope:"local", type:"video"} )), - React.DOM.li(null, MediaControlButton( {action:this.handleToggleAudio, - enabled:this.props.audio.enabled, - scope:"local", type:"audio"} )) + React.DOM.ul({className: "conversation-toolbar"}, + React.DOM.li(null, React.DOM.button({className: "btn btn-hangup", + onClick: this.handleClickHangup, + title: __("hangup_button_title")})), + React.DOM.li(null, MediaControlButton({action: this.handleToggleVideo, + enabled: this.props.video.enabled, + scope: "local", type: "video"})), + React.DOM.li(null, MediaControlButton({action: this.handleToggleAudio, + enabled: this.props.audio.enabled, + scope: "local", type: "audio"})) ) ); /* jshint ignore:end */ @@ -336,16 +336,16 @@ loop.shared.views = (function(_, OT, l10n) { render: function() { /* jshint ignore:start */ return ( - React.DOM.div( {className:"conversation"}, - ConversationToolbar( {video:this.state.video, - audio:this.state.audio, - publishStream:this.publishStream, - hangup:this.hangup} ), - React.DOM.div( {className:"media nested"}, - React.DOM.div( {className:"video_wrapper remote_wrapper"}, - React.DOM.div( {className:"video_inner remote"}) - ), - React.DOM.div( {className:"local"}) + React.DOM.div({className: "conversation"}, + ConversationToolbar({video: this.state.video, + audio: this.state.audio, + publishStream: this.publishStream, + hangup: this.hangup}), + React.DOM.div({className: "media nested"}, + React.DOM.div({className: "video_wrapper remote_wrapper"}, + React.DOM.div({className: "video_inner remote"}) + ), + React.DOM.div({className: "local"}) ) ) ); @@ -367,18 +367,18 @@ loop.shared.views = (function(_, OT, l10n) { }, render: function() { - var backButton = React.DOM.div(null ); + var backButton = React.DOM.div(null); if (this.props.reset) { backButton = ( - React.DOM.button( {className:"back", type:"button", onClick:this.props.reset}, - "« ",__("feedback_back_button") + React.DOM.button({className: "back", type: "button", onClick: this.props.reset}, + "« ", __("feedback_back_button") ) ); } return ( - React.DOM.div( {className:"feedback"}, - backButton, - React.DOM.h3(null, this.props.title), + React.DOM.div({className: "feedback"}, + backButton, + React.DOM.h3(null, this.props.title), this.props.children ) ); @@ -417,10 +417,10 @@ loop.shared.views = (function(_, OT, l10n) { var categories = this._getCategories(); return Object.keys(categories).map(function(category, key) { return ( - React.DOM.label( {key:key}, - React.DOM.input( {type:"radio", ref:"category", name:"category", - value:category, - onChange:this.handleCategoryChange} ), + React.DOM.label({key: key}, + React.DOM.input({type: "radio", ref: "category", name: "category", + value: category, + onChange: this.handleCategoryChange}), categories[category] ) ); @@ -462,16 +462,16 @@ loop.shared.views = (function(_, OT, l10n) { render: function() { return ( - FeedbackLayout( {title:__("feedback_what_makes_you_sad"), - reset:this.props.reset}, - React.DOM.form( {onSubmit:this.handleFormSubmit}, - this._getCategoryFields(), - React.DOM.p(null, React.DOM.input( {type:"text", ref:"description", name:"description", - disabled:this.state.category !== "other", - onChange:this.handleCustomTextChange, - value:this.state.description} )), - React.DOM.button( {type:"submit", className:"btn btn-success", - disabled:!this._isFormReady()}, + FeedbackLayout({title: __("feedback_what_makes_you_sad"), + reset: this.props.reset}, + React.DOM.form({onSubmit: this.handleFormSubmit}, + this._getCategoryFields(), + React.DOM.p(null, React.DOM.input({type: "text", ref: "description", name: "description", + disabled: this.state.category !== "other", + onChange: this.handleCustomTextChange, + value: this.state.description})), + React.DOM.button({type: "submit", className: "btn btn-success", + disabled: !this._isFormReady()}, __("feedback_submit_button") ) ) @@ -506,8 +506,8 @@ loop.shared.views = (function(_, OT, l10n) { window.close(); } return ( - FeedbackLayout( {title:__("feedback_thank_you_heading")}, - React.DOM.p( {className:"info thank-you"}, __("feedback_window_will_close_in", { + FeedbackLayout({title: __("feedback_thank_you_heading")}, + React.DOM.p({className: "info thank-you"}, __("feedback_window_will_close_in", { countdown: this.state.countdown })) ) @@ -565,20 +565,20 @@ loop.shared.views = (function(_, OT, l10n) { render: function() { switch(this.state.step) { case "finished": - return FeedbackReceived(null ); + return FeedbackReceived(null); case "form": - return FeedbackForm( {feedbackApiClient:this.props.feedbackApiClient, - sendFeedback:this.sendFeedback, - reset:this.reset, - pending:this.state.pending} ); + return FeedbackForm({feedbackApiClient: this.props.feedbackApiClient, + sendFeedback: this.sendFeedback, + reset: this.reset, + pending: this.state.pending}); default: return ( - FeedbackLayout( {title:__("feedback_call_experience_heading")}, - React.DOM.div( {className:"faces"}, - React.DOM.button( {className:"face face-happy", - onClick:this.handleHappyClick}), - React.DOM.button( {className:"face face-sad", - onClick:this.handleSadClick}) + FeedbackLayout({title: __("feedback_call_experience_heading")}, + React.DOM.div({className: "faces"}, + React.DOM.button({className: "face face-happy", + onClick: this.handleHappyClick}), + React.DOM.button({className: "face face-sad", + onClick: this.handleSadClick}) ) ) ); diff --git a/browser/components/loop/content/shared/libs/react-0.10.0.js b/browser/components/loop/content/shared/libs/react-0.11.1.js similarity index 81% rename from browser/components/loop/content/shared/libs/react-0.10.0.js rename to browser/components/loop/content/shared/libs/react-0.11.1.js index 7dea4fc53f13..9a58d139c76b 100644 --- a/browser/components/loop/content/shared/libs/react-0.10.0.js +++ b/browser/components/loop/content/shared/libs/react-0.11.1.js @@ -1,7 +1,7 @@ /** - * React (with addons) v0.10.0 + * React (with addons) v0.11.1 */ -!function(e){if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.React=e()}}(function(){var define,module,exports;return (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);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 8 + ( + 'documentMode' in document && + document.documentMode > 8 && + document.documentMode <= 11 + ) ); var topLevelTypes = EventConstants.topLevelTypes; @@ -1057,7 +1390,7 @@ var CompositionEventPlugin = { module.exports = CompositionEventPlugin; -},{"./EventConstants":15,"./EventPropagators":20,"./ExecutionEnvironment":21,"./ReactInputSelection":56,"./SyntheticCompositionEvent":87,"./getTextContentAccessor":121,"./keyOf":132}],8:[function(_dereq_,module,exports){ +},{"./EventConstants":16,"./EventPropagators":21,"./ExecutionEnvironment":22,"./ReactInputSelection":63,"./SyntheticCompositionEvent":94,"./getTextContentAccessor":129,"./keyOf":141}],10:[function(_dereq_,module,exports){ /** * Copyright 2013-2014 Facebook, Inc. * @@ -1083,6 +1416,7 @@ var Danger = _dereq_("./Danger"); var ReactMultiChildUpdateTypes = _dereq_("./ReactMultiChildUpdateTypes"); var getTextContentAccessor = _dereq_("./getTextContentAccessor"); +var invariant = _dereq_("./invariant"); /** * The DOM property to use when setting text content. @@ -1101,20 +1435,14 @@ var textContentAccessor = getTextContentAccessor(); * @internal */ function insertChildAt(parentNode, childNode, index) { - var childNodes = parentNode.childNodes; - if (childNodes[index] === childNode) { - return; - } - // If `childNode` is already a child of `parentNode`, remove it so that - // computing `childNodes[index]` takes into account the removal. - if (childNode.parentNode === parentNode) { - parentNode.removeChild(childNode); - } - if (index >= childNodes.length) { - parentNode.appendChild(childNode); - } else { - parentNode.insertBefore(childNode, childNodes[index]); - } + // By exploiting arrays returning `undefined` for an undefined index, we can + // rely exclusively on `insertBefore(node, null)` instead of also using + // `appendChild(node)`. However, using `undefined` is not allowed by all + // browsers so we must replace it with `null`. + parentNode.insertBefore( + childNode, + parentNode.childNodes[index] || null + ); } var updateTextContent; @@ -1179,6 +1507,18 @@ var DOMChildrenOperations = { var updatedChild = update.parentNode.childNodes[updatedIndex]; var parentID = update.parentID; + ("production" !== "development" ? invariant( + updatedChild, + 'processUpdates(): Unable to find child %s of element. This ' + + 'probably means the DOM was unexpectedly mutated (e.g., by the ' + + 'browser), usually due to forgetting a when using tables, ' + + 'nesting

or tags, or using non-SVG elements in an '+ + 'parent. Try inspecting the child nodes of the element with React ' + + 'ID `%s`.', + updatedIndex, + parentID + ) : invariant(updatedChild)); + initialChildren = initialChildren || {}; initialChildren[parentID] = initialChildren[parentID] || []; initialChildren[parentID][updatedIndex] = updatedChild; @@ -1230,7 +1570,7 @@ var DOMChildrenOperations = { module.exports = DOMChildrenOperations; -},{"./Danger":11,"./ReactMultiChildUpdateTypes":63,"./getTextContentAccessor":121}],9:[function(_dereq_,module,exports){ +},{"./Danger":13,"./ReactMultiChildUpdateTypes":69,"./getTextContentAccessor":129,"./invariant":134}],11:[function(_dereq_,module,exports){ /** * Copyright 2013-2014 Facebook, Inc. * @@ -1265,7 +1605,9 @@ var DOMPropertyInjection = { MUST_USE_PROPERTY: 0x2, HAS_SIDE_EFFECTS: 0x4, HAS_BOOLEAN_VALUE: 0x8, - HAS_POSITIVE_NUMERIC_VALUE: 0x10, + HAS_NUMERIC_VALUE: 0x10, + HAS_POSITIVE_NUMERIC_VALUE: 0x20 | 0x10, + HAS_OVERLOADED_BOOLEAN_VALUE: 0x40, /** * Inject some specialized knowledge about the DOM. This takes a config object @@ -1306,32 +1648,36 @@ var DOMPropertyInjection = { for (var propName in Properties) { ("production" !== "development" ? invariant( - !DOMProperty.isStandardName[propName], + !DOMProperty.isStandardName.hasOwnProperty(propName), 'injectDOMPropertyConfig(...): You\'re trying to inject DOM property ' + '\'%s\' which has already been injected. You may be accidentally ' + 'injecting the same DOM property config twice, or you may be ' + 'injecting two configs that have conflicting property names.', propName - ) : invariant(!DOMProperty.isStandardName[propName])); + ) : invariant(!DOMProperty.isStandardName.hasOwnProperty(propName))); DOMProperty.isStandardName[propName] = true; var lowerCased = propName.toLowerCase(); DOMProperty.getPossibleStandardName[lowerCased] = propName; - var attributeName = DOMAttributeNames[propName]; - if (attributeName) { + if (DOMAttributeNames.hasOwnProperty(propName)) { + var attributeName = DOMAttributeNames[propName]; DOMProperty.getPossibleStandardName[attributeName] = propName; + DOMProperty.getAttributeName[propName] = attributeName; + } else { + DOMProperty.getAttributeName[propName] = lowerCased; } - DOMProperty.getAttributeName[propName] = attributeName || lowerCased; - DOMProperty.getPropertyName[propName] = - DOMPropertyNames[propName] || propName; + DOMPropertyNames.hasOwnProperty(propName) ? + DOMPropertyNames[propName] : + propName; - var mutationMethod = DOMMutationMethods[propName]; - if (mutationMethod) { - DOMProperty.getMutationMethod[propName] = mutationMethod; + if (DOMMutationMethods.hasOwnProperty(propName)) { + DOMProperty.getMutationMethod[propName] = DOMMutationMethods[propName]; + } else { + DOMProperty.getMutationMethod[propName] = null; } var propConfig = Properties[propName]; @@ -1343,8 +1689,12 @@ var DOMPropertyInjection = { propConfig & DOMPropertyInjection.HAS_SIDE_EFFECTS; DOMProperty.hasBooleanValue[propName] = propConfig & DOMPropertyInjection.HAS_BOOLEAN_VALUE; + DOMProperty.hasNumericValue[propName] = + propConfig & DOMPropertyInjection.HAS_NUMERIC_VALUE; DOMProperty.hasPositiveNumericValue[propName] = propConfig & DOMPropertyInjection.HAS_POSITIVE_NUMERIC_VALUE; + DOMProperty.hasOverloadedBooleanValue[propName] = + propConfig & DOMPropertyInjection.HAS_OVERLOADED_BOOLEAN_VALUE; ("production" !== "development" ? invariant( !DOMProperty.mustUseAttribute[propName] || @@ -1361,12 +1711,15 @@ var DOMPropertyInjection = { ) : invariant(DOMProperty.mustUseProperty[propName] || !DOMProperty.hasSideEffects[propName])); ("production" !== "development" ? invariant( - !DOMProperty.hasBooleanValue[propName] || - !DOMProperty.hasPositiveNumericValue[propName], - 'DOMProperty: Cannot have both boolean and positive numeric value: %s', + !!DOMProperty.hasBooleanValue[propName] + + !!DOMProperty.hasNumericValue[propName] + + !!DOMProperty.hasOverloadedBooleanValue[propName] <= 1, + 'DOMProperty: Value can be one of boolean, overloaded boolean, or ' + + 'numeric value, but not a combination: %s', propName - ) : invariant(!DOMProperty.hasBooleanValue[propName] || - !DOMProperty.hasPositiveNumericValue[propName])); + ) : invariant(!!DOMProperty.hasBooleanValue[propName] + + !!DOMProperty.hasNumericValue[propName] + + !!DOMProperty.hasOverloadedBooleanValue[propName] <= 1)); } } }; @@ -1450,6 +1803,13 @@ var DOMProperty = { */ hasBooleanValue: {}, + /** + * Whether the property must be numeric or parse as a + * numeric and should be removed when set to a falsey value. + * @type {Object} + */ + hasNumericValue: {}, + /** * Whether the property must be positive numeric or parse as a positive * numeric and should be removed when set to a falsey value. @@ -1457,6 +1817,14 @@ var DOMProperty = { */ hasPositiveNumericValue: {}, + /** + * Whether the property can be used as a flag as well as with a value. Removed + * when strictly equal to false; present without a value when strictly equal + * to true; present with a value otherwise. + * @type {Object} + */ + hasOverloadedBooleanValue: {}, + /** * All of the isCustomAttribute() functions that have been injected. */ @@ -1502,7 +1870,7 @@ var DOMProperty = { module.exports = DOMProperty; -},{"./invariant":125}],10:[function(_dereq_,module,exports){ +},{"./invariant":134}],12:[function(_dereq_,module,exports){ /** * Copyright 2013-2014 Facebook, Inc. * @@ -1532,8 +1900,10 @@ var warning = _dereq_("./warning"); function shouldIgnoreValue(name, value) { return value == null || - DOMProperty.hasBooleanValue[name] && !value || - DOMProperty.hasPositiveNumericValue[name] && (isNaN(value) || value < 1); + (DOMProperty.hasBooleanValue[name] && !value) || + (DOMProperty.hasNumericValue[name] && isNaN(value)) || + (DOMProperty.hasPositiveNumericValue[name] && (value < 1)) || + (DOMProperty.hasOverloadedBooleanValue[name] && value === false); } var processAttributeNameAndPrefix = memoizeStringOnly(function(name) { @@ -1550,7 +1920,8 @@ if ("production" !== "development") { var warnedProperties = {}; var warnUnknownProperty = function(name) { - if (reactProps[name] || warnedProperties[name]) { + if (reactProps.hasOwnProperty(name) && reactProps[name] || + warnedProperties.hasOwnProperty(name) && warnedProperties[name]) { return; } @@ -1558,8 +1929,13 @@ if ("production" !== "development") { var lowerCasedName = name.toLowerCase(); // data-* attributes should be lowercase; suggest the lowercase version - var standardName = DOMProperty.isCustomAttribute(lowerCasedName) ? - lowerCasedName : DOMProperty.getPossibleStandardName[lowerCasedName]; + var standardName = ( + DOMProperty.isCustomAttribute(lowerCasedName) ? + lowerCasedName : + DOMProperty.getPossibleStandardName.hasOwnProperty(lowerCasedName) ? + DOMProperty.getPossibleStandardName[lowerCasedName] : + null + ); // For now, only warn when we have a suggested correction. This prevents // logging too much when using transferPropsTo. @@ -1595,12 +1971,14 @@ var DOMPropertyOperations = { * @return {?string} Markup string, or null if the property was invalid. */ createMarkupForProperty: function(name, value) { - if (DOMProperty.isStandardName[name]) { + if (DOMProperty.isStandardName.hasOwnProperty(name) && + DOMProperty.isStandardName[name]) { if (shouldIgnoreValue(name, value)) { return ''; } var attributeName = DOMProperty.getAttributeName[name]; - if (DOMProperty.hasBooleanValue[name]) { + if (DOMProperty.hasBooleanValue[name] || + (DOMProperty.hasOverloadedBooleanValue[name] && value === true)) { return escapeTextForBrowser(attributeName); } return processAttributeNameAndPrefix(attributeName) + @@ -1625,7 +2003,8 @@ var DOMPropertyOperations = { * @param {*} value */ setValueForProperty: function(node, name, value) { - if (DOMProperty.isStandardName[name]) { + if (DOMProperty.isStandardName.hasOwnProperty(name) && + DOMProperty.isStandardName[name]) { var mutationMethod = DOMProperty.getMutationMethod[name]; if (mutationMethod) { mutationMethod(node, value); @@ -1641,7 +2020,7 @@ var DOMPropertyOperations = { } } else if (DOMProperty.isCustomAttribute(name)) { if (value == null) { - node.removeAttribute(DOMProperty.getAttributeName[name]); + node.removeAttribute(name); } else { node.setAttribute(name, '' + value); } @@ -1657,7 +2036,8 @@ var DOMPropertyOperations = { * @param {string} name */ deleteValueForProperty: function(node, name) { - if (DOMProperty.isStandardName[name]) { + if (DOMProperty.isStandardName.hasOwnProperty(name) && + DOMProperty.isStandardName[name]) { var mutationMethod = DOMProperty.getMutationMethod[name]; if (mutationMethod) { mutationMethod(node, undefined); @@ -1685,7 +2065,7 @@ var DOMPropertyOperations = { module.exports = DOMPropertyOperations; -},{"./DOMProperty":9,"./escapeTextForBrowser":111,"./memoizeStringOnly":133,"./warning":148}],11:[function(_dereq_,module,exports){ +},{"./DOMProperty":11,"./escapeTextForBrowser":118,"./memoizeStringOnly":143,"./warning":158}],13:[function(_dereq_,module,exports){ /** * Copyright 2013-2014 Facebook, Inc. * @@ -1874,205 +2254,7 @@ var Danger = { module.exports = Danger; -},{"./ExecutionEnvironment":21,"./createNodesFromMarkup":105,"./emptyFunction":109,"./getMarkupWrap":118,"./invariant":125}],12:[function(_dereq_,module,exports){ -/** - * Copyright 2013-2014 Facebook, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * @providesModule DefaultDOMPropertyConfig - */ - -/*jslint bitwise: true*/ - -"use strict"; - -var DOMProperty = _dereq_("./DOMProperty"); - -var MUST_USE_ATTRIBUTE = DOMProperty.injection.MUST_USE_ATTRIBUTE; -var MUST_USE_PROPERTY = DOMProperty.injection.MUST_USE_PROPERTY; -var HAS_BOOLEAN_VALUE = DOMProperty.injection.HAS_BOOLEAN_VALUE; -var HAS_SIDE_EFFECTS = DOMProperty.injection.HAS_SIDE_EFFECTS; -var HAS_POSITIVE_NUMERIC_VALUE = - DOMProperty.injection.HAS_POSITIVE_NUMERIC_VALUE; - -var DefaultDOMPropertyConfig = { - isCustomAttribute: RegExp.prototype.test.bind( - /^(data|aria)-[a-z_][a-z\d_.\-]*$/ - ), - Properties: { - /** - * Standard Properties - */ - accept: null, - accessKey: null, - action: null, - allowFullScreen: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE, - allowTransparency: MUST_USE_ATTRIBUTE, - alt: null, - async: HAS_BOOLEAN_VALUE, - autoComplete: null, - // autoFocus is polyfilled/normalized by AutoFocusMixin - // autoFocus: HAS_BOOLEAN_VALUE, - autoPlay: HAS_BOOLEAN_VALUE, - cellPadding: null, - cellSpacing: null, - charSet: MUST_USE_ATTRIBUTE, - checked: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE, - className: MUST_USE_PROPERTY, - cols: MUST_USE_ATTRIBUTE | HAS_POSITIVE_NUMERIC_VALUE, - colSpan: null, - content: null, - contentEditable: null, - contextMenu: MUST_USE_ATTRIBUTE, - controls: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE, - crossOrigin: null, - data: null, // For `` acts as `src`. - dateTime: MUST_USE_ATTRIBUTE, - defer: HAS_BOOLEAN_VALUE, - dir: null, - disabled: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE, - download: null, - draggable: null, - encType: null, - form: MUST_USE_ATTRIBUTE, - formNoValidate: HAS_BOOLEAN_VALUE, - frameBorder: MUST_USE_ATTRIBUTE, - height: MUST_USE_ATTRIBUTE, - hidden: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE, - href: null, - hrefLang: null, - htmlFor: null, - httpEquiv: null, - icon: null, - id: MUST_USE_PROPERTY, - label: null, - lang: null, - list: null, - loop: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE, - max: null, - maxLength: MUST_USE_ATTRIBUTE, - mediaGroup: null, - method: null, - min: null, - multiple: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE, - muted: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE, - name: null, - noValidate: HAS_BOOLEAN_VALUE, - pattern: null, - placeholder: null, - poster: null, - preload: null, - radioGroup: null, - readOnly: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE, - rel: null, - required: HAS_BOOLEAN_VALUE, - role: MUST_USE_ATTRIBUTE, - rows: MUST_USE_ATTRIBUTE | HAS_POSITIVE_NUMERIC_VALUE, - rowSpan: null, - sandbox: null, - scope: null, - scrollLeft: MUST_USE_PROPERTY, - scrollTop: MUST_USE_PROPERTY, - seamless: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE, - selected: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE, - size: MUST_USE_ATTRIBUTE | HAS_POSITIVE_NUMERIC_VALUE, - span: HAS_POSITIVE_NUMERIC_VALUE, - spellCheck: null, - src: null, - srcDoc: MUST_USE_PROPERTY, - srcSet: null, - step: null, - style: null, - tabIndex: null, - target: null, - title: null, - type: null, - value: MUST_USE_PROPERTY | HAS_SIDE_EFFECTS, - width: MUST_USE_ATTRIBUTE, - wmode: MUST_USE_ATTRIBUTE, - - /** - * Non-standard Properties - */ - autoCapitalize: null, // Supported in Mobile Safari for keyboard hints - autoCorrect: null, // Supported in Mobile Safari for keyboard hints - property: null, // Supports OG in meta tags - - /** - * SVG Properties - */ - cx: MUST_USE_ATTRIBUTE, - cy: MUST_USE_ATTRIBUTE, - d: MUST_USE_ATTRIBUTE, - fill: MUST_USE_ATTRIBUTE, - fx: MUST_USE_ATTRIBUTE, - fy: MUST_USE_ATTRIBUTE, - gradientTransform: MUST_USE_ATTRIBUTE, - gradientUnits: MUST_USE_ATTRIBUTE, - offset: MUST_USE_ATTRIBUTE, - points: MUST_USE_ATTRIBUTE, - r: MUST_USE_ATTRIBUTE, - rx: MUST_USE_ATTRIBUTE, - ry: MUST_USE_ATTRIBUTE, - spreadMethod: MUST_USE_ATTRIBUTE, - stopColor: MUST_USE_ATTRIBUTE, - stopOpacity: MUST_USE_ATTRIBUTE, - stroke: MUST_USE_ATTRIBUTE, - strokeLinecap: MUST_USE_ATTRIBUTE, - strokeWidth: MUST_USE_ATTRIBUTE, - textAnchor: MUST_USE_ATTRIBUTE, - transform: MUST_USE_ATTRIBUTE, - version: MUST_USE_ATTRIBUTE, - viewBox: MUST_USE_ATTRIBUTE, - x1: MUST_USE_ATTRIBUTE, - x2: MUST_USE_ATTRIBUTE, - x: MUST_USE_ATTRIBUTE, - y1: MUST_USE_ATTRIBUTE, - y2: MUST_USE_ATTRIBUTE, - y: MUST_USE_ATTRIBUTE - }, - DOMAttributeNames: { - className: 'class', - gradientTransform: 'gradientTransform', - gradientUnits: 'gradientUnits', - htmlFor: 'for', - spreadMethod: 'spreadMethod', - stopColor: 'stop-color', - stopOpacity: 'stop-opacity', - strokeLinecap: 'stroke-linecap', - strokeWidth: 'stroke-width', - textAnchor: 'text-anchor', - viewBox: 'viewBox' - }, - DOMPropertyNames: { - autoCapitalize: 'autocapitalize', - autoComplete: 'autocomplete', - autoCorrect: 'autocorrect', - autoFocus: 'autofocus', - autoPlay: 'autoplay', - encType: 'enctype', - hrefLang: 'hreflang', - radioGroup: 'radiogroup', - spellCheck: 'spellcheck', - srcDoc: 'srcdoc', - srcSet: 'srcset' - } -}; - -module.exports = DefaultDOMPropertyConfig; - -},{"./DOMProperty":9}],13:[function(_dereq_,module,exports){ +},{"./ExecutionEnvironment":22,"./createNodesFromMarkup":113,"./emptyFunction":116,"./getMarkupWrap":126,"./invariant":134}],14:[function(_dereq_,module,exports){ /** * Copyright 2013-2014 Facebook, Inc. * @@ -2112,13 +2294,14 @@ var DefaultEventPluginOrder = [ keyOf({ChangeEventPlugin: null}), keyOf({SelectEventPlugin: null}), keyOf({CompositionEventPlugin: null}), + keyOf({BeforeInputEventPlugin: null}), keyOf({AnalyticsEventPlugin: null}), keyOf({MobileSafariClickEventPlugin: null}) ]; module.exports = DefaultEventPluginOrder; -},{"./keyOf":132}],14:[function(_dereq_,module,exports){ +},{"./keyOf":141}],15:[function(_dereq_,module,exports){ /** * Copyright 2013-2014 Facebook, Inc. * @@ -2265,7 +2448,7 @@ var EnterLeaveEventPlugin = { module.exports = EnterLeaveEventPlugin; -},{"./EventConstants":15,"./EventPropagators":20,"./ReactMount":60,"./SyntheticMouseEvent":92,"./keyOf":132}],15:[function(_dereq_,module,exports){ +},{"./EventConstants":16,"./EventPropagators":21,"./ReactMount":67,"./SyntheticMouseEvent":100,"./keyOf":141}],16:[function(_dereq_,module,exports){ /** * Copyright 2013-2014 Facebook, Inc. * @@ -2329,6 +2512,7 @@ var topLevelTypes = keyMirror({ topScroll: null, topSelectionChange: null, topSubmit: null, + topTextInput: null, topTouchCancel: null, topTouchEnd: null, topTouchMove: null, @@ -2343,9 +2527,10 @@ var EventConstants = { module.exports = EventConstants; -},{"./keyMirror":131}],16:[function(_dereq_,module,exports){ +},{"./keyMirror":140}],17:[function(_dereq_,module,exports){ /** * @providesModule EventListener + * @typechecks */ var emptyFunction = _dereq_("./emptyFunction"); @@ -2375,7 +2560,7 @@ var EventListener = { target.attachEvent('on' + eventType, callback); return { remove: function() { - target.detachEvent(eventType, callback); + target.detachEvent('on' + eventType, callback); } }; } @@ -2409,12 +2594,14 @@ var EventListener = { } }; } - } + }, + + registerDefault: function() {} }; module.exports = EventListener; -},{"./emptyFunction":109}],17:[function(_dereq_,module,exports){ +},{"./emptyFunction":116}],18:[function(_dereq_,module,exports){ /** * Copyright 2013-2014 Facebook, Inc. * @@ -2437,7 +2624,6 @@ module.exports = EventListener; var EventPluginRegistry = _dereq_("./EventPluginRegistry"); var EventPluginUtils = _dereq_("./EventPluginUtils"); -var ExecutionEnvironment = _dereq_("./ExecutionEnvironment"); var accumulate = _dereq_("./accumulate"); var forEachAccumulated = _dereq_("./forEachAccumulated"); @@ -2571,10 +2757,6 @@ var EventPluginHub = { * @param {?function} listener The callback to store. */ putListener: function(id, registrationName, listener) { - ("production" !== "development" ? invariant( - ExecutionEnvironment.canUseDOM, - 'Cannot call putListener() in a non-DOM environment.' - ) : invariant(ExecutionEnvironment.canUseDOM)); ("production" !== "development" ? invariant( !listener || typeof listener === 'function', 'Expected %s listener to be a function, instead got type %s', @@ -2711,7 +2893,7 @@ var EventPluginHub = { module.exports = EventPluginHub; -},{"./EventPluginRegistry":18,"./EventPluginUtils":19,"./ExecutionEnvironment":21,"./accumulate":98,"./forEachAccumulated":114,"./invariant":125,"./isEventSupported":126,"./monitorCodeUse":138}],18:[function(_dereq_,module,exports){ +},{"./EventPluginRegistry":19,"./EventPluginUtils":20,"./accumulate":106,"./forEachAccumulated":121,"./invariant":134,"./isEventSupported":135,"./monitorCodeUse":148}],19:[function(_dereq_,module,exports){ /** * Copyright 2013-2014 Facebook, Inc. * @@ -2804,11 +2986,11 @@ function recomputePluginOrdering() { */ function publishEventForPlugin(dispatchConfig, PluginModule, eventName) { ("production" !== "development" ? invariant( - !EventPluginRegistry.eventNameDispatchConfigs[eventName], + !EventPluginRegistry.eventNameDispatchConfigs.hasOwnProperty(eventName), 'EventPluginHub: More than one plugin attempted to publish the same ' + 'event name, `%s`.', eventName - ) : invariant(!EventPluginRegistry.eventNameDispatchConfigs[eventName])); + ) : invariant(!EventPluginRegistry.eventNameDispatchConfigs.hasOwnProperty(eventName))); EventPluginRegistry.eventNameDispatchConfigs[eventName] = dispatchConfig; var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames; @@ -2894,7 +3076,8 @@ var EventPluginRegistry = { injectEventPluginOrder: function(InjectedEventPluginOrder) { ("production" !== "development" ? invariant( !EventPluginOrder, - 'EventPluginRegistry: Cannot inject event plugin ordering more than once.' + 'EventPluginRegistry: Cannot inject event plugin ordering more than ' + + 'once. You are likely trying to load more than one copy of React.' ) : invariant(!EventPluginOrder)); // Clone the ordering so it cannot be dynamically mutated. EventPluginOrder = Array.prototype.slice.call(InjectedEventPluginOrder); @@ -2918,7 +3101,8 @@ var EventPluginRegistry = { continue; } var PluginModule = injectedNamesToPlugins[pluginName]; - if (namesToPlugins[pluginName] !== PluginModule) { + if (!namesToPlugins.hasOwnProperty(pluginName) || + namesToPlugins[pluginName] !== PluginModule) { ("production" !== "development" ? invariant( !namesToPlugins[pluginName], 'EventPluginRegistry: Cannot inject two different event plugins ' + @@ -2994,7 +3178,7 @@ var EventPluginRegistry = { module.exports = EventPluginRegistry; -},{"./invariant":125}],19:[function(_dereq_,module,exports){ +},{"./invariant":134}],20:[function(_dereq_,module,exports){ /** * Copyright 2013-2014 Facebook, Inc. * @@ -3132,7 +3316,7 @@ function executeDispatchesInOrder(event, executeDispatch) { * @return id of the first dispatch execution who's listener returns true, or * null if no listener returned true. */ -function executeDispatchesInOrderStopAtTrue(event) { +function executeDispatchesInOrderStopAtTrueImpl(event) { var dispatchListeners = event._dispatchListeners; var dispatchIDs = event._dispatchIDs; if ("production" !== "development") { @@ -3156,6 +3340,16 @@ function executeDispatchesInOrderStopAtTrue(event) { return null; } +/** + * @see executeDispatchesInOrderStopAtTrueImpl + */ +function executeDispatchesInOrderStopAtTrue(event) { + var ret = executeDispatchesInOrderStopAtTrueImpl(event); + event._dispatchIDs = null; + event._dispatchListeners = null; + return ret; +} + /** * Execution of a "direct" dispatch - there must be at most one dispatch * accumulated on the event or it is considered an error. It doesn't really make @@ -3210,7 +3404,7 @@ var EventPluginUtils = { module.exports = EventPluginUtils; -},{"./EventConstants":15,"./invariant":125}],20:[function(_dereq_,module,exports){ +},{"./EventConstants":16,"./invariant":134}],21:[function(_dereq_,module,exports){ /** * Copyright 2013-2014 Facebook, Inc. * @@ -3355,7 +3549,7 @@ var EventPropagators = { module.exports = EventPropagators; -},{"./EventConstants":15,"./EventPluginHub":17,"./accumulate":98,"./forEachAccumulated":114}],21:[function(_dereq_,module,exports){ +},{"./EventConstants":16,"./EventPluginHub":18,"./accumulate":106,"./forEachAccumulated":121}],22:[function(_dereq_,module,exports){ /** * Copyright 2013-2014 Facebook, Inc. * @@ -3378,7 +3572,11 @@ module.exports = EventPropagators; "use strict"; -var canUseDOM = typeof window !== 'undefined'; +var canUseDOM = !!( + typeof window !== 'undefined' && + window.document && + window.document.createElement +); /** * Simple, lightweight module assisting with the detection and context of @@ -3393,7 +3591,9 @@ var ExecutionEnvironment = { canUseWorkers: typeof Worker !== 'undefined', canUseEventListeners: - canUseDOM && (window.addEventListener || window.attachEvent), + canUseDOM && !!(window.addEventListener || window.attachEvent), + + canUseViewport: canUseDOM && !!window.screen, isInWorker: !canUseDOM // For now, this is true - might change in the future. @@ -3401,7 +3601,195 @@ var ExecutionEnvironment = { module.exports = ExecutionEnvironment; -},{}],22:[function(_dereq_,module,exports){ +},{}],23:[function(_dereq_,module,exports){ +/** + * Copyright 2013-2014 Facebook, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @providesModule HTMLDOMPropertyConfig + */ + +/*jslint bitwise: true*/ + +"use strict"; + +var DOMProperty = _dereq_("./DOMProperty"); +var ExecutionEnvironment = _dereq_("./ExecutionEnvironment"); + +var MUST_USE_ATTRIBUTE = DOMProperty.injection.MUST_USE_ATTRIBUTE; +var MUST_USE_PROPERTY = DOMProperty.injection.MUST_USE_PROPERTY; +var HAS_BOOLEAN_VALUE = DOMProperty.injection.HAS_BOOLEAN_VALUE; +var HAS_SIDE_EFFECTS = DOMProperty.injection.HAS_SIDE_EFFECTS; +var HAS_NUMERIC_VALUE = DOMProperty.injection.HAS_NUMERIC_VALUE; +var HAS_POSITIVE_NUMERIC_VALUE = + DOMProperty.injection.HAS_POSITIVE_NUMERIC_VALUE; +var HAS_OVERLOADED_BOOLEAN_VALUE = + DOMProperty.injection.HAS_OVERLOADED_BOOLEAN_VALUE; + +var hasSVG; +if (ExecutionEnvironment.canUseDOM) { + var implementation = document.implementation; + hasSVG = ( + implementation && + implementation.hasFeature && + implementation.hasFeature( + 'http://www.w3.org/TR/SVG11/feature#BasicStructure', + '1.1' + ) + ); +} + + +var HTMLDOMPropertyConfig = { + isCustomAttribute: RegExp.prototype.test.bind( + /^(data|aria)-[a-z_][a-z\d_.\-]*$/ + ), + Properties: { + /** + * Standard Properties + */ + accept: null, + accessKey: null, + action: null, + allowFullScreen: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE, + allowTransparency: MUST_USE_ATTRIBUTE, + alt: null, + async: HAS_BOOLEAN_VALUE, + autoComplete: null, + // autoFocus is polyfilled/normalized by AutoFocusMixin + // autoFocus: HAS_BOOLEAN_VALUE, + autoPlay: HAS_BOOLEAN_VALUE, + cellPadding: null, + cellSpacing: null, + charSet: MUST_USE_ATTRIBUTE, + checked: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE, + // To set className on SVG elements, it's necessary to use .setAttribute; + // this works on HTML elements too in all browsers except IE8. Conveniently, + // IE8 doesn't support SVG and so we can simply use the attribute in + // browsers that support SVG and the property in browsers that don't, + // regardless of whether the element is HTML or SVG. + className: hasSVG ? MUST_USE_ATTRIBUTE : MUST_USE_PROPERTY, + cols: MUST_USE_ATTRIBUTE | HAS_POSITIVE_NUMERIC_VALUE, + colSpan: null, + content: null, + contentEditable: null, + contextMenu: MUST_USE_ATTRIBUTE, + controls: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE, + coords: null, + crossOrigin: null, + data: null, // For `` acts as `src`. + dateTime: MUST_USE_ATTRIBUTE, + defer: HAS_BOOLEAN_VALUE, + dir: null, + disabled: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE, + download: HAS_OVERLOADED_BOOLEAN_VALUE, + draggable: null, + encType: null, + form: MUST_USE_ATTRIBUTE, + formNoValidate: HAS_BOOLEAN_VALUE, + frameBorder: MUST_USE_ATTRIBUTE, + height: MUST_USE_ATTRIBUTE, + hidden: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE, + href: null, + hrefLang: null, + htmlFor: null, + httpEquiv: null, + icon: null, + id: MUST_USE_PROPERTY, + label: null, + lang: null, + list: null, + loop: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE, + max: null, + maxLength: MUST_USE_ATTRIBUTE, + mediaGroup: null, + method: null, + min: null, + multiple: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE, + muted: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE, + name: null, + noValidate: HAS_BOOLEAN_VALUE, + pattern: null, + placeholder: null, + poster: null, + preload: null, + radioGroup: null, + readOnly: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE, + rel: null, + required: HAS_BOOLEAN_VALUE, + role: MUST_USE_ATTRIBUTE, + rows: MUST_USE_ATTRIBUTE | HAS_POSITIVE_NUMERIC_VALUE, + rowSpan: null, + sandbox: null, + scope: null, + scrollLeft: MUST_USE_PROPERTY, + scrolling: null, + scrollTop: MUST_USE_PROPERTY, + seamless: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE, + selected: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE, + shape: null, + size: MUST_USE_ATTRIBUTE | HAS_POSITIVE_NUMERIC_VALUE, + span: HAS_POSITIVE_NUMERIC_VALUE, + spellCheck: null, + src: null, + srcDoc: MUST_USE_PROPERTY, + srcSet: null, + start: HAS_NUMERIC_VALUE, + step: null, + style: null, + tabIndex: null, + target: null, + title: null, + type: null, + useMap: null, + value: MUST_USE_PROPERTY | HAS_SIDE_EFFECTS, + width: MUST_USE_ATTRIBUTE, + wmode: MUST_USE_ATTRIBUTE, + + /** + * Non-standard Properties + */ + autoCapitalize: null, // Supported in Mobile Safari for keyboard hints + autoCorrect: null, // Supported in Mobile Safari for keyboard hints + itemProp: MUST_USE_ATTRIBUTE, // Microdata: http://schema.org/docs/gs.html + itemScope: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE, // Microdata: http://schema.org/docs/gs.html + itemType: MUST_USE_ATTRIBUTE, // Microdata: http://schema.org/docs/gs.html + property: null // Supports OG in meta tags + }, + DOMAttributeNames: { + className: 'class', + htmlFor: 'for', + httpEquiv: 'http-equiv' + }, + DOMPropertyNames: { + autoCapitalize: 'autocapitalize', + autoComplete: 'autocomplete', + autoCorrect: 'autocorrect', + autoFocus: 'autofocus', + autoPlay: 'autoplay', + encType: 'enctype', + hrefLang: 'hreflang', + radioGroup: 'radiogroup', + spellCheck: 'spellcheck', + srcDoc: 'srcdoc', + srcSet: 'srcset' + } +}; + +module.exports = HTMLDOMPropertyConfig; + +},{"./DOMProperty":11,"./ExecutionEnvironment":22}],24:[function(_dereq_,module,exports){ /** * Copyright 2013-2014 Facebook, Inc. * @@ -3449,7 +3837,7 @@ var LinkedStateMixin = { module.exports = LinkedStateMixin; -},{"./ReactLink":58,"./ReactStateSetters":75}],23:[function(_dereq_,module,exports){ +},{"./ReactLink":65,"./ReactStateSetters":81}],25:[function(_dereq_,module,exports){ /** * Copyright 2013-2014 Facebook, Inc. * @@ -3474,7 +3862,6 @@ module.exports = LinkedStateMixin; var ReactPropTypes = _dereq_("./ReactPropTypes"); var invariant = _dereq_("./invariant"); -var warning = _dereq_("./warning"); var hasReadOnlyValue = { 'button': true, @@ -3488,9 +3875,9 @@ var hasReadOnlyValue = { function _assertSingleLink(input) { ("production" !== "development" ? invariant( - input.props.checkedLink == null || input.props.valueLink == null, - 'Cannot provide a checkedLink and a valueLink. If you want to use ' + - 'checkedLink, you probably don\'t want to use valueLink and vice versa.' + input.props.checkedLink == null || input.props.valueLink == null, + 'Cannot provide a checkedLink and a valueLink. If you want to use ' + + 'checkedLink, you probably don\'t want to use valueLink and vice versa.' ) : invariant(input.props.checkedLink == null || input.props.valueLink == null)); } function _assertValueLink(input) { @@ -3536,33 +3923,33 @@ var LinkedValueUtils = { Mixin: { propTypes: { value: function(props, propName, componentName) { - if ("production" !== "development") { - ("production" !== "development" ? warning( - !props[propName] || + if (!props[propName] || hasReadOnlyValue[props.type] || props.onChange || props.readOnly || - props.disabled, - 'You provided a `value` prop to a form field without an ' + - '`onChange` handler. This will render a read-only field. If ' + - 'the field should be mutable use `defaultValue`. Otherwise, ' + - 'set either `onChange` or `readOnly`.' - ) : null); + props.disabled) { + return; } + return new Error( + 'You provided a `value` prop to a form field without an ' + + '`onChange` handler. This will render a read-only field. If ' + + 'the field should be mutable use `defaultValue`. Otherwise, ' + + 'set either `onChange` or `readOnly`.' + ); }, checked: function(props, propName, componentName) { - if ("production" !== "development") { - ("production" !== "development" ? warning( - !props[propName] || + if (!props[propName] || props.onChange || props.readOnly || - props.disabled, - 'You provided a `checked` prop to a form field without an ' + - '`onChange` handler. This will render a read-only field. If ' + - 'the field should be mutable use `defaultChecked`. Otherwise, ' + - 'set either `onChange` or `readOnly`.' - ) : null); + props.disabled) { + return; } + return new Error( + 'You provided a `checked` prop to a form field without an ' + + '`onChange` handler. This will render a read-only field. If ' + + 'the field should be mutable use `defaultChecked`. Otherwise, ' + + 'set either `onChange` or `readOnly`.' + ); }, onChange: ReactPropTypes.func } @@ -3611,7 +3998,61 @@ var LinkedValueUtils = { module.exports = LinkedValueUtils; -},{"./ReactPropTypes":69,"./invariant":125,"./warning":148}],24:[function(_dereq_,module,exports){ +},{"./ReactPropTypes":75,"./invariant":134}],26:[function(_dereq_,module,exports){ +/** + * Copyright 2014 Facebook, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @providesModule LocalEventTrapMixin + */ + +"use strict"; + +var ReactBrowserEventEmitter = _dereq_("./ReactBrowserEventEmitter"); + +var accumulate = _dereq_("./accumulate"); +var forEachAccumulated = _dereq_("./forEachAccumulated"); +var invariant = _dereq_("./invariant"); + +function remove(event) { + event.remove(); +} + +var LocalEventTrapMixin = { + trapBubbledEvent:function(topLevelType, handlerBaseName) { + ("production" !== "development" ? invariant(this.isMounted(), 'Must be mounted to trap events') : invariant(this.isMounted())); + var listener = ReactBrowserEventEmitter.trapBubbledEvent( + topLevelType, + handlerBaseName, + this.getDOMNode() + ); + this._localEventListeners = accumulate(this._localEventListeners, listener); + }, + + // trapCapturedEvent would look nearly identical. We don't implement that + // method because it isn't currently needed. + + componentWillUnmount:function() { + if (this._localEventListeners) { + forEachAccumulated(this._localEventListeners, remove); + } + } +}; + +module.exports = LocalEventTrapMixin; + +},{"./ReactBrowserEventEmitter":31,"./accumulate":106,"./forEachAccumulated":121,"./invariant":134}],27:[function(_dereq_,module,exports){ /** * Copyright 2013-2014 Facebook, Inc. * @@ -3676,7 +4117,7 @@ var MobileSafariClickEventPlugin = { module.exports = MobileSafariClickEventPlugin; -},{"./EventConstants":15,"./emptyFunction":109}],25:[function(_dereq_,module,exports){ +},{"./EventConstants":16,"./emptyFunction":116}],28:[function(_dereq_,module,exports){ /** * Copyright 2013-2014 Facebook, Inc. * @@ -3797,7 +4238,7 @@ var PooledClass = { module.exports = PooledClass; -},{"./invariant":125}],26:[function(_dereq_,module,exports){ +},{"./invariant":134}],29:[function(_dereq_,module,exports){ /** * Copyright 2013-2014 Facebook, Inc. * @@ -3825,6 +4266,7 @@ var ReactComponent = _dereq_("./ReactComponent"); var ReactCompositeComponent = _dereq_("./ReactCompositeComponent"); var ReactContext = _dereq_("./ReactContext"); var ReactCurrentOwner = _dereq_("./ReactCurrentOwner"); +var ReactDescriptor = _dereq_("./ReactDescriptor"); var ReactDOM = _dereq_("./ReactDOM"); var ReactDOMComponent = _dereq_("./ReactDOMComponent"); var ReactDefaultInjection = _dereq_("./ReactDefaultInjection"); @@ -3844,6 +4286,7 @@ var React = { Children: { map: ReactChildren.map, forEach: ReactChildren.forEach, + count: ReactChildren.count, only: onlyChild }, DOM: ReactDOM, @@ -3852,6 +4295,10 @@ var React = { EventPluginUtils.useTouchEvents = shouldUseTouch; }, createClass: ReactCompositeComponent.createClass, + createDescriptor: function(type, props, children) { + var args = Array.prototype.slice.call(arguments, 1); + return type.apply(null, args); + }, constructAndRenderComponent: ReactMount.constructAndRenderComponent, constructAndRenderComponentByID: ReactMount.constructAndRenderComponentByID, renderComponent: ReactPerf.measure( @@ -3863,8 +4310,8 @@ var React = { renderComponentToStaticMarkup: ReactServerRendering.renderComponentToStaticMarkup, unmountComponentAtNode: ReactMount.unmountComponentAtNode, - isValidClass: ReactCompositeComponent.isValidClass, - isValidComponent: ReactComponent.isValidComponent, + isValidClass: ReactDescriptor.isValidFactory, + isValidComponent: ReactDescriptor.isValidDescriptor, withContext: ReactContext.withContext, __internals: { Component: ReactComponent, @@ -3887,16 +4334,44 @@ if ("production" !== "development") { 'Download the React DevTools for a better development experience: ' + 'http://fb.me/react-devtools' ); + + var expectedFeatures = [ + // shims + Array.isArray, + Array.prototype.every, + Array.prototype.forEach, + Array.prototype.indexOf, + Array.prototype.map, + Date.now, + Function.prototype.bind, + Object.keys, + String.prototype.split, + String.prototype.trim, + + // shams + Object.create, + Object.freeze + ]; + + for (var i in expectedFeatures) { + if (!expectedFeatures[i]) { + console.error( + 'One or more ES5 shim/shams expected by React are not available: ' + + 'http://fb.me/react-warning-polyfills' + ); + break; + } + } } } // Version exists only in the open-source version of React, not in Facebook's // internal version. -React.version = '0.10.0'; +React.version = '0.11.1'; module.exports = React; -},{"./DOMPropertyOperations":10,"./EventPluginUtils":19,"./ExecutionEnvironment":21,"./ReactChildren":30,"./ReactComponent":31,"./ReactCompositeComponent":33,"./ReactContext":34,"./ReactCurrentOwner":35,"./ReactDOM":36,"./ReactDOMComponent":38,"./ReactDefaultInjection":48,"./ReactInstanceHandles":57,"./ReactMount":60,"./ReactMultiChild":62,"./ReactPerf":65,"./ReactPropTypes":69,"./ReactServerRendering":73,"./ReactTextComponent":77,"./onlyChild":141}],27:[function(_dereq_,module,exports){ +},{"./DOMPropertyOperations":12,"./EventPluginUtils":20,"./ExecutionEnvironment":22,"./ReactChildren":34,"./ReactComponent":35,"./ReactCompositeComponent":38,"./ReactContext":39,"./ReactCurrentOwner":40,"./ReactDOM":41,"./ReactDOMComponent":43,"./ReactDefaultInjection":53,"./ReactDescriptor":56,"./ReactInstanceHandles":64,"./ReactMount":67,"./ReactMultiChild":68,"./ReactPerf":71,"./ReactPropTypes":75,"./ReactServerRendering":79,"./ReactTextComponent":83,"./onlyChild":149}],30:[function(_dereq_,module,exports){ /** * Copyright 2013-2014 Facebook, Inc. * @@ -3917,6 +4392,7 @@ module.exports = React; "use strict"; +var ReactEmptyComponent = _dereq_("./ReactEmptyComponent"); var ReactMount = _dereq_("./ReactMount"); var invariant = _dereq_("./invariant"); @@ -3934,13 +4410,378 @@ var ReactBrowserComponentMixin = { this.isMounted(), 'getDOMNode(): A component must be mounted to have a DOM node.' ) : invariant(this.isMounted())); + if (ReactEmptyComponent.isNullComponentID(this._rootNodeID)) { + return null; + } return ReactMount.getNode(this._rootNodeID); } }; module.exports = ReactBrowserComponentMixin; -},{"./ReactMount":60,"./invariant":125}],28:[function(_dereq_,module,exports){ +},{"./ReactEmptyComponent":58,"./ReactMount":67,"./invariant":134}],31:[function(_dereq_,module,exports){ +/** + * Copyright 2013-2014 Facebook, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @providesModule ReactBrowserEventEmitter + * @typechecks static-only + */ + +"use strict"; + +var EventConstants = _dereq_("./EventConstants"); +var EventPluginHub = _dereq_("./EventPluginHub"); +var EventPluginRegistry = _dereq_("./EventPluginRegistry"); +var ReactEventEmitterMixin = _dereq_("./ReactEventEmitterMixin"); +var ViewportMetrics = _dereq_("./ViewportMetrics"); + +var isEventSupported = _dereq_("./isEventSupported"); +var merge = _dereq_("./merge"); + +/** + * Summary of `ReactBrowserEventEmitter` event handling: + * + * - Top-level delegation is used to trap most native browser events. This + * may only occur in the main thread and is the responsibility of + * ReactEventListener, which is injected and can therefore support pluggable + * event sources. This is the only work that occurs in the main thread. + * + * - We normalize and de-duplicate events to account for browser quirks. This + * may be done in the worker thread. + * + * - Forward these native events (with the associated top-level type used to + * trap it) to `EventPluginHub`, which in turn will ask plugins if they want + * to extract any synthetic events. + * + * - The `EventPluginHub` will then process each event by annotating them with + * "dispatches", a sequence of listeners and IDs that care about that event. + * + * - The `EventPluginHub` then dispatches the events. + * + * Overview of React and the event system: + * + * +------------+ . + * | DOM | . + * +------------+ . + * | . + * v . + * +------------+ . + * | ReactEvent | . + * | Listener | . + * +------------+ . +-----------+ + * | . +--------+|SimpleEvent| + * | . | |Plugin | + * +-----|------+ . v +-----------+ + * | | | . +--------------+ +------------+ + * | +-----------.--->|EventPluginHub| | Event | + * | | . | | +-----------+ | Propagators| + * | ReactEvent | . | | |TapEvent | |------------| + * | Emitter | . | |<---+|Plugin | |other plugin| + * | | . | | +-----------+ | utilities | + * | +-----------.--->| | +------------+ + * | | | . +--------------+ + * +-----|------+ . ^ +-----------+ + * | . | |Enter/Leave| + * + . +-------+|Plugin | + * +-------------+ . +-----------+ + * | application | . + * |-------------| . + * | | . + * | | . + * +-------------+ . + * . + * React Core . General Purpose Event Plugin System + */ + +var alreadyListeningTo = {}; +var isMonitoringScrollValue = false; +var reactTopListenersCounter = 0; + +// For events like 'submit' which don't consistently bubble (which we trap at a +// lower node than `document`), binding at `document` would cause duplicate +// events so we don't include them here +var topEventMapping = { + topBlur: 'blur', + topChange: 'change', + topClick: 'click', + topCompositionEnd: 'compositionend', + topCompositionStart: 'compositionstart', + topCompositionUpdate: 'compositionupdate', + topContextMenu: 'contextmenu', + topCopy: 'copy', + topCut: 'cut', + topDoubleClick: 'dblclick', + topDrag: 'drag', + topDragEnd: 'dragend', + topDragEnter: 'dragenter', + topDragExit: 'dragexit', + topDragLeave: 'dragleave', + topDragOver: 'dragover', + topDragStart: 'dragstart', + topDrop: 'drop', + topFocus: 'focus', + topInput: 'input', + topKeyDown: 'keydown', + topKeyPress: 'keypress', + topKeyUp: 'keyup', + topMouseDown: 'mousedown', + topMouseMove: 'mousemove', + topMouseOut: 'mouseout', + topMouseOver: 'mouseover', + topMouseUp: 'mouseup', + topPaste: 'paste', + topScroll: 'scroll', + topSelectionChange: 'selectionchange', + topTextInput: 'textInput', + topTouchCancel: 'touchcancel', + topTouchEnd: 'touchend', + topTouchMove: 'touchmove', + topTouchStart: 'touchstart', + topWheel: 'wheel' +}; + +/** + * To ensure no conflicts with other potential React instances on the page + */ +var topListenersIDKey = "_reactListenersID" + String(Math.random()).slice(2); + +function getListeningForDocument(mountAt) { + // In IE8, `mountAt` is a host object and doesn't have `hasOwnProperty` + // directly. + if (!Object.prototype.hasOwnProperty.call(mountAt, topListenersIDKey)) { + mountAt[topListenersIDKey] = reactTopListenersCounter++; + alreadyListeningTo[mountAt[topListenersIDKey]] = {}; + } + return alreadyListeningTo[mountAt[topListenersIDKey]]; +} + +/** + * `ReactBrowserEventEmitter` is used to attach top-level event listeners. For + * example: + * + * ReactBrowserEventEmitter.putListener('myID', 'onClick', myFunction); + * + * This would allocate a "registration" of `('onClick', myFunction)` on 'myID'. + * + * @internal + */ +var ReactBrowserEventEmitter = merge(ReactEventEmitterMixin, { + + /** + * Injectable event backend + */ + ReactEventListener: null, + + injection: { + /** + * @param {object} ReactEventListener + */ + injectReactEventListener: function(ReactEventListener) { + ReactEventListener.setHandleTopLevel( + ReactBrowserEventEmitter.handleTopLevel + ); + ReactBrowserEventEmitter.ReactEventListener = ReactEventListener; + } + }, + + /** + * Sets whether or not any created callbacks should be enabled. + * + * @param {boolean} enabled True if callbacks should be enabled. + */ + setEnabled: function(enabled) { + if (ReactBrowserEventEmitter.ReactEventListener) { + ReactBrowserEventEmitter.ReactEventListener.setEnabled(enabled); + } + }, + + /** + * @return {boolean} True if callbacks are enabled. + */ + isEnabled: function() { + return !!( + ReactBrowserEventEmitter.ReactEventListener && + ReactBrowserEventEmitter.ReactEventListener.isEnabled() + ); + }, + + /** + * We listen for bubbled touch events on the document object. + * + * Firefox v8.01 (and possibly others) exhibited strange behavior when + * mounting `onmousemove` events at some node that was not the document + * element. The symptoms were that if your mouse is not moving over something + * contained within that mount point (for example on the background) the + * top-level listeners for `onmousemove` won't be called. However, if you + * register the `mousemove` on the document object, then it will of course + * catch all `mousemove`s. This along with iOS quirks, justifies restricting + * top-level listeners to the document object only, at least for these + * movement types of events and possibly all events. + * + * @see http://www.quirksmode.org/blog/archives/2010/09/click_event_del.html + * + * Also, `keyup`/`keypress`/`keydown` do not bubble to the window on IE, but + * they bubble to document. + * + * @param {string} registrationName Name of listener (e.g. `onClick`). + * @param {object} contentDocumentHandle Document which owns the container + */ + listenTo: function(registrationName, contentDocumentHandle) { + var mountAt = contentDocumentHandle; + var isListening = getListeningForDocument(mountAt); + var dependencies = EventPluginRegistry. + registrationNameDependencies[registrationName]; + + var topLevelTypes = EventConstants.topLevelTypes; + for (var i = 0, l = dependencies.length; i < l; i++) { + var dependency = dependencies[i]; + if (!( + isListening.hasOwnProperty(dependency) && + isListening[dependency] + )) { + if (dependency === topLevelTypes.topWheel) { + if (isEventSupported('wheel')) { + ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent( + topLevelTypes.topWheel, + 'wheel', + mountAt + ); + } else if (isEventSupported('mousewheel')) { + ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent( + topLevelTypes.topWheel, + 'mousewheel', + mountAt + ); + } else { + // Firefox needs to capture a different mouse scroll event. + // @see http://www.quirksmode.org/dom/events/tests/scroll.html + ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent( + topLevelTypes.topWheel, + 'DOMMouseScroll', + mountAt + ); + } + } else if (dependency === topLevelTypes.topScroll) { + + if (isEventSupported('scroll', true)) { + ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent( + topLevelTypes.topScroll, + 'scroll', + mountAt + ); + } else { + ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent( + topLevelTypes.topScroll, + 'scroll', + ReactBrowserEventEmitter.ReactEventListener.WINDOW_HANDLE + ); + } + } else if (dependency === topLevelTypes.topFocus || + dependency === topLevelTypes.topBlur) { + + if (isEventSupported('focus', true)) { + ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent( + topLevelTypes.topFocus, + 'focus', + mountAt + ); + ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent( + topLevelTypes.topBlur, + 'blur', + mountAt + ); + } else if (isEventSupported('focusin')) { + // IE has `focusin` and `focusout` events which bubble. + // @see http://www.quirksmode.org/blog/archives/2008/04/delegating_the.html + ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent( + topLevelTypes.topFocus, + 'focusin', + mountAt + ); + ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent( + topLevelTypes.topBlur, + 'focusout', + mountAt + ); + } + + // to make sure blur and focus event listeners are only attached once + isListening[topLevelTypes.topBlur] = true; + isListening[topLevelTypes.topFocus] = true; + } else if (topEventMapping.hasOwnProperty(dependency)) { + ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent( + dependency, + topEventMapping[dependency], + mountAt + ); + } + + isListening[dependency] = true; + } + } + }, + + trapBubbledEvent: function(topLevelType, handlerBaseName, handle) { + return ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent( + topLevelType, + handlerBaseName, + handle + ); + }, + + trapCapturedEvent: function(topLevelType, handlerBaseName, handle) { + return ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent( + topLevelType, + handlerBaseName, + handle + ); + }, + + /** + * Listens to window scroll and resize events. We cache scroll values so that + * application code can access them without triggering reflows. + * + * NOTE: Scroll events do not bubble. + * + * @see http://www.quirksmode.org/dom/events/scroll.html + */ + ensureScrollValueMonitoring: function(){ + if (!isMonitoringScrollValue) { + var refresh = ViewportMetrics.refreshScrollValues; + ReactBrowserEventEmitter.ReactEventListener.monitorScrollValue(refresh); + isMonitoringScrollValue = true; + } + }, + + eventNameDispatchConfigs: EventPluginHub.eventNameDispatchConfigs, + + registrationNameModules: EventPluginHub.registrationNameModules, + + putListener: EventPluginHub.putListener, + + getListener: EventPluginHub.getListener, + + deleteListener: EventPluginHub.deleteListener, + + deleteAllListeners: EventPluginHub.deleteAllListeners + +}); + +module.exports = ReactBrowserEventEmitter; + +},{"./EventConstants":16,"./EventPluginHub":18,"./EventPluginRegistry":19,"./ReactEventEmitterMixin":60,"./ViewportMetrics":105,"./isEventSupported":135,"./merge":144}],32:[function(_dereq_,module,exports){ /** * Copyright 2013-2014 Facebook, Inc. * @@ -3968,6 +4809,8 @@ var ReactTransitionGroup = _dereq_("./ReactTransitionGroup"); var ReactCSSTransitionGroupChild = _dereq_("./ReactCSSTransitionGroupChild"); var ReactCSSTransitionGroup = React.createClass({ + displayName: 'ReactCSSTransitionGroup', + propTypes: { transitionName: React.PropTypes.string.isRequired, transitionEnter: React.PropTypes.bool, @@ -4007,7 +4850,7 @@ var ReactCSSTransitionGroup = React.createClass({ module.exports = ReactCSSTransitionGroup; -},{"./React":26,"./ReactCSSTransitionGroupChild":29,"./ReactTransitionGroup":80}],29:[function(_dereq_,module,exports){ +},{"./React":29,"./ReactCSSTransitionGroupChild":33,"./ReactTransitionGroup":86}],33:[function(_dereq_,module,exports){ /** * Copyright 2013-2014 Facebook, Inc. * @@ -4058,6 +4901,8 @@ if ("production" !== "development") { } var ReactCSSTransitionGroupChild = React.createClass({ + displayName: 'ReactCSSTransitionGroupChild', + transition: function(animationType, finishCallback) { var node = this.getDOMNode(); var className = this.props.name + '-' + animationType; @@ -4094,11 +4939,6 @@ var ReactCSSTransitionGroupChild = React.createClass({ queueClass: function(className) { this.classNameQueue.push(className); - if (this.props.runNextTick) { - this.props.runNextTick(this.flushClassNameQueue); - return; - } - if (!this.timeout) { this.timeout = setTimeout(this.flushClassNameQueue, TICK); } @@ -4147,7 +4987,7 @@ var ReactCSSTransitionGroupChild = React.createClass({ module.exports = ReactCSSTransitionGroupChild; -},{"./CSSCore":2,"./React":26,"./ReactTransitionEvents":79,"./onlyChild":141}],30:[function(_dereq_,module,exports){ +},{"./CSSCore":3,"./React":29,"./ReactTransitionEvents":85,"./onlyChild":149}],34:[function(_dereq_,module,exports){ /** * Copyright 2013-2014 Facebook, Inc. * @@ -4170,8 +5010,8 @@ module.exports = ReactCSSTransitionGroupChild; var PooledClass = _dereq_("./PooledClass"); -var invariant = _dereq_("./invariant"); var traverseAllChildren = _dereq_("./traverseAllChildren"); +var warning = _dereq_("./warning"); var twoArgumentPooler = PooledClass.twoArgumentPooler; var threeArgumentPooler = PooledClass.threeArgumentPooler; @@ -4236,16 +5076,21 @@ PooledClass.addPoolingTo(MapBookKeeping, threeArgumentPooler); function mapSingleChildIntoContext(traverseContext, child, name, i) { var mapBookKeeping = traverseContext; var mapResult = mapBookKeeping.mapResult; - var mappedChild = - mapBookKeeping.mapFunction.call(mapBookKeeping.mapContext, child, i); - // We found a component instance - ("production" !== "development" ? invariant( - !mapResult.hasOwnProperty(name), + + var keyUnique = !mapResult.hasOwnProperty(name); + ("production" !== "development" ? warning( + keyUnique, 'ReactChildren.map(...): Encountered two children with the same key, ' + - '`%s`. Children keys must be unique.', + '`%s`. Child keys must be unique; when two children share a key, only ' + + 'the first child will be used.', name - ) : invariant(!mapResult.hasOwnProperty(name))); - mapResult[name] = mappedChild; + ) : null); + + if (keyUnique) { + var mappedChild = + mapBookKeeping.mapFunction.call(mapBookKeeping.mapContext, child, i); + mapResult[name] = mappedChild; + } } /** @@ -4274,14 +5119,30 @@ function mapChildren(children, func, context) { return mapResult; } +function forEachSingleChildDummy(traverseContext, child, name, i) { + return null; +} + +/** + * Count the number of children that are typically specified as + * `props.children`. + * + * @param {?*} children Children tree container. + * @return {number} The number of children. + */ +function countChildren(children, context) { + return traverseAllChildren(children, forEachSingleChildDummy, null); +} + var ReactChildren = { forEach: forEachChildren, - map: mapChildren + map: mapChildren, + count: countChildren }; module.exports = ReactChildren; -},{"./PooledClass":25,"./invariant":125,"./traverseAllChildren":146}],31:[function(_dereq_,module,exports){ +},{"./PooledClass":28,"./traverseAllChildren":156,"./warning":158}],35:[function(_dereq_,module,exports){ /** * Copyright 2013-2014 Facebook, Inc. * @@ -4302,14 +5163,13 @@ module.exports = ReactChildren; "use strict"; -var ReactCurrentOwner = _dereq_("./ReactCurrentOwner"); +var ReactDescriptor = _dereq_("./ReactDescriptor"); var ReactOwner = _dereq_("./ReactOwner"); var ReactUpdates = _dereq_("./ReactUpdates"); var invariant = _dereq_("./invariant"); var keyMirror = _dereq_("./keyMirror"); var merge = _dereq_("./merge"); -var monitorCodeUse = _dereq_("./monitorCodeUse"); /** * Every React component is in one of these life cycles. @@ -4326,18 +5186,6 @@ var ComponentLifeCycle = keyMirror({ UNMOUNTED: null }); -/** - * Warn if there's no key explicitly set on dynamic arrays of children or - * object keys are not valid. This allows us to keep track of children between - * updates. - */ - -var ownerHasExplicitKeyWarning = {}; -var ownerHasPropertyWarning = {}; -var ownerHasMonitoredObjectMap = {}; - -var NUMERIC_PROPERTY_REGEX = /^\d+$/; - var injected = false; /** @@ -4360,130 +5208,6 @@ var unmountIDFromEnvironment = null; */ var mountImageIntoNode = null; -/** - * Warn if the component doesn't have an explicit key assigned to it. - * This component is in an array. The array could grow and shrink or be - * reordered. All children that haven't already been validated are required to - * have a "key" property assigned to it. - * - * @internal - * @param {ReactComponent} component Component that requires a key. - */ -function validateExplicitKey(component) { - if (component.__keyValidated__ || component.props.key != null) { - return; - } - component.__keyValidated__ = true; - - // We can't provide friendly warnings for top level components. - if (!ReactCurrentOwner.current) { - return; - } - - // Name of the component whose render method tried to pass children. - var currentName = ReactCurrentOwner.current.constructor.displayName; - if (ownerHasExplicitKeyWarning.hasOwnProperty(currentName)) { - return; - } - ownerHasExplicitKeyWarning[currentName] = true; - - var message = 'Each child in an array should have a unique "key" prop. ' + - 'Check the render method of ' + currentName + '.'; - - var childOwnerName = null; - if (!component.isOwnedBy(ReactCurrentOwner.current)) { - // Name of the component that originally created this child. - childOwnerName = - component._owner && - component._owner.constructor.displayName; - - // Usually the current owner is the offender, but if it accepts - // children as a property, it may be the creator of the child that's - // responsible for assigning it a key. - message += ' It was passed a child from ' + childOwnerName + '.'; - } - - message += ' See http://fb.me/react-warning-keys for more information.'; - monitorCodeUse('react_key_warning', { - component: currentName, - componentOwner: childOwnerName - }); - console.warn(message); -} - -/** - * Warn if the key is being defined as an object property but has an incorrect - * value. - * - * @internal - * @param {string} name Property name of the key. - * @param {ReactComponent} component Component that requires a key. - */ -function validatePropertyKey(name) { - if (NUMERIC_PROPERTY_REGEX.test(name)) { - // Name of the component whose render method tried to pass children. - var currentName = ReactCurrentOwner.current.constructor.displayName; - if (ownerHasPropertyWarning.hasOwnProperty(currentName)) { - return; - } - ownerHasPropertyWarning[currentName] = true; - - monitorCodeUse('react_numeric_key_warning'); - console.warn( - 'Child objects should have non-numeric keys so ordering is preserved. ' + - 'Check the render method of ' + currentName + '. ' + - 'See http://fb.me/react-warning-keys for more information.' - ); - } -} - -/** - * Log that we're using an object map. We're considering deprecating this - * feature and replace it with proper Map and ImmutableMap data structures. - * - * @internal - */ -function monitorUseOfObjectMap() { - // Name of the component whose render method tried to pass children. - // We only use this to avoid spewing the logs. We lose additional - // owner stacks but hopefully one level is enough to trace the source. - var currentName = (ReactCurrentOwner.current && - ReactCurrentOwner.current.constructor.displayName) || ''; - if (ownerHasMonitoredObjectMap.hasOwnProperty(currentName)) { - return; - } - ownerHasMonitoredObjectMap[currentName] = true; - monitorCodeUse('react_object_map_children'); -} - -/** - * Ensure that every component either is passed in a static location, in an - * array with an explicit keys property defined, or in an object literal - * with valid key property. - * - * @internal - * @param {*} component Statically passed child of any type. - * @return {boolean} - */ -function validateChildKeys(component) { - if (Array.isArray(component)) { - for (var i = 0; i < component.length; i++) { - var child = component[i]; - if (ReactComponent.isValidComponent(child)) { - validateExplicitKey(child); - } - } - } else if (ReactComponent.isValidComponent(component)) { - // This component was passed in a valid location. - component.__keyValidated__ = true; - } else if (component && typeof component === 'object') { - monitorUseOfObjectMap(); - for (var name in component) { - validatePropertyKey(name, component); - } - } -} - /** * Components are the basic units of composition in React. * @@ -4522,32 +5246,10 @@ var ReactComponent = { ReactComponentEnvironment.unmountIDFromEnvironment; ReactComponent.BackendIDOperations = ReactComponentEnvironment.BackendIDOperations; - ReactComponent.ReactReconcileTransaction = - ReactComponentEnvironment.ReactReconcileTransaction; injected = true; } }, - /** - * @param {?object} object - * @return {boolean} True if `object` is a valid component. - * @final - */ - isValidComponent: function(object) { - if (!object || !object.type || !object.type.prototype) { - return false; - } - // This is the safer way of duck checking the type of instance this is. - // The object can be a generic descriptor but the type property refers to - // the constructor and it's prototype can be used to inspect the type that - // will actually get mounted. - var prototype = object.type.prototype; - return ( - typeof prototype.mountComponentIntoNode === 'function' && - typeof prototype.receiveComponent === 'function' - ); - }, - /** * @internal */ @@ -4562,14 +5264,6 @@ var ReactComponent = { */ BackendIDOperations: null, - /** - * React references `ReactReconcileTransaction` using this property in order - * to allow dependency injection. - * - * @internal - */ - ReactReconcileTransaction: null, - /** * Base functionality for every ReactComponent constructor. Mixed into the * `ReactComponent` prototype, but exposed statically for easy access. @@ -4598,9 +5292,11 @@ var ReactComponent = { * @public */ setProps: function(partialProps, callback) { - // Merge with `_pendingProps` if it exists, otherwise with existing props. + // Merge with the pending descriptor if it exists, otherwise with existing + // descriptor props. + var descriptor = this._pendingDescriptor || this._descriptor; this.replaceProps( - merge(this._pendingProps || this.props, partialProps), + merge(descriptor.props, partialProps), callback ); }, @@ -4626,7 +5322,31 @@ var ReactComponent = { '`render` method to pass the correct value as props to the component ' + 'where it is created.' ) : invariant(this._mountDepth === 0)); - this._pendingProps = props; + // This is a deoptimized path. We optimize for always having a descriptor. + // This creates an extra internal descriptor. + this._pendingDescriptor = ReactDescriptor.cloneAndReplaceProps( + this._pendingDescriptor || this._descriptor, + props + ); + ReactUpdates.enqueueUpdate(this, callback); + }, + + /** + * Schedule a partial update to the props. Only used for internal testing. + * + * @param {object} partialProps Subset of the next props. + * @param {?function} callback Called after props are updated. + * @final + * @internal + */ + _setPropsInternal: function(partialProps, callback) { + // This is a deoptimized path. We optimize for always having a descriptor. + // This creates an extra internal descriptor. + var descriptor = this._pendingDescriptor || this._descriptor; + this._pendingDescriptor = ReactDescriptor.cloneAndReplaceProps( + descriptor, + merge(descriptor.props, partialProps) + ); ReactUpdates.enqueueUpdate(this, callback); }, @@ -4636,43 +5356,30 @@ var ReactComponent = { * Subclasses that override this method should make sure to invoke * `ReactComponent.Mixin.construct.call(this, ...)`. * - * @param {?object} initialProps - * @param {*} children + * @param {ReactDescriptor} descriptor * @internal */ - construct: function(initialProps, children) { - this.props = initialProps || {}; + construct: function(descriptor) { + // This is the public exposed props object after it has been processed + // with default props. The descriptor's props represents the true internal + // state of the props. + this.props = descriptor.props; // Record the component responsible for creating this component. - this._owner = ReactCurrentOwner.current; + // This is accessible through the descriptor but we maintain an extra + // field for compatibility with devtools and as a way to make an + // incremental update. TODO: Consider deprecating this field. + this._owner = descriptor._owner; + // All components start unmounted. this._lifeCycleState = ComponentLifeCycle.UNMOUNTED; - this._pendingProps = null; + // See ReactUpdates. this._pendingCallbacks = null; - // Unlike _pendingProps and _pendingCallbacks, we won't use null to - // indicate that nothing is pending because it's possible for a component - // to have a null owner. Instead, an owner change is pending when - // this._owner !== this._pendingOwner. - this._pendingOwner = this._owner; - - // Children can be more than one argument - var childrenLength = arguments.length - 1; - if (childrenLength === 1) { - if ("production" !== "development") { - validateChildKeys(children); - } - this.props.children = children; - } else if (childrenLength > 1) { - var childArray = Array(childrenLength); - for (var i = 0; i < childrenLength; i++) { - if ("production" !== "development") { - validateChildKeys(arguments[i + 1]); - } - childArray[i] = arguments[i + 1]; - } - this.props.children = childArray; - } + // We keep the old descriptor and a reference to the pending descriptor + // to track updates. + this._descriptor = descriptor; + this._pendingDescriptor = null; }, /** @@ -4697,9 +5404,10 @@ var ReactComponent = { 'single component instance in multiple places.', rootID ) : invariant(!this.isMounted())); - var props = this.props; + var props = this._descriptor.props; if (props.ref != null) { - ReactOwner.addComponentAsRefTo(this, props.ref, this._owner); + var owner = this._descriptor._owner; + ReactOwner.addComponentAsRefTo(this, props.ref, owner); } this._rootNodeID = rootID; this._lifeCycleState = ComponentLifeCycle.MOUNTED; @@ -4742,66 +5450,70 @@ var ReactComponent = { * @param {ReactReconcileTransaction} transaction * @internal */ - receiveComponent: function(nextComponent, transaction) { + receiveComponent: function(nextDescriptor, transaction) { ("production" !== "development" ? invariant( this.isMounted(), 'receiveComponent(...): Can only update a mounted component.' ) : invariant(this.isMounted())); - this._pendingOwner = nextComponent._owner; - this._pendingProps = nextComponent.props; - this._performUpdateIfNecessary(transaction); + this._pendingDescriptor = nextDescriptor; + this.performUpdateIfNecessary(transaction); }, /** - * Call `_performUpdateIfNecessary` within a new transaction. - * - * @internal - */ - performUpdateIfNecessary: function() { - var transaction = ReactComponent.ReactReconcileTransaction.getPooled(); - transaction.perform(this._performUpdateIfNecessary, this, transaction); - ReactComponent.ReactReconcileTransaction.release(transaction); - }, - - /** - * If `_pendingProps` is set, update the component. + * If `_pendingDescriptor` is set, update the component. * * @param {ReactReconcileTransaction} transaction * @internal */ - _performUpdateIfNecessary: function(transaction) { - if (this._pendingProps == null) { + performUpdateIfNecessary: function(transaction) { + if (this._pendingDescriptor == null) { return; } - var prevProps = this.props; - var prevOwner = this._owner; - this.props = this._pendingProps; - this._owner = this._pendingOwner; - this._pendingProps = null; - this.updateComponent(transaction, prevProps, prevOwner); + var prevDescriptor = this._descriptor; + var nextDescriptor = this._pendingDescriptor; + this._descriptor = nextDescriptor; + this.props = nextDescriptor.props; + this._owner = nextDescriptor._owner; + this._pendingDescriptor = null; + this.updateComponent(transaction, prevDescriptor); }, /** * Updates the component's currently mounted representation. * * @param {ReactReconcileTransaction} transaction - * @param {object} prevProps + * @param {object} prevDescriptor * @internal */ - updateComponent: function(transaction, prevProps, prevOwner) { - var props = this.props; + updateComponent: function(transaction, prevDescriptor) { + var nextDescriptor = this._descriptor; + // If either the owner or a `ref` has changed, make sure the newest owner // has stored a reference to `this`, and the previous owner (if different) - // has forgotten the reference to `this`. - if (this._owner !== prevOwner || props.ref !== prevProps.ref) { - if (prevProps.ref != null) { + // has forgotten the reference to `this`. We use the descriptor instead + // of the public this.props because the post processing cannot determine + // a ref. The ref conceptually lives on the descriptor. + + // TODO: Should this even be possible? The owner cannot change because + // it's forbidden by shouldUpdateReactComponent. The ref can change + // if you swap the keys of but not the refs. Reconsider where this check + // is made. It probably belongs where the key checking and + // instantiateReactComponent is done. + + if (nextDescriptor._owner !== prevDescriptor._owner || + nextDescriptor.props.ref !== prevDescriptor.props.ref) { + if (prevDescriptor.props.ref != null) { ReactOwner.removeComponentAsRefFrom( - this, prevProps.ref, prevOwner + this, prevDescriptor.props.ref, prevDescriptor._owner ); } // Correct, even if the owner is the same, and only the ref has changed. - if (props.ref != null) { - ReactOwner.addComponentAsRefTo(this, props.ref, this._owner); + if (nextDescriptor.props.ref != null) { + ReactOwner.addComponentAsRefTo( + this, + nextDescriptor.props.ref, + nextDescriptor._owner + ); } } }, @@ -4817,7 +5529,7 @@ var ReactComponent = { * @see {ReactMount.renderComponent} */ mountComponentIntoNode: function(rootID, container, shouldReuseMarkup) { - var transaction = ReactComponent.ReactReconcileTransaction.getPooled(); + var transaction = ReactUpdates.ReactReconcileTransaction.getPooled(); transaction.perform( this._mountComponentIntoNode, this, @@ -4826,7 +5538,7 @@ var ReactComponent = { transaction, shouldReuseMarkup ); - ReactComponent.ReactReconcileTransaction.release(transaction); + ReactUpdates.ReactReconcileTransaction.release(transaction); }, /** @@ -4878,7 +5590,7 @@ var ReactComponent = { module.exports = ReactComponent; -},{"./ReactCurrentOwner":35,"./ReactOwner":64,"./ReactUpdates":81,"./invariant":125,"./keyMirror":131,"./merge":134,"./monitorCodeUse":138}],32:[function(_dereq_,module,exports){ +},{"./ReactDescriptor":56,"./ReactOwner":70,"./ReactUpdates":87,"./invariant":134,"./keyMirror":140,"./merge":144}],36:[function(_dereq_,module,exports){ /** * Copyright 2013-2014 Facebook, Inc. * @@ -4909,6 +5621,7 @@ var ReactReconcileTransaction = _dereq_("./ReactReconcileTransaction"); var getReactRootElementInContainer = _dereq_("./getReactRootElementInContainer"); var invariant = _dereq_("./invariant"); +var setInnerHTML = _dereq_("./setInnerHTML"); var ELEMENT_NODE_TYPE = 1; @@ -4979,7 +5692,7 @@ var ReactComponentBrowserEnvironment = { 'React attempted to use reuse markup in a container but the ' + 'checksum was invalid. This generally means that you are ' + 'using server rendering and the markup generated on the ' + - 'server was not what the client was expecting. React injected' + + 'server was not what the client was expecting. React injected ' + 'new markup to compensate which works but you have lost many ' + 'of the benefits of server rendering. Instead, figure out ' + 'why the markup being generated is different on the client ' + @@ -4997,14 +5710,70 @@ var ReactComponentBrowserEnvironment = { 'See renderComponentToString() for server rendering.' ) : invariant(container.nodeType !== DOC_NODE_TYPE)); - container.innerHTML = markup; + setInnerHTML(container, markup); } ) }; module.exports = ReactComponentBrowserEnvironment; -},{"./ReactDOMIDOperations":40,"./ReactMarkupChecksum":59,"./ReactMount":60,"./ReactPerf":65,"./ReactReconcileTransaction":71,"./getReactRootElementInContainer":120,"./invariant":125}],33:[function(_dereq_,module,exports){ +},{"./ReactDOMIDOperations":45,"./ReactMarkupChecksum":66,"./ReactMount":67,"./ReactPerf":71,"./ReactReconcileTransaction":77,"./getReactRootElementInContainer":128,"./invariant":134,"./setInnerHTML":152}],37:[function(_dereq_,module,exports){ +/** + * Copyright 2013-2014 Facebook, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +* @providesModule ReactComponentWithPureRenderMixin +*/ + +"use strict"; + +var shallowEqual = _dereq_("./shallowEqual"); + +/** + * If your React component's render function is "pure", e.g. it will render the + * same result given the same props and state, provide this Mixin for a + * considerable performance boost. + * + * Most React components have pure render functions. + * + * Example: + * + * var ReactComponentWithPureRenderMixin = + * require('ReactComponentWithPureRenderMixin'); + * React.createClass({ + * mixins: [ReactComponentWithPureRenderMixin], + * + * render: function() { + * return

foo
; + * } + * }); + * + * Note: This only checks shallow equality for props and state. If these contain + * complex data structures this mixin may have false-negatives for deeper + * differences. Only mixin to components which have simple props and state, or + * use `forceUpdate()` when you know deep data structures have changed. + */ +var ReactComponentWithPureRenderMixin = { + shouldComponentUpdate: function(nextProps, nextState) { + return !shallowEqual(this.props, nextProps) || + !shallowEqual(this.state, nextState); + } +}; + +module.exports = ReactComponentWithPureRenderMixin; + +},{"./shallowEqual":153}],38:[function(_dereq_,module,exports){ /** * Copyright 2013-2014 Facebook, Inc. * @@ -5028,6 +5797,9 @@ module.exports = ReactComponentBrowserEnvironment; var ReactComponent = _dereq_("./ReactComponent"); var ReactContext = _dereq_("./ReactContext"); var ReactCurrentOwner = _dereq_("./ReactCurrentOwner"); +var ReactDescriptor = _dereq_("./ReactDescriptor"); +var ReactDescriptorValidator = _dereq_("./ReactDescriptorValidator"); +var ReactEmptyComponent = _dereq_("./ReactEmptyComponent"); var ReactErrorUtils = _dereq_("./ReactErrorUtils"); var ReactOwner = _dereq_("./ReactOwner"); var ReactPerf = _dereq_("./ReactPerf"); @@ -5042,7 +5814,7 @@ var keyMirror = _dereq_("./keyMirror"); var merge = _dereq_("./merge"); var mixInto = _dereq_("./mixInto"); var monitorCodeUse = _dereq_("./monitorCodeUse"); -var objMap = _dereq_("./objMap"); +var mapObject = _dereq_("./mapObject"); var shouldUpdateReactComponent = _dereq_("./shouldUpdateReactComponent"); var warning = _dereq_("./warning"); @@ -5333,18 +6105,17 @@ var ReactCompositeComponentInterface = { * which all other static methods are defined. */ var RESERVED_SPEC_KEYS = { - displayName: function(ConvenienceConstructor, displayName) { - ConvenienceConstructor.componentConstructor.displayName = displayName; + displayName: function(Constructor, displayName) { + Constructor.displayName = displayName; }, - mixins: function(ConvenienceConstructor, mixins) { + mixins: function(Constructor, mixins) { if (mixins) { for (var i = 0; i < mixins.length; i++) { - mixSpecIntoComponent(ConvenienceConstructor, mixins[i]); + mixSpecIntoComponent(Constructor, mixins[i]); } } }, - childContextTypes: function(ConvenienceConstructor, childContextTypes) { - var Constructor = ConvenienceConstructor.componentConstructor; + childContextTypes: function(Constructor, childContextTypes) { validateTypeDef( Constructor, childContextTypes, @@ -5355,8 +6126,7 @@ var RESERVED_SPEC_KEYS = { childContextTypes ); }, - contextTypes: function(ConvenienceConstructor, contextTypes) { - var Constructor = ConvenienceConstructor.componentConstructor; + contextTypes: function(Constructor, contextTypes) { validateTypeDef( Constructor, contextTypes, @@ -5364,8 +6134,21 @@ var RESERVED_SPEC_KEYS = { ); Constructor.contextTypes = merge(Constructor.contextTypes, contextTypes); }, - propTypes: function(ConvenienceConstructor, propTypes) { - var Constructor = ConvenienceConstructor.componentConstructor; + /** + * Special case getDefaultProps which should move into statics but requires + * automatic merging. + */ + getDefaultProps: function(Constructor, getDefaultProps) { + if (Constructor.getDefaultProps) { + Constructor.getDefaultProps = createMergedResultFunction( + Constructor.getDefaultProps, + getDefaultProps + ); + } else { + Constructor.getDefaultProps = getDefaultProps; + } + }, + propTypes: function(Constructor, propTypes) { validateTypeDef( Constructor, propTypes, @@ -5373,11 +6156,20 @@ var RESERVED_SPEC_KEYS = { ); Constructor.propTypes = merge(Constructor.propTypes, propTypes); }, - statics: function(ConvenienceConstructor, statics) { - mixStaticSpecIntoComponent(ConvenienceConstructor, statics); + statics: function(Constructor, statics) { + mixStaticSpecIntoComponent(Constructor, statics); } }; +function getDeclarationErrorAddendum(component) { + var owner = component._owner || null; + if (owner && owner.constructor && owner.constructor.displayName) { + return ' Check the render method of `' + owner.constructor.displayName + + '`.'; + } + return ''; +} + function validateTypeDef(Constructor, typeDef, location) { for (var propName in typeDef) { if (typeDef.hasOwnProperty(propName)) { @@ -5394,7 +6186,9 @@ function validateTypeDef(Constructor, typeDef, location) { } function validateMethodOverride(proto, name) { - var specPolicy = ReactCompositeComponentInterface[name]; + var specPolicy = ReactCompositeComponentInterface.hasOwnProperty(name) ? + ReactCompositeComponentInterface[name] : + null; // Disallow overriding of base class methods unless explicitly allowed. if (ReactCompositeComponentMixin.hasOwnProperty(name)) { @@ -5444,19 +6238,18 @@ function validateLifeCycleOnReplaceState(instance) { * Custom version of `mixInto` which handles policy validation and reserved * specification keys when building `ReactCompositeComponent` classses. */ -function mixSpecIntoComponent(ConvenienceConstructor, spec) { +function mixSpecIntoComponent(Constructor, spec) { ("production" !== "development" ? invariant( - !isValidClass(spec), + !ReactDescriptor.isValidFactory(spec), 'ReactCompositeComponent: You\'re attempting to ' + 'use a component class as a mixin. Instead, just use a regular object.' - ) : invariant(!isValidClass(spec))); + ) : invariant(!ReactDescriptor.isValidFactory(spec))); ("production" !== "development" ? invariant( - !ReactComponent.isValidComponent(spec), + !ReactDescriptor.isValidDescriptor(spec), 'ReactCompositeComponent: You\'re attempting to ' + 'use a component as a mixin. Instead, just use a regular object.' - ) : invariant(!ReactComponent.isValidComponent(spec))); + ) : invariant(!ReactDescriptor.isValidDescriptor(spec))); - var Constructor = ConvenienceConstructor.componentConstructor; var proto = Constructor.prototype; for (var name in spec) { var property = spec[name]; @@ -5467,20 +6260,21 @@ function mixSpecIntoComponent(ConvenienceConstructor, spec) { validateMethodOverride(proto, name); if (RESERVED_SPEC_KEYS.hasOwnProperty(name)) { - RESERVED_SPEC_KEYS[name](ConvenienceConstructor, property); + RESERVED_SPEC_KEYS[name](Constructor, property); } else { // Setup methods on prototype: // The following member methods should not be automatically bound: // 1. Expected ReactCompositeComponent methods (in the "interface"). // 2. Overridden methods (that were mixed in). - var isCompositeComponentMethod = name in ReactCompositeComponentInterface; - var isInherited = name in proto; + var isCompositeComponentMethod = + ReactCompositeComponentInterface.hasOwnProperty(name); + var isAlreadyDefined = proto.hasOwnProperty(name); var markedDontBind = property && property.__reactDontBind; var isFunction = typeof property === 'function'; var shouldAutoBind = isFunction && !isCompositeComponentMethod && - !isInherited && + !isAlreadyDefined && !markedDontBind; if (shouldAutoBind) { @@ -5490,37 +6284,60 @@ function mixSpecIntoComponent(ConvenienceConstructor, spec) { proto.__reactAutoBindMap[name] = property; proto[name] = property; } else { - if (isInherited) { + if (isAlreadyDefined) { + var specPolicy = ReactCompositeComponentInterface[name]; + + // These cases should already be caught by validateMethodOverride + ("production" !== "development" ? invariant( + isCompositeComponentMethod && ( + specPolicy === SpecPolicy.DEFINE_MANY_MERGED || + specPolicy === SpecPolicy.DEFINE_MANY + ), + 'ReactCompositeComponent: Unexpected spec policy %s for key %s ' + + 'when mixing in component specs.', + specPolicy, + name + ) : invariant(isCompositeComponentMethod && ( + specPolicy === SpecPolicy.DEFINE_MANY_MERGED || + specPolicy === SpecPolicy.DEFINE_MANY + ))); + // For methods which are defined more than once, call the existing - // methods before calling the new property. - if (ReactCompositeComponentInterface[name] === - SpecPolicy.DEFINE_MANY_MERGED) { + // methods before calling the new property, merging if appropriate. + if (specPolicy === SpecPolicy.DEFINE_MANY_MERGED) { proto[name] = createMergedResultFunction(proto[name], property); - } else { + } else if (specPolicy === SpecPolicy.DEFINE_MANY) { proto[name] = createChainedFunction(proto[name], property); } } else { proto[name] = property; + if ("production" !== "development") { + // Add verbose displayName to the function, which helps when looking + // at profiling tools. + if (typeof property === 'function' && spec.displayName) { + proto[name].displayName = spec.displayName + '_' + name; + } + } } } } } } -function mixStaticSpecIntoComponent(ConvenienceConstructor, statics) { +function mixStaticSpecIntoComponent(Constructor, statics) { if (!statics) { return; } for (var name in statics) { var property = statics[name]; if (!statics.hasOwnProperty(name)) { - return; + continue; } - var isInherited = name in ConvenienceConstructor; + var isInherited = name in Constructor; var result = property; if (isInherited) { - var existingProperty = ConvenienceConstructor[name]; + var existingProperty = Constructor[name]; var existingType = typeof existingProperty; var propertyType = typeof property; ("production" !== "development" ? invariant( @@ -5533,8 +6350,7 @@ function mixStaticSpecIntoComponent(ConvenienceConstructor, statics) { ) : invariant(existingType === 'function' && propertyType === 'function')); result = createChainedFunction(existingProperty, property); } - ConvenienceConstructor[name] = result; - ConvenienceConstructor.componentConstructor[name] = result; + Constructor[name] = result; } } @@ -5551,7 +6367,7 @@ function mergeObjectsWithNoDuplicateKeys(one, two) { 'mergeObjectsWithNoDuplicateKeys(): Cannot merge non-objects' ) : invariant(one && two && typeof one === 'object' && typeof two === 'object')); - objMap(two, function(value, key) { + mapObject(two, function(value, key) { ("production" !== "development" ? invariant( one[key] === undefined, 'mergeObjectsWithNoDuplicateKeys(): ' + @@ -5599,203 +6415,6 @@ function createChainedFunction(one, two) { }; } -if ("production" !== "development") { - - var unmountedPropertyWhitelist = { - constructor: true, - construct: true, - isOwnedBy: true, // should be deprecated but can have code mod (internal) - type: true, - props: true, - // currently private but belong on the descriptor and are valid for use - // inside the framework: - __keyValidated__: true, - _owner: true, - _currentContext: true - }; - - var componentInstanceProperties = { - __keyValidated__: true, - __keySetters: true, - _compositeLifeCycleState: true, - _currentContext: true, - _defaultProps: true, - _instance: true, - _lifeCycleState: true, - _mountDepth: true, - _owner: true, - _pendingCallbacks: true, - _pendingContext: true, - _pendingForceUpdate: true, - _pendingOwner: true, - _pendingProps: true, - _pendingState: true, - _renderedComponent: true, - _rootNodeID: true, - context: true, - props: true, - refs: true, - state: true, - - // These are known instance properties coming from other sources - _pendingQueries: true, - _queryPropListeners: true, - queryParams: true - - }; - - var hasWarnedOnComponentType = {}; - - var warningStackCounter = 0; - - var issueMembraneWarning = function(instance, key) { - var isWhitelisted = unmountedPropertyWhitelist.hasOwnProperty(key); - if (warningStackCounter > 0 || isWhitelisted) { - return; - } - var name = instance.constructor.displayName || 'Unknown'; - var owner = ReactCurrentOwner.current; - var ownerName = (owner && owner.constructor.displayName) || 'Unknown'; - var warningKey = key + '|' + name + '|' + ownerName; - if (hasWarnedOnComponentType.hasOwnProperty(warningKey)) { - // We have already warned for this combination. Skip it this time. - return; - } - hasWarnedOnComponentType[warningKey] = true; - - var context = owner ? ' in ' + ownerName + '.' : ' at the top level.'; - var staticMethodExample = '<' + name + ' />.type.' + key + '(...)'; - - monitorCodeUse('react_descriptor_property_access', { component: name }); - console.warn( - 'Invalid access to component property "' + key + '" on ' + name + - context + ' See http://fb.me/react-warning-descriptors .' + - ' Use a static method instead: ' + staticMethodExample - ); - }; - - var wrapInMembraneFunction = function(fn, thisBinding) { - if (fn.__reactMembraneFunction && fn.__reactMembraneSelf === thisBinding) { - return fn.__reactMembraneFunction; - } - return fn.__reactMembraneFunction = function() { - /** - * By getting this function, you've already received a warning. The - * internals of this function will likely cause more warnings. To avoid - * Spamming too much we disable any warning triggered inside of this - * stack. - */ - warningStackCounter++; - try { - // If the this binding is unchanged, we defer to the real component. - // This is important to keep some referential integrity in the - // internals. E.g. owner equality check. - var self = this === thisBinding ? this.__realComponentInstance : this; - return fn.apply(self, arguments); - } finally { - warningStackCounter--; - } - }; - }; - - var defineMembraneProperty = function(membrane, prototype, key) { - Object.defineProperty(membrane, key, { - - configurable: false, - enumerable: true, - - get: function() { - if (this === membrane) { - // We're allowed to access the prototype directly. - return prototype[key]; - } - issueMembraneWarning(this, key); - - var realValue = this.__realComponentInstance[key]; - // If the real value is a function, we need to provide a wrapper that - // disables nested warnings. The properties type and constructors are - // expected to the be constructors and therefore is often use with an - // equality check and we shouldn't try to rebind those. - if (typeof realValue === 'function' && - key !== 'type' && - key !== 'constructor') { - return wrapInMembraneFunction(realValue, this); - } - return realValue; - }, - - set: function(value) { - if (this === membrane) { - // We're allowed to set a value on the prototype directly. - prototype[key] = value; - return; - } - issueMembraneWarning(this, key); - this.__realComponentInstance[key] = value; - } - - }); - }; - - /** - * Creates a membrane prototype which wraps the original prototype. If any - * property is accessed in an unmounted state, a warning is issued. - * - * @param {object} prototype Original prototype. - * @return {object} The membrane prototype. - * @private - */ - var createMountWarningMembrane = function(prototype) { - var membrane = {}; - var key; - for (key in prototype) { - defineMembraneProperty(membrane, prototype, key); - } - // These are properties that goes into the instance but not the prototype. - // We can create the membrane on the prototype even though this will - // result in a faulty hasOwnProperty check it's better perf. - for (key in componentInstanceProperties) { - if (componentInstanceProperties.hasOwnProperty(key) && - !(key in prototype)) { - defineMembraneProperty(membrane, prototype, key); - } - } - return membrane; - }; - - /** - * Creates a membrane constructor which wraps the component that gets mounted. - * - * @param {function} constructor Original constructor. - * @return {function} The membrane constructor. - * @private - */ - var createDescriptorProxy = function(constructor) { - try { - var ProxyConstructor = function() { - this.__realComponentInstance = new constructor(); - - // We can only safely pass through known instance variables. Unknown - // expandos are not safe. Use the real mounted instance to avoid this - // problem if it blows something up. - Object.freeze(this); - }; - - ProxyConstructor.prototype = createMountWarningMembrane( - constructor.prototype - ); - - return ProxyConstructor; - } catch(x) { - // In IE8 define property will fail on non-DOM objects. If anything in - // the membrane creation fails, we'll bail out and just use the plain - // constructor without warnings. - return constructor; - } - }; - -} - /** * `ReactCompositeComponent` maintains an auxiliary life cycle state in * `this._compositeLifeCycleState` (which can be null). @@ -5853,12 +6472,11 @@ var ReactCompositeComponentMixin = { /** * Base constructor for all composite component. * - * @param {?object} initialProps - * @param {*} children + * @param {ReactDescriptor} descriptor * @final * @internal */ - construct: function(initialProps, children) { + construct: function(descriptor) { // Children can be either an array or more than one argument ReactComponent.Mixin.construct.apply(this, arguments); ReactOwner.Mixin.construct.apply(this, arguments); @@ -5866,29 +6484,13 @@ var ReactCompositeComponentMixin = { this.state = null; this._pendingState = null; + // This is the public post-processed context. The real context and pending + // context lives on the descriptor. this.context = null; - this._currentContext = ReactContext.current; - this._pendingContext = null; - - // The descriptor that was used to instantiate this component. Will be - // set by the instantiator instead of the constructor since this - // constructor is currently used by both instances and descriptors. - this._descriptor = null; this._compositeLifeCycleState = null; }, - /** - * Components in the intermediate state now has cyclic references. To avoid - * breaking JSON serialization we expose a custom JSON format. - * @return {object} JSON compatible representation. - * @internal - * @final - */ - toJSON: function() { - return { type: this.type, props: this.props }; - }, - /** * Checks whether or not this composite component is mounted. * @return {boolean} True if mounted, false otherwise. @@ -5922,14 +6524,13 @@ var ReactCompositeComponentMixin = { ); this._compositeLifeCycleState = CompositeLifeCycle.MOUNTING; - this.context = this._processContext(this._currentContext); - this._defaultProps = this.getDefaultProps ? this.getDefaultProps() : null; - this.props = this._processProps(this.props); - if (this.__reactAutoBindMap) { this._bindAutoBindMethods(); } + this.context = this._processContext(this._descriptor._context); + this.props = this._processProps(this.props); + this.state = this.getInitialState ? this.getInitialState() : null; ("production" !== "development" ? invariant( typeof this.state === 'object' && !Array.isArray(this.state), @@ -5962,7 +6563,7 @@ var ReactCompositeComponentMixin = { mountDepth + 1 ); if (this.componentDidMount) { - transaction.getReactMountReady().enqueue(this, this.componentDidMount); + transaction.getReactMountReady().enqueue(this.componentDidMount, this); } return markup; } @@ -5981,8 +6582,6 @@ var ReactCompositeComponentMixin = { } this._compositeLifeCycleState = null; - this._defaultProps = null; - this._renderedComponent.unmountComponent(); this._renderedComponent = null; @@ -6016,7 +6615,7 @@ var ReactCompositeComponentMixin = { typeof partialState === 'object' || partialState == null, 'setState(...): takes an object of state variables to update.' ) : invariant(typeof partialState === 'object' || partialState == null)); - if ("production" !== "development") { + if ("production" !== "development"){ ("production" !== "development" ? warning( partialState != null, 'setState(...): You passed an undefined or null state object; ' + @@ -6045,7 +6644,15 @@ var ReactCompositeComponentMixin = { replaceState: function(completeState, callback) { validateLifeCycleOnReplaceState(this); this._pendingState = completeState; - ReactUpdates.enqueueUpdate(this, callback); + if (this._compositeLifeCycleState !== CompositeLifeCycle.MOUNTING) { + // If we're in a componentWillMount handler, don't enqueue a rerender + // because ReactUpdates assumes we're in a browser context (which is wrong + // for server rendering) and we're about to do a render anyway. + // TODO: The callback here is ignored when setState is called from + // componentWillMount. Either fix it or disallow doing so completely in + // favor of getInitialState. + ReactUpdates.enqueueUpdate(this, callback); + } }, /** @@ -6120,12 +6727,17 @@ var ReactCompositeComponentMixin = { * @private */ _processProps: function(newProps) { - var props = merge(newProps); - var defaultProps = this._defaultProps; - for (var propName in defaultProps) { - if (typeof props[propName] === 'undefined') { - props[propName] = defaultProps[propName]; + var defaultProps = this.constructor.defaultProps; + var props; + if (defaultProps) { + props = merge(newProps); + for (var propName in defaultProps) { + if (typeof props[propName] === 'undefined') { + props[propName] = defaultProps[propName]; + } } + } else { + props = newProps; } if ("production" !== "development") { var propTypes = this.constructor.propTypes; @@ -6145,15 +6757,32 @@ var ReactCompositeComponentMixin = { * @private */ _checkPropTypes: function(propTypes, props, location) { + // TODO: Stop validating prop types here and only use the descriptor + // validation. var componentName = this.constructor.displayName; for (var propName in propTypes) { if (propTypes.hasOwnProperty(propName)) { - propTypes[propName](props, propName, componentName, location); + var error = + propTypes[propName](props, propName, componentName, location); + if (error instanceof Error) { + // We may want to extend this logic for similar errors in + // renderComponent calls, so I'm abstracting it away into + // a function to minimize refactoring in the future + var addendum = getDeclarationErrorAddendum(this); + ("production" !== "development" ? warning(false, error.message + addendum) : null); + } } } }, - performUpdateIfNecessary: function() { + /** + * If any of `_pendingDescriptor`, `_pendingState`, or `_pendingForceUpdate` + * is set, update the component. + * + * @param {ReactReconcileTransaction} transaction + * @internal + */ + performUpdateIfNecessary: function(transaction) { var compositeLifeCycleState = this._compositeLifeCycleState; // Do not trigger a state transition if we are in the middle of mounting or // receiving props because both of those will already be doing this. @@ -6161,32 +6790,21 @@ var ReactCompositeComponentMixin = { compositeLifeCycleState === CompositeLifeCycle.RECEIVING_PROPS) { return; } - ReactComponent.Mixin.performUpdateIfNecessary.call(this); - }, - /** - * If any of `_pendingProps`, `_pendingState`, or `_pendingForceUpdate` is - * set, update the component. - * - * @param {ReactReconcileTransaction} transaction - * @internal - */ - _performUpdateIfNecessary: function(transaction) { - if (this._pendingProps == null && + if (this._pendingDescriptor == null && this._pendingState == null && - this._pendingContext == null && !this._pendingForceUpdate) { return; } - var nextFullContext = this._pendingContext || this._currentContext; - var nextContext = this._processContext(nextFullContext); - this._pendingContext = null; - + var nextContext = this.context; var nextProps = this.props; - if (this._pendingProps != null) { - nextProps = this._processProps(this._pendingProps); - this._pendingProps = null; + var nextDescriptor = this._descriptor; + if (this._pendingDescriptor != null) { + nextDescriptor = this._pendingDescriptor; + nextContext = this._processContext(nextDescriptor._context); + nextProps = this._processProps(nextDescriptor.props); + this._pendingDescriptor = null; this._compositeLifeCycleState = CompositeLifeCycle.RECEIVING_PROPS; if (this.componentWillReceiveProps) { @@ -6196,37 +6814,46 @@ var ReactCompositeComponentMixin = { this._compositeLifeCycleState = CompositeLifeCycle.RECEIVING_STATE; - // Unlike props, state, and context, we specifically don't want to set - // _pendingOwner to null here because it's possible for a component to have - // a null owner, so we instead make `this._owner === this._pendingOwner` - // mean that there's no owner change pending. - var nextOwner = this._pendingOwner; - var nextState = this._pendingState || this.state; this._pendingState = null; try { - if (this._pendingForceUpdate || - !this.shouldComponentUpdate || - this.shouldComponentUpdate(nextProps, nextState, nextContext)) { + var shouldUpdate = + this._pendingForceUpdate || + !this.shouldComponentUpdate || + this.shouldComponentUpdate(nextProps, nextState, nextContext); + + if ("production" !== "development") { + if (typeof shouldUpdate === "undefined") { + console.warn( + (this.constructor.displayName || 'ReactCompositeComponent') + + '.shouldComponentUpdate(): Returned undefined instead of a ' + + 'boolean value. Make sure to return true or false.' + ); + } + } + + if (shouldUpdate) { this._pendingForceUpdate = false; // Will set `this.props`, `this.state` and `this.context`. this._performComponentUpdate( + nextDescriptor, nextProps, - nextOwner, nextState, - nextFullContext, nextContext, transaction ); } else { // If it's determined that a component should not update, we still want // to set props and state. + this._descriptor = nextDescriptor; this.props = nextProps; - this._owner = nextOwner; this.state = nextState; - this._currentContext = nextFullContext; this.context = nextContext; + + // Owner cannot change because shouldUpdateReactComponent doesn't allow + // it. TODO: Remove this._owner completely. + this._owner = nextDescriptor._owner; } } finally { this._compositeLifeCycleState = null; @@ -6237,24 +6864,22 @@ var ReactCompositeComponentMixin = { * Merges new props and state, notifies delegate methods of update and * performs update. * - * @param {object} nextProps Next object to set as properties. - * @param {?ReactComponent} nextOwner Next component to set as owner + * @param {ReactDescriptor} nextDescriptor Next descriptor + * @param {object} nextProps Next public object to set as properties. * @param {?object} nextState Next object to set as state. - * @param {?object} nextFullContext Next object to set as _currentContext. - * @param {?object} nextContext Next object to set as context. + * @param {?object} nextContext Next public object to set as context. * @param {ReactReconcileTransaction} transaction * @private */ _performComponentUpdate: function( + nextDescriptor, nextProps, - nextOwner, nextState, - nextFullContext, nextContext, transaction ) { + var prevDescriptor = this._descriptor; var prevProps = this.props; - var prevOwner = this._owner; var prevState = this.state; var prevContext = this.context; @@ -6262,43 +6887,44 @@ var ReactCompositeComponentMixin = { this.componentWillUpdate(nextProps, nextState, nextContext); } + this._descriptor = nextDescriptor; this.props = nextProps; - this._owner = nextOwner; this.state = nextState; - this._currentContext = nextFullContext; this.context = nextContext; + // Owner cannot change because shouldUpdateReactComponent doesn't allow + // it. TODO: Remove this._owner completely. + this._owner = nextDescriptor._owner; + this.updateComponent( transaction, - prevProps, - prevOwner, - prevState, - prevContext + prevDescriptor ); if (this.componentDidUpdate) { transaction.getReactMountReady().enqueue( - this, - this.componentDidUpdate.bind(this, prevProps, prevState, prevContext) + this.componentDidUpdate.bind(this, prevProps, prevState, prevContext), + this ); } }, - receiveComponent: function(nextComponent, transaction) { - if (nextComponent === this._descriptor) { - // Since props and context are immutable after the component is - // mounted, we can do a cheap identity compare here to determine - // if this is a superfluous reconcile. + receiveComponent: function(nextDescriptor, transaction) { + if (nextDescriptor === this._descriptor && + nextDescriptor._owner != null) { + // Since descriptors are immutable after the owner is rendered, + // we can do a cheap identity compare here to determine if this is a + // superfluous reconcile. It's possible for state to be mutable but such + // change should trigger an update of the owner which would recreate + // the descriptor. We explicitly check for the existence of an owner since + // it's possible for a descriptor created outside a composite to be + // deeply mutated and reused. return; } - // Update the descriptor that was last used by this component instance - this._descriptor = nextComponent; - - this._pendingContext = nextComponent._currentContext; ReactComponent.Mixin.receiveComponent.call( this, - nextComponent, + nextDescriptor, transaction ); }, @@ -6310,35 +6936,31 @@ var ReactCompositeComponentMixin = { * Sophisticated clients may wish to override this. * * @param {ReactReconcileTransaction} transaction - * @param {object} prevProps - * @param {?ReactComponent} prevOwner - * @param {?object} prevState - * @param {?object} prevContext + * @param {ReactDescriptor} prevDescriptor * @internal * @overridable */ updateComponent: ReactPerf.measure( 'ReactCompositeComponent', 'updateComponent', - function(transaction, prevProps, prevOwner, prevState, prevContext) { + function(transaction, prevParentDescriptor) { ReactComponent.Mixin.updateComponent.call( this, transaction, - prevProps, - prevOwner + prevParentDescriptor ); - var prevComponentInstance = this._renderedComponent; - var nextComponent = this._renderValidatedComponent(); - if (shouldUpdateReactComponent(prevComponentInstance, nextComponent)) { - prevComponentInstance.receiveComponent(nextComponent, transaction); + var prevDescriptor = prevComponentInstance._descriptor; + var nextDescriptor = this._renderValidatedComponent(); + if (shouldUpdateReactComponent(prevDescriptor, nextDescriptor)) { + prevComponentInstance.receiveComponent(nextDescriptor, transaction); } else { // These two IDs are actually the same! But nothing should rely on that. var thisID = this._rootNodeID; var prevComponentID = prevComponentInstance._rootNodeID; prevComponentInstance.unmountComponent(); - this._renderedComponent = instantiateReactComponent(nextComponent); + this._renderedComponent = instantiateReactComponent(nextDescriptor); var nextMarkup = this._renderedComponent.mountComponent( thisID, transaction, @@ -6395,20 +7017,28 @@ var ReactCompositeComponentMixin = { function() { var renderedComponent; var previousContext = ReactContext.current; - ReactContext.current = this._processChildContext(this._currentContext); + ReactContext.current = this._processChildContext( + this._descriptor._context + ); ReactCurrentOwner.current = this; try { renderedComponent = this.render(); + if (renderedComponent === null || renderedComponent === false) { + renderedComponent = ReactEmptyComponent.getEmptyComponent(); + ReactEmptyComponent.registerNullComponentID(this._rootNodeID); + } else { + ReactEmptyComponent.deregisterNullComponentID(this._rootNodeID); + } } finally { ReactContext.current = previousContext; ReactCurrentOwner.current = null; } ("production" !== "development" ? invariant( - ReactComponent.isValidComponent(renderedComponent), + ReactDescriptor.isValidDescriptor(renderedComponent), '%s.render(): A valid ReactComponent must be returned. You may have ' + - 'returned null, undefined, an array, or some other invalid object.', + 'returned undefined, an array or some other invalid object.', this.constructor.displayName || 'ReactCompositeComponent' - ) : invariant(ReactComponent.isValidComponent(renderedComponent))); + ) : invariant(ReactDescriptor.isValidDescriptor(renderedComponent))); return renderedComponent; } ), @@ -6482,18 +7112,6 @@ mixInto(ReactCompositeComponentBase, ReactOwner.Mixin); mixInto(ReactCompositeComponentBase, ReactPropTransferer.Mixin); mixInto(ReactCompositeComponentBase, ReactCompositeComponentMixin); -/** - * Checks if a value is a valid component constructor. - * - * @param {*} - * @return {boolean} - * @public - */ -function isValidClass(componentClass) { - return componentClass instanceof Function && - 'componentConstructor' in componentClass && - componentClass.componentConstructor instanceof Function; -} /** * Module for creating composite components. * @@ -6516,26 +7134,22 @@ var ReactCompositeComponent = { * @public */ createClass: function(spec) { - var Constructor = function() {}; + var Constructor = function(props, owner) { + this.construct(props, owner); + }; Constructor.prototype = new ReactCompositeComponentBase(); Constructor.prototype.constructor = Constructor; - var DescriptorConstructor = Constructor; - - var ConvenienceConstructor = function(props, children) { - var descriptor = new DescriptorConstructor(); - descriptor.construct.apply(descriptor, arguments); - return descriptor; - }; - ConvenienceConstructor.componentConstructor = Constructor; - Constructor.ConvenienceConstructor = ConvenienceConstructor; - ConvenienceConstructor.originalSpec = spec; - injectedMixins.forEach( - mixSpecIntoComponent.bind(null, ConvenienceConstructor) + mixSpecIntoComponent.bind(null, Constructor) ); - mixSpecIntoComponent(ConvenienceConstructor, spec); + mixSpecIntoComponent(Constructor, spec); + + // Initialize the defaultProps property after all mixins have been merged + if (Constructor.getDefaultProps) { + Constructor.defaultProps = Constructor.getDefaultProps(); + } ("production" !== "development" ? invariant( Constructor.prototype.render, @@ -6557,14 +7171,6 @@ var ReactCompositeComponent = { } } - // Expose the convience constructor on the prototype so that it can be - // easily accessed on descriptors. E.g. .type === Foo.type and for - // static methods like .type.staticMethod(); - // This should not be named constructor since this may not be the function - // that created the descriptor, and it may not even be a constructor. - ConvenienceConstructor.type = Constructor; - Constructor.prototype.type = Constructor; - // Reduce time spent doing lookups by setting these on the prototype. for (var methodName in ReactCompositeComponentInterface) { if (!Constructor.prototype[methodName]) { @@ -6572,18 +7178,19 @@ var ReactCompositeComponent = { } } + var descriptorFactory = ReactDescriptor.createFactory(Constructor); + if ("production" !== "development") { - // In DEV the convenience constructor generates a proxy to another - // instance around it to warn about access to properties on the - // descriptor. - DescriptorConstructor = createDescriptorProxy(Constructor); + return ReactDescriptorValidator.createFactory( + descriptorFactory, + Constructor.propTypes, + Constructor.contextTypes + ); } - return ConvenienceConstructor; + return descriptorFactory; }, - isValidClass: isValidClass, - injection: { injectMixin: function(mixin) { injectedMixins.push(mixin); @@ -6593,7 +7200,7 @@ var ReactCompositeComponent = { module.exports = ReactCompositeComponent; -},{"./ReactComponent":31,"./ReactContext":34,"./ReactCurrentOwner":35,"./ReactErrorUtils":51,"./ReactOwner":64,"./ReactPerf":65,"./ReactPropTransferer":66,"./ReactPropTypeLocationNames":67,"./ReactPropTypeLocations":68,"./ReactUpdates":81,"./instantiateReactComponent":124,"./invariant":125,"./keyMirror":131,"./merge":134,"./mixInto":137,"./monitorCodeUse":138,"./objMap":139,"./shouldUpdateReactComponent":144,"./warning":148}],34:[function(_dereq_,module,exports){ +},{"./ReactComponent":35,"./ReactContext":39,"./ReactCurrentOwner":40,"./ReactDescriptor":56,"./ReactDescriptorValidator":57,"./ReactEmptyComponent":58,"./ReactErrorUtils":59,"./ReactOwner":70,"./ReactPerf":71,"./ReactPropTransferer":72,"./ReactPropTypeLocationNames":73,"./ReactPropTypeLocations":74,"./ReactUpdates":87,"./instantiateReactComponent":133,"./invariant":134,"./keyMirror":140,"./mapObject":142,"./merge":144,"./mixInto":147,"./monitorCodeUse":148,"./shouldUpdateReactComponent":154,"./warning":158}],39:[function(_dereq_,module,exports){ /** * Copyright 2013-2014 Facebook, Inc. * @@ -6662,7 +7269,7 @@ var ReactContext = { module.exports = ReactContext; -},{"./merge":134}],35:[function(_dereq_,module,exports){ +},{"./merge":144}],40:[function(_dereq_,module,exports){ /** * Copyright 2013-2014 Facebook, Inc. * @@ -6703,7 +7310,7 @@ var ReactCurrentOwner = { module.exports = ReactCurrentOwner; -},{}],36:[function(_dereq_,module,exports){ +},{}],41:[function(_dereq_,module,exports){ /** * Copyright 2013-2014 Facebook, Inc. * @@ -6725,10 +7332,12 @@ module.exports = ReactCurrentOwner; "use strict"; +var ReactDescriptor = _dereq_("./ReactDescriptor"); +var ReactDescriptorValidator = _dereq_("./ReactDescriptorValidator"); var ReactDOMComponent = _dereq_("./ReactDOMComponent"); var mergeInto = _dereq_("./mergeInto"); -var objMapKeyVal = _dereq_("./objMapKeyVal"); +var mapObject = _dereq_("./mapObject"); /** * Creates a new React class that is idempotent and capable of containing other @@ -6741,30 +7350,26 @@ var objMapKeyVal = _dereq_("./objMapKeyVal"); * The `style` property functions differently from the DOM API. It accepts an * object mapping of style properties to values. * - * @param {string} tag Tag name (e.g. `div`). * @param {boolean} omitClose True if the close tag should be omitted. + * @param {string} tag Tag name (e.g. `div`). * @private */ -function createDOMComponentClass(tag, omitClose) { - var Constructor = function() {}; +function createDOMComponentClass(omitClose, tag) { + var Constructor = function(descriptor) { + this.construct(descriptor); + }; Constructor.prototype = new ReactDOMComponent(tag, omitClose); Constructor.prototype.constructor = Constructor; Constructor.displayName = tag; - var ConvenienceConstructor = function(props, children) { - var instance = new Constructor(); - instance.construct.apply(instance, arguments); - return instance; - }; + var ConvenienceConstructor = ReactDescriptor.createFactory(Constructor); - // Expose the constructor on the ConvenienceConstructor and prototype so that - // it can be easily easily accessed on descriptors. - // E.g.
.type === div.type - ConvenienceConstructor.type = Constructor; - Constructor.prototype.type = Constructor; + if ("production" !== "development") { + return ReactDescriptorValidator.createFactory( + ConvenienceConstructor + ); + } - Constructor.ConvenienceConstructor = ConvenienceConstructor; - ConvenienceConstructor.componentConstructor = Constructor; return ConvenienceConstructor; } @@ -6774,7 +7379,7 @@ function createDOMComponentClass(tag, omitClose) { * * @public */ -var ReactDOM = objMapKeyVal({ +var ReactDOM = mapObject({ a: false, abbr: false, address: false, @@ -6889,17 +7494,21 @@ var ReactDOM = objMapKeyVal({ // SVG circle: false, defs: false, + ellipse: false, g: false, line: false, linearGradient: false, + mask: false, path: false, + pattern: false, polygon: false, polyline: false, radialGradient: false, rect: false, stop: false, svg: false, - text: false + text: false, + tspan: false }, createDOMComponentClass); var injection = { @@ -6912,7 +7521,7 @@ ReactDOM.injection = injection; module.exports = ReactDOM; -},{"./ReactDOMComponent":38,"./mergeInto":136,"./objMapKeyVal":140}],37:[function(_dereq_,module,exports){ +},{"./ReactDOMComponent":43,"./ReactDescriptor":56,"./ReactDescriptorValidator":57,"./mapObject":142,"./mergeInto":146}],42:[function(_dereq_,module,exports){ /** * Copyright 2013-2014 Facebook, Inc. * @@ -6983,7 +7592,7 @@ var ReactDOMButton = ReactCompositeComponent.createClass({ module.exports = ReactDOMButton; -},{"./AutoFocusMixin":1,"./ReactBrowserComponentMixin":27,"./ReactCompositeComponent":33,"./ReactDOM":36,"./keyMirror":131}],38:[function(_dereq_,module,exports){ +},{"./AutoFocusMixin":1,"./ReactBrowserComponentMixin":30,"./ReactCompositeComponent":38,"./ReactDOM":41,"./keyMirror":140}],43:[function(_dereq_,module,exports){ /** * Copyright 2013-2014 Facebook, Inc. * @@ -7010,7 +7619,7 @@ var DOMProperty = _dereq_("./DOMProperty"); var DOMPropertyOperations = _dereq_("./DOMPropertyOperations"); var ReactBrowserComponentMixin = _dereq_("./ReactBrowserComponentMixin"); var ReactComponent = _dereq_("./ReactComponent"); -var ReactEventEmitter = _dereq_("./ReactEventEmitter"); +var ReactBrowserEventEmitter = _dereq_("./ReactBrowserEventEmitter"); var ReactMount = _dereq_("./ReactMount"); var ReactMultiChild = _dereq_("./ReactMultiChild"); var ReactPerf = _dereq_("./ReactPerf"); @@ -7021,9 +7630,9 @@ var keyOf = _dereq_("./keyOf"); var merge = _dereq_("./merge"); var mixInto = _dereq_("./mixInto"); -var deleteListener = ReactEventEmitter.deleteListener; -var listenTo = ReactEventEmitter.listenTo; -var registrationNameModules = ReactEventEmitter.registrationNameModules; +var deleteListener = ReactBrowserEventEmitter.deleteListener; +var listenTo = ReactBrowserEventEmitter.listenTo; +var registrationNameModules = ReactBrowserEventEmitter.registrationNameModules; // For quickly matching children type, to test if can be treated as content. var CONTENT_TYPES = {'string': true, 'number': true}; @@ -7133,7 +7742,7 @@ ReactDOMComponent.Mixin = { if (propValue == null) { continue; } - if (registrationNameModules[propKey]) { + if (registrationNameModules.hasOwnProperty(propKey)) { putListener(this._rootNodeID, propKey, propValue, transaction); } else { if (propKey === STYLE) { @@ -7191,20 +7800,22 @@ ReactDOMComponent.Mixin = { return ''; }, - receiveComponent: function(nextComponent, transaction) { - if (nextComponent === this) { - // Since props and context are immutable after the component is - // mounted, we can do a cheap identity compare here to determine - // if this is a superfluous reconcile. - - // TODO: compare the descriptor + receiveComponent: function(nextDescriptor, transaction) { + if (nextDescriptor === this._descriptor && + nextDescriptor._owner != null) { + // Since descriptors are immutable after the owner is rendered, + // we can do a cheap identity compare here to determine if this is a + // superfluous reconcile. It's possible for state to be mutable but such + // change should trigger an update of the owner which would recreate + // the descriptor. We explicitly check for the existence of an owner since + // it's possible for a descriptor created outside a composite to be + // deeply mutated and reused. return; } - assertValidProps(nextComponent.props); ReactComponent.Mixin.receiveComponent.call( this, - nextComponent, + nextDescriptor, transaction ); }, @@ -7214,22 +7825,22 @@ ReactDOMComponent.Mixin = { * attached to the DOM. Reconciles the root DOM node, then recurses. * * @param {ReactReconcileTransaction} transaction - * @param {object} prevProps + * @param {ReactDescriptor} prevDescriptor * @internal * @overridable */ updateComponent: ReactPerf.measure( 'ReactDOMComponent', 'updateComponent', - function(transaction, prevProps, prevOwner) { + function(transaction, prevDescriptor) { + assertValidProps(this._descriptor.props); ReactComponent.Mixin.updateComponent.call( this, transaction, - prevProps, - prevOwner + prevDescriptor ); - this._updateDOMProperties(prevProps, transaction); - this._updateDOMChildren(prevProps, transaction); + this._updateDOMProperties(prevDescriptor.props, transaction); + this._updateDOMChildren(prevDescriptor.props, transaction); } ), @@ -7266,7 +7877,7 @@ ReactDOMComponent.Mixin = { styleUpdates[styleName] = ''; } } - } else if (registrationNameModules[propKey]) { + } else if (registrationNameModules.hasOwnProperty(propKey)) { deleteListener(this._rootNodeID, propKey); } else if ( DOMProperty.isStandardName[propKey] || @@ -7291,7 +7902,7 @@ ReactDOMComponent.Mixin = { // Unset styles on `lastProp` but not on `nextProp`. for (styleName in lastProp) { if (lastProp.hasOwnProperty(styleName) && - !nextProp.hasOwnProperty(styleName)) { + (!nextProp || !nextProp.hasOwnProperty(styleName))) { styleUpdates = styleUpdates || {}; styleUpdates[styleName] = ''; } @@ -7308,7 +7919,7 @@ ReactDOMComponent.Mixin = { // Relies on `updateStylesByID` not mutating `styleUpdates`. styleUpdates = nextProp; } - } else if (registrationNameModules[propKey]) { + } else if (registrationNameModules.hasOwnProperty(propKey)) { putListener(this._rootNodeID, propKey, nextProp, transaction); } else if ( DOMProperty.isStandardName[propKey] || @@ -7388,7 +7999,7 @@ ReactDOMComponent.Mixin = { */ unmountComponent: function() { this.unmountChildren(); - ReactEventEmitter.deleteAllListeners(this._rootNodeID); + ReactBrowserEventEmitter.deleteAllListeners(this._rootNodeID); ReactComponent.Mixin.unmountComponent.call(this); } @@ -7401,7 +8012,7 @@ mixInto(ReactDOMComponent, ReactBrowserComponentMixin); module.exports = ReactDOMComponent; -},{"./CSSPropertyOperations":4,"./DOMProperty":9,"./DOMPropertyOperations":10,"./ReactBrowserComponentMixin":27,"./ReactComponent":31,"./ReactEventEmitter":52,"./ReactMount":60,"./ReactMultiChild":62,"./ReactPerf":65,"./escapeTextForBrowser":111,"./invariant":125,"./keyOf":132,"./merge":134,"./mixInto":137}],39:[function(_dereq_,module,exports){ +},{"./CSSPropertyOperations":5,"./DOMProperty":11,"./DOMPropertyOperations":12,"./ReactBrowserComponentMixin":30,"./ReactBrowserEventEmitter":31,"./ReactComponent":35,"./ReactMount":67,"./ReactMultiChild":68,"./ReactPerf":71,"./escapeTextForBrowser":118,"./invariant":134,"./keyOf":141,"./merge":144,"./mixInto":147}],44:[function(_dereq_,module,exports){ /** * Copyright 2013-2014 Facebook, Inc. * @@ -7422,11 +8033,11 @@ module.exports = ReactDOMComponent; "use strict"; +var EventConstants = _dereq_("./EventConstants"); +var LocalEventTrapMixin = _dereq_("./LocalEventTrapMixin"); var ReactBrowserComponentMixin = _dereq_("./ReactBrowserComponentMixin"); var ReactCompositeComponent = _dereq_("./ReactCompositeComponent"); var ReactDOM = _dereq_("./ReactDOM"); -var ReactEventEmitter = _dereq_("./ReactEventEmitter"); -var EventConstants = _dereq_("./EventConstants"); // Store a reference to the
`ReactDOMComponent`. var form = ReactDOM.form; @@ -7440,7 +8051,7 @@ var form = ReactDOM.form; var ReactDOMForm = ReactCompositeComponent.createClass({ displayName: 'ReactDOMForm', - mixins: [ReactBrowserComponentMixin], + mixins: [ReactBrowserComponentMixin, LocalEventTrapMixin], render: function() { // TODO: Instead of using `ReactDOM` directly, we should use JSX. However, @@ -7450,22 +8061,14 @@ var ReactDOMForm = ReactCompositeComponent.createClass({ }, componentDidMount: function() { - ReactEventEmitter.trapBubbledEvent( - EventConstants.topLevelTypes.topReset, - 'reset', - this.getDOMNode() - ); - ReactEventEmitter.trapBubbledEvent( - EventConstants.topLevelTypes.topSubmit, - 'submit', - this.getDOMNode() - ); + this.trapBubbledEvent(EventConstants.topLevelTypes.topReset, 'reset'); + this.trapBubbledEvent(EventConstants.topLevelTypes.topSubmit, 'submit'); } }); module.exports = ReactDOMForm; -},{"./EventConstants":15,"./ReactBrowserComponentMixin":27,"./ReactCompositeComponent":33,"./ReactDOM":36,"./ReactEventEmitter":52}],40:[function(_dereq_,module,exports){ +},{"./EventConstants":16,"./LocalEventTrapMixin":26,"./ReactBrowserComponentMixin":30,"./ReactCompositeComponent":38,"./ReactDOM":41}],45:[function(_dereq_,module,exports){ /** * Copyright 2013-2014 Facebook, Inc. * @@ -7496,6 +8099,7 @@ var ReactMount = _dereq_("./ReactMount"); var ReactPerf = _dereq_("./ReactPerf"); var invariant = _dereq_("./invariant"); +var setInnerHTML = _dereq_("./setInnerHTML"); /** * Errors for properties that should not be updated with `updatePropertyById()`. @@ -7509,8 +8113,6 @@ var INVALID_PROPERTY_ERRORS = { style: '`style` must be set using `updateStylesByID()`.' }; -var useWhitespaceWorkaround; - /** * Operations used to process updates to DOM nodes. This is made injectable via * `ReactComponent.BackendIDOperations`. @@ -7599,35 +8201,7 @@ var ReactDOMIDOperations = { 'updateInnerHTMLByID', function(id, html) { var node = ReactMount.getNode(id); - - // IE8: When updating a just created node with innerHTML only leading - // whitespace is removed. When updating an existing node with innerHTML - // whitespace in root TextNodes is also collapsed. - // @see quirksmode.org/bugreports/archives/2004/11/innerhtml_and_t.html - - if (useWhitespaceWorkaround === undefined) { - // Feature detection; only IE8 is known to behave improperly like this. - var temp = document.createElement('div'); - temp.innerHTML = ' '; - useWhitespaceWorkaround = temp.innerHTML === ''; - } - - if (useWhitespaceWorkaround) { - // Magic theory: IE8 supposedly differentiates between added and updated - // nodes when processing innerHTML, innerHTML on updated nodes suffers - // from worse whitespace behavior. Re-adding a node like this triggers - // the initial and more favorable whitespace behavior. - node.parentNode.replaceChild(node, node); - } - - if (useWhitespaceWorkaround && html.match(/^[ \r\n\t\f]/)) { - // Recover leading whitespace by temporarily prepending any character. - // \uFEFF has the potential advantage of being zero-width/invisible. - node.innerHTML = '\uFEFF' + html; - node.firstChild.deleteData(0, 1); - } else { - node.innerHTML = html; - } + setInnerHTML(node, html); } ), @@ -7685,7 +8259,7 @@ var ReactDOMIDOperations = { module.exports = ReactDOMIDOperations; -},{"./CSSPropertyOperations":4,"./DOMChildrenOperations":8,"./DOMPropertyOperations":10,"./ReactMount":60,"./ReactPerf":65,"./invariant":125}],41:[function(_dereq_,module,exports){ +},{"./CSSPropertyOperations":5,"./DOMChildrenOperations":10,"./DOMPropertyOperations":12,"./ReactMount":67,"./ReactPerf":71,"./invariant":134,"./setInnerHTML":152}],46:[function(_dereq_,module,exports){ /** * Copyright 2013-2014 Facebook, Inc. * @@ -7706,11 +8280,11 @@ module.exports = ReactDOMIDOperations; "use strict"; +var EventConstants = _dereq_("./EventConstants"); +var LocalEventTrapMixin = _dereq_("./LocalEventTrapMixin"); var ReactBrowserComponentMixin = _dereq_("./ReactBrowserComponentMixin"); var ReactCompositeComponent = _dereq_("./ReactCompositeComponent"); var ReactDOM = _dereq_("./ReactDOM"); -var ReactEventEmitter = _dereq_("./ReactEventEmitter"); -var EventConstants = _dereq_("./EventConstants"); // Store a reference to the `ReactDOMComponent`. var img = ReactDOM.img; @@ -7725,30 +8299,21 @@ var ReactDOMImg = ReactCompositeComponent.createClass({ displayName: 'ReactDOMImg', tagName: 'IMG', - mixins: [ReactBrowserComponentMixin], + mixins: [ReactBrowserComponentMixin, LocalEventTrapMixin], render: function() { return img(this.props); }, componentDidMount: function() { - var node = this.getDOMNode(); - ReactEventEmitter.trapBubbledEvent( - EventConstants.topLevelTypes.topLoad, - 'load', - node - ); - ReactEventEmitter.trapBubbledEvent( - EventConstants.topLevelTypes.topError, - 'error', - node - ); + this.trapBubbledEvent(EventConstants.topLevelTypes.topLoad, 'load'); + this.trapBubbledEvent(EventConstants.topLevelTypes.topError, 'error'); } }); module.exports = ReactDOMImg; -},{"./EventConstants":15,"./ReactBrowserComponentMixin":27,"./ReactCompositeComponent":33,"./ReactDOM":36,"./ReactEventEmitter":52}],42:[function(_dereq_,module,exports){ +},{"./EventConstants":16,"./LocalEventTrapMixin":26,"./ReactBrowserComponentMixin":30,"./ReactCompositeComponent":38,"./ReactDOM":41}],47:[function(_dereq_,module,exports){ /** * Copyright 2013-2014 Facebook, Inc. * @@ -7932,7 +8497,7 @@ var ReactDOMInput = ReactCompositeComponent.createClass({ module.exports = ReactDOMInput; -},{"./AutoFocusMixin":1,"./DOMPropertyOperations":10,"./LinkedValueUtils":23,"./ReactBrowserComponentMixin":27,"./ReactCompositeComponent":33,"./ReactDOM":36,"./ReactMount":60,"./invariant":125,"./merge":134}],43:[function(_dereq_,module,exports){ +},{"./AutoFocusMixin":1,"./DOMPropertyOperations":12,"./LinkedValueUtils":25,"./ReactBrowserComponentMixin":30,"./ReactCompositeComponent":38,"./ReactDOM":41,"./ReactMount":67,"./invariant":134,"./merge":144}],48:[function(_dereq_,module,exports){ /** * Copyright 2013-2014 Facebook, Inc. * @@ -7989,7 +8554,7 @@ var ReactDOMOption = ReactCompositeComponent.createClass({ module.exports = ReactDOMOption; -},{"./ReactBrowserComponentMixin":27,"./ReactCompositeComponent":33,"./ReactDOM":36,"./warning":148}],44:[function(_dereq_,module,exports){ +},{"./ReactBrowserComponentMixin":30,"./ReactCompositeComponent":38,"./ReactDOM":41,"./warning":158}],49:[function(_dereq_,module,exports){ /** * Copyright 2013-2014 Facebook, Inc. * @@ -8016,7 +8581,6 @@ var ReactBrowserComponentMixin = _dereq_("./ReactBrowserComponentMixin"); var ReactCompositeComponent = _dereq_("./ReactCompositeComponent"); var ReactDOM = _dereq_("./ReactDOM"); -var invariant = _dereq_("./invariant"); var merge = _dereq_("./merge"); // Store a reference to the must be an array if `multiple` is ' + - 'true.', - propName - ) : invariant(Array.isArray(props[propName]))); + if (!Array.isArray(props[propName])) { + return new Error( + ("The `" + propName + "` prop supplied to must be a scalar value if ' + - '`multiple` is false.', - propName - ) : invariant(!Array.isArray(props[propName]))); + if (Array.isArray(props[propName])) { + return new Error( + ("The `" + propName + "` prop supplied to