mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
ReactNativeComponent -> ReactDOMComponent
In an effort to break the DOMy parts of React away from the non-DOMy parts, I'm renaming this.
This commit is contained in:
committed by
Paul O’Shannessy
parent
e66287f92e
commit
f43449d333
@@ -19,7 +19,7 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
var ReactNativeComponent = require('ReactNativeComponent');
|
||||
var ReactDOMComponent = require('ReactDOMComponent');
|
||||
|
||||
var mergeInto = require('mergeInto');
|
||||
var objMapKeyVal = require('objMapKeyVal');
|
||||
@@ -41,7 +41,7 @@ var objMapKeyVal = require('objMapKeyVal');
|
||||
*/
|
||||
function createDOMComponentClass(tag, omitClose) {
|
||||
var Constructor = function() {};
|
||||
Constructor.prototype = new ReactNativeComponent(tag, omitClose);
|
||||
Constructor.prototype = new ReactDOMComponent(tag, omitClose);
|
||||
Constructor.prototype.constructor = Constructor;
|
||||
|
||||
var ConvenienceConstructor = function(props, children) {
|
||||
@@ -54,7 +54,7 @@ function createDOMComponentClass(tag, omitClose) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a mapping from supported HTML tags to `ReactNativeComponent` classes.
|
||||
* Creates a mapping from supported HTML tags to `ReactDOMComponent` classes.
|
||||
* This is also accessible via `React.DOM`.
|
||||
*
|
||||
* @public
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @providesModule ReactNativeComponent
|
||||
* @providesModule ReactDOMComponent
|
||||
* @typechecks static-only
|
||||
*/
|
||||
|
||||
@@ -64,17 +64,17 @@ function assertValidProps(props) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @constructor ReactNativeComponent
|
||||
* @constructor ReactDOMComponent
|
||||
* @extends ReactComponent
|
||||
* @extends ReactMultiChild
|
||||
*/
|
||||
function ReactNativeComponent(tag, omitClose) {
|
||||
function ReactDOMComponent(tag, omitClose) {
|
||||
this._tagOpen = '<' + tag;
|
||||
this._tagClose = omitClose ? '' : '</' + tag + '>';
|
||||
this.tagName = tag.toUpperCase();
|
||||
}
|
||||
|
||||
ReactNativeComponent.Mixin = {
|
||||
ReactDOMComponent.Mixin = {
|
||||
|
||||
/**
|
||||
* Generates root tag markup then recurses. This method has side effects and
|
||||
@@ -87,7 +87,7 @@ ReactNativeComponent.Mixin = {
|
||||
* @return {string} The computed markup.
|
||||
*/
|
||||
mountComponent: ReactPerf.measure(
|
||||
'ReactNativeComponent',
|
||||
'ReactDOMComponent',
|
||||
'mountComponent',
|
||||
function(rootID, transaction, mountDepth) {
|
||||
ReactComponent.Mixin.mountComponent.call(
|
||||
@@ -195,7 +195,7 @@ ReactNativeComponent.Mixin = {
|
||||
* @overridable
|
||||
*/
|
||||
updateComponent: ReactPerf.measure(
|
||||
'ReactNativeComponent',
|
||||
'ReactDOMComponent',
|
||||
'updateComponent',
|
||||
function(transaction, prevProps) {
|
||||
ReactComponent.Mixin.updateComponent.call(this, transaction, prevProps);
|
||||
@@ -364,8 +364,8 @@ ReactNativeComponent.Mixin = {
|
||||
|
||||
};
|
||||
|
||||
mixInto(ReactNativeComponent, ReactComponent.Mixin);
|
||||
mixInto(ReactNativeComponent, ReactNativeComponent.Mixin);
|
||||
mixInto(ReactNativeComponent, ReactMultiChild.Mixin);
|
||||
mixInto(ReactDOMComponent, ReactComponent.Mixin);
|
||||
mixInto(ReactDOMComponent, ReactDOMComponent.Mixin);
|
||||
mixInto(ReactDOMComponent, ReactMultiChild.Mixin);
|
||||
|
||||
module.exports = ReactNativeComponent;
|
||||
module.exports = ReactDOMComponent;
|
||||
@@ -179,7 +179,7 @@ var ReactMultiChild = {
|
||||
|
||||
/**
|
||||
* Provides common functionality for components that must reconcile multiple
|
||||
* children. This is used by `ReactNativeComponent` to mount, update, and
|
||||
* children. This is used by `ReactDOMComponent` to mount, update, and
|
||||
* unmount child components.
|
||||
*
|
||||
* @lends {ReactMultiChild.prototype}
|
||||
@@ -188,7 +188,7 @@ var ReactMultiChild = {
|
||||
|
||||
/**
|
||||
* Generates a "mount image" for each of the supplied children. In the case
|
||||
* of `ReactNativeComponent`, a mount image is a string of markup.
|
||||
* of `ReactDOMComponent`, a mount image is a string of markup.
|
||||
*
|
||||
* @param {?object} children As returned by `flattenChildren`.
|
||||
* @return {array} An array of mounted representations.
|
||||
|
||||
+7
-7
@@ -23,7 +23,7 @@
|
||||
|
||||
var mocks = require('mocks');
|
||||
|
||||
describe('ReactNativeComponent', function() {
|
||||
describe('ReactDOMComponent', function() {
|
||||
|
||||
describe('updateDOM', function() {
|
||||
var React;
|
||||
@@ -220,13 +220,13 @@ describe('ReactNativeComponent', function() {
|
||||
ReactDefaultInjection.inject();
|
||||
|
||||
var mixInto = require('mixInto');
|
||||
var ReactNativeComponent = require('ReactNativeComponent');
|
||||
var ReactDOMComponent = require('ReactDOMComponent');
|
||||
|
||||
var NodeStub = function(initialProps) {
|
||||
this.props = initialProps || {};
|
||||
this._rootNodeID = 'test';
|
||||
};
|
||||
mixInto(NodeStub, ReactNativeComponent.Mixin);
|
||||
mixInto(NodeStub, ReactDOMComponent.Mixin);
|
||||
|
||||
genMarkup = function(props) {
|
||||
return (new NodeStub(props))._createOpenTagMarkup();
|
||||
@@ -261,14 +261,14 @@ describe('ReactNativeComponent', function() {
|
||||
require('mock-modules').dumpCache();
|
||||
|
||||
var mixInto = require('mixInto');
|
||||
var ReactNativeComponent = require('ReactNativeComponent');
|
||||
var ReactDOMComponent = require('ReactDOMComponent');
|
||||
var ReactReconcileTransaction = require('ReactReconcileTransaction');
|
||||
|
||||
var NodeStub = function(initialProps) {
|
||||
this.props = initialProps || {};
|
||||
this._rootNodeID = 'test';
|
||||
};
|
||||
mixInto(NodeStub, ReactNativeComponent.Mixin);
|
||||
mixInto(NodeStub, ReactDOMComponent.Mixin);
|
||||
|
||||
genMarkup = function(props) {
|
||||
var transaction = new ReactReconcileTransaction();
|
||||
@@ -300,14 +300,14 @@ describe('ReactNativeComponent', function() {
|
||||
var mixInto = require('mixInto');
|
||||
var ReactComponent = require('ReactComponent');
|
||||
var ReactMultiChild = require('ReactMultiChild');
|
||||
var ReactNativeComponent = require('ReactNativeComponent');
|
||||
var ReactDOMComponent = require('ReactDOMComponent');
|
||||
var ReactReconcileTransaction = require('ReactReconcileTransaction');
|
||||
|
||||
var StubNativeComponent = function(initialProps) {
|
||||
ReactComponent.Mixin.construct.call(this, initialProps);
|
||||
};
|
||||
mixInto(StubNativeComponent, ReactComponent.Mixin);
|
||||
mixInto(StubNativeComponent, ReactNativeComponent.Mixin);
|
||||
mixInto(StubNativeComponent, ReactDOMComponent.Mixin);
|
||||
mixInto(StubNativeComponent, ReactMultiChild.Mixin);
|
||||
|
||||
mountComponent = function(props) {
|
||||
@@ -23,7 +23,7 @@ var ReactDOM = require('ReactDOM');
|
||||
|
||||
var keyMirror = require('keyMirror');
|
||||
|
||||
// Store a reference to the <button> `ReactNativeComponent`.
|
||||
// Store a reference to the <button> `ReactDOMComponent`.
|
||||
var button = ReactDOM.button;
|
||||
|
||||
var mouseListenerNames = keyMirror({
|
||||
|
||||
@@ -23,7 +23,7 @@ var ReactDOM = require('ReactDOM');
|
||||
var ReactEventEmitter = require('ReactEventEmitter');
|
||||
var EventConstants = require('EventConstants');
|
||||
|
||||
// Store a reference to the <form> `ReactNativeComponent`.
|
||||
// Store a reference to the <form> `ReactDOMComponent`.
|
||||
var form = ReactDOM.form;
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,7 +27,7 @@ var ReactMount = require('ReactMount');
|
||||
var invariant = require('invariant');
|
||||
var merge = require('merge');
|
||||
|
||||
// Store a reference to the <input> `ReactNativeComponent`.
|
||||
// Store a reference to the <input> `ReactDOMComponent`.
|
||||
var input = ReactDOM.input;
|
||||
|
||||
var instancesByReactID = {};
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
var ReactCompositeComponent = require('ReactCompositeComponent');
|
||||
var ReactDOM = require('ReactDOM');
|
||||
|
||||
// Store a reference to the <option> `ReactNativeComponent`.
|
||||
// Store a reference to the <option> `ReactDOMComponent`.
|
||||
var option = ReactDOM.option;
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,7 +25,7 @@ var ReactDOM = require('ReactDOM');
|
||||
var invariant = require('invariant');
|
||||
var merge = require('merge');
|
||||
|
||||
// Store a reference to the <select> `ReactNativeComponent`.
|
||||
// Store a reference to the <select> `ReactDOMComponent`.
|
||||
var select = ReactDOM.select;
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,7 +26,7 @@ var ReactDOM = require('ReactDOM');
|
||||
var invariant = require('invariant');
|
||||
var merge = require('merge');
|
||||
|
||||
// Store a reference to the <textarea> `ReactNativeComponent`.
|
||||
// Store a reference to the <textarea> `ReactDOMComponent`.
|
||||
var textarea = ReactDOM.textarea;
|
||||
|
||||
// For quickly matching children type, to test if can be treated as content.
|
||||
@@ -84,7 +84,7 @@ var ReactDOMTextarea = ReactCompositeComponent.createClass({
|
||||
}
|
||||
var value = this.getValue();
|
||||
return {
|
||||
// We save the initial value so that `ReactNativeComponent` doesn't update
|
||||
// We save the initial value so that `ReactDOMComponent` doesn't update
|
||||
// `textContent` (unnecessary since we update value).
|
||||
initialValue: value != null ? value : defaultValue,
|
||||
value: defaultValue
|
||||
|
||||
@@ -307,8 +307,8 @@ if (__DEV__) {
|
||||
switch (objName + '.' + fnName) {
|
||||
case 'React.renderComponent':
|
||||
return _renderComponentCallback;
|
||||
case 'ReactNativeComponent.mountComponent':
|
||||
case 'ReactNativeComponent.updateComponent':
|
||||
case 'ReactDOMComponent.mountComponent':
|
||||
case 'ReactDOMComponent.updateComponent':
|
||||
return _nativeComponentCallback;
|
||||
case 'ReactCompositeComponent.mountComponent':
|
||||
case 'ReactCompositeComponent.updateComponent':
|
||||
@@ -355,7 +355,7 @@ if (__DEV__) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Callback function for ReactNativeComponent
|
||||
* Callback function for ReactDOMComponent
|
||||
*
|
||||
* @param {object} component
|
||||
* @param {object} args
|
||||
|
||||
@@ -122,7 +122,7 @@ var ReactTestUtils = {
|
||||
* Like scryRenderedDOMComponentsWithClass but expects there to be one result,
|
||||
* and returns that one result, or throws exception if there is any other
|
||||
* number of matches besides one.
|
||||
* @return {!ReactNativeComponent} The one match.
|
||||
* @return {!ReactDOMComponent} The one match.
|
||||
*/
|
||||
findRenderedDOMComponentWithClass: function(root, className) {
|
||||
var all =
|
||||
@@ -150,7 +150,7 @@ var ReactTestUtils = {
|
||||
* Like scryRenderedDOMComponentsWithTag but expects there to be one result,
|
||||
* and returns that one result, or throws exception if there is any other
|
||||
* number of matches besides one.
|
||||
* @return {!ReactNativeComponent} The one match.
|
||||
* @return {!ReactDOMComponent} The one match.
|
||||
*/
|
||||
findRenderedDOMComponentWithTag: function(root, tagName) {
|
||||
var all = ReactTestUtils.scryRenderedDOMComponentsWithTag(root, tagName);
|
||||
@@ -208,9 +208,9 @@ var ReactTestUtils = {
|
||||
|
||||
/**
|
||||
* Simulates a top level event being dispatched from a raw event that occured
|
||||
* on the `ReactNativeComponent` `comp`.
|
||||
* on the `ReactDOMComponent` `comp`.
|
||||
* @param topLevelType {Object} A type from `EventConstants.topLevelTypes`.
|
||||
* @param comp {!ReactNativeComponent}
|
||||
* @param comp {!ReactDOMComponent}
|
||||
* @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent.
|
||||
*/
|
||||
simulateEventOnDOMComponent: function(topLevelType, comp, fakeNativeEvent) {
|
||||
@@ -243,10 +243,10 @@ var ReactTestUtils = {
|
||||
/**
|
||||
* Exports:
|
||||
*
|
||||
* - `ReactTestUtils.Simulate.click(Element/ReactNativeComponent)`
|
||||
* - `ReactTestUtils.Simulate.mouseMove(Element/ReactNativeComponent)`
|
||||
* - `ReactTestUtils.Simulate.mouseIn/ReactNativeComponent)`
|
||||
* - `ReactTestUtils.Simulate.mouseOut(Element/ReactNativeComponent)`
|
||||
* - `ReactTestUtils.Simulate.click(Element/ReactDOMComponent)`
|
||||
* - `ReactTestUtils.Simulate.mouseMove(Element/ReactDOMComponent)`
|
||||
* - `ReactTestUtils.Simulate.mouseIn/ReactDOMComponent)`
|
||||
* - `ReactTestUtils.Simulate.mouseOut(Element/ReactDOMComponent)`
|
||||
* - ... (All keys from `EventConstants.topLevelTypes`)
|
||||
*
|
||||
* Note: Top level event types are a subset of the entire set of handler types
|
||||
@@ -287,7 +287,7 @@ for (eventType in topLevelTypes) {
|
||||
var convenienceName = eventType.indexOf('top') === 0 ?
|
||||
eventType.charAt(3).toLowerCase() + eventType.substr(4) : eventType;
|
||||
/**
|
||||
* @param {!Element || ReactNativeComponent} domComponentOrNode
|
||||
* @param {!Element || ReactDOMComponent} domComponentOrNode
|
||||
* @param {?Event} nativeEventData Fake native event to use in SyntheticEvent.
|
||||
*/
|
||||
ReactTestUtils.Simulate[convenienceName] = makeSimulator(eventType);
|
||||
|
||||
Reference in New Issue
Block a user