@samitouri / QOS-React-2 / commits / 505bc7595b

Fix up variable names and types to be correct

Test Plan: jest

Ben Alpert committed Nov 16, 2014 at 16:35 UTC 505bc7595b2b880a54d8420897d353f6ab364146
1 file changed +36 -36
src/core/ReactElementValidator.js
+36 -36
@@ -54,25 +54,25 @@ function getCurrentOwnerDisplayName() {
54 }
55
56 /**
57 - * Warn if the component doesn't have an explicit key assigned to it.
58 - * This component is in an array. The array could grow and shrink or be
57 + * Warn if the element doesn't have an explicit key assigned to it.
58 + * This element is in an array. The array could grow and shrink or be
59 * reordered. All children that haven't already been validated are required to
60 * have a "key" property assigned to it.
61 *
62 * @internal
63 - * @param {ReactComponent} component Component that requires a key.
64 - * @param {*} parentType component's parent's type.
63 + * @param {ReactElement} element Element that requires a key.
64 + * @param {*} parentType element's parent's type.
65 */
66 -function validateExplicitKey(component, parentType) {
67 - if (component._store.validated || component.key != null) {
66 +function validateExplicitKey(element, parentType) {
67 + if (element._store.validated || element.key != null) {
68 return;
69 }
70 - component._store.validated = true;
70 + element._store.validated = true;
71
72 warnAndMonitorForKeyUse(
73 'react_key_warning',
74 'Each child in an array or iterator should have a unique "key" prop.',
75 - component,
75 + element,
76 parentType
77 );
78 }
@@ -83,17 +83,17 @@ function validateExplicitKey(component, parentType) {
83 *
84 * @internal
85 * @param {string} name Property name of the key.
86 - * @param {ReactComponent} component Component that requires a key.
87 - * @param {*} parentType component's parent's type.
86 + * @param {ReactElement} element Component that requires a key.
87 + * @param {*} parentType element's parent's type.
88 */
89 -function validatePropertyKey(name, component, parentType) {
89 +function validatePropertyKey(name, element, parentType) {
90 if (!NUMERIC_PROPERTY_REGEX.test(name)) {
91 return;
92 }
93 warnAndMonitorForKeyUse(
94 'react_numeric_key_warning',
95 'Child objects should have non-numeric keys so ordering is preserved.',
96 - component,
96 + element,
97 parentType
98 );
99 }
@@ -104,10 +104,10 @@ function validatePropertyKey(name, component, parentType) {
104 * @internal
105 * @param {string} warningID The id used when logging.
106 * @param {string} message The base warning that gets output.
107 - * @param {ReactComponent} component Component that requires a key.
108 - * @param {*} parentType component's parent's type.
107 + * @param {ReactElement} element Component that requires a key.
108 + * @param {*} parentType element's parent's type.
109 */
110 -function warnAndMonitorForKeyUse(warningID, message, component, parentType) {
110 +function warnAndMonitorForKeyUse(warningID, message, element, parentType) {
111 var ownerName = getCurrentOwnerDisplayName();
112 var parentName = parentType.displayName;
113
@@ -126,12 +126,12 @@ function warnAndMonitorForKeyUse(warningID, message, component, parentType) {
126 // property, it may be the creator of the child that's responsible for
127 // assigning it a key.
128 var childOwnerName = null;
129 - if (component &&
130 - component._owner &&
131 - component._owner !== ReactCurrentOwner.current) {
129 + if (element &&
130 + element._owner &&
131 + element._owner !== ReactCurrentOwner.current) {
132 // Name of the component that originally created this child.
133 childOwnerName =
134 - component._owner.getPublicInstance().constructor.displayName;
134 + element._owner.getPublicInstance().constructor.displayName;
135
136 message += ` It was passed a child from ${childOwnerName}.`;
137 }
@@ -165,36 +165,36 @@ function monitorUseOfObjectMap() {
165 * with valid key property.
166 *
167 * @internal
168 - * @param {*} component Statically passed child of any type.
169 - * @param {*} parentType component's parent's type.
168 + * @param {ReactNode} node Statically passed child of any type.
169 + * @param {*} parentType node's parent's type.
170 */
171 -function validateChildKeys(component, parentType) {
172 - if (Array.isArray(component)) {
173 - for (var i = 0; i < component.length; i++) {
174 - var child = component[i];
171 +function validateChildKeys(node, parentType) {
172 + if (Array.isArray(node)) {
173 + for (var i = 0; i < node.length; i++) {
174 + var child = node[i];
175 if (ReactElement.isValidElement(child)) {
176 validateExplicitKey(child, parentType);
177 }
178 }
179 - } else if (ReactElement.isValidElement(component)) {
180 - // This component was passed in a valid location.
181 - component._store.validated = true;
182 - } else if (component) {
183 - var iteratorFn = getIteratorFn(component);
179 + } else if (ReactElement.isValidElement(node)) {
180 + // This element was passed in a valid location.
181 + node._store.validated = true;
182 + } else if (node) {
183 + var iteratorFn = getIteratorFn(node);
184 // Entry iterators provide implicit keys.
185 - if (iteratorFn && iteratorFn !== component.entries) {
186 - var iterator = iteratorFn.call(component);
185 + if (iteratorFn && iteratorFn !== node.entries) {
186 + var iterator = iteratorFn.call(node);
187 var step;
188 while (!(step = iterator.next()).done) {
189 if (ReactElement.isValidElement(step.value)) {
190 validateExplicitKey(step.value, parentType);
191 }
192 }
193 - } else if (typeof component === 'object') {
193 + } else if (typeof node === 'object') {
194 monitorUseOfObjectMap();
195 - for (var key in component) {
196 - if (component.hasOwnProperty(key)) {
197 - validatePropertyKey(key, component[key], parentType);
195 + for (var key in node) {
196 + if (node.hasOwnProperty(key)) {
197 + validatePropertyKey(key, node[key], parentType);
198 }
199 }
200 }