Socket
Socket
Sign inDemoInstall

react

Package Overview
Dependencies
33
Maintainers
4
Versions
1793
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.14.0-alpha1 to 0.14.0-alpha2

lib/ReactDOMClient.js

2

lib/adler32.js

@@ -12,4 +12,2 @@ /**

/* jslint bitwise:true */
'use strict';

@@ -16,0 +14,0 @@

@@ -30,5 +30,5 @@ /**

_function: while (_again) {
_again = false;
var outerNode = _x,
innerNode = _x2;
_again = false;

@@ -35,0 +35,0 @@ if (!outerNode || !innerNode) {

@@ -13,4 +13,2 @@ /**

/*jslint evil: true, sub: true */
'use strict';

@@ -17,0 +15,0 @@

@@ -13,4 +13,2 @@ /**

/*jslint bitwise: true */
'use strict';

@@ -17,0 +15,0 @@

@@ -12,4 +12,2 @@ /**

/*jslint bitwise: true*/
'use strict';

@@ -110,2 +108,3 @@

min: null,
minLength: MUST_USE_ATTRIBUTE,
multiple: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,

@@ -112,0 +111,0 @@ muted: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,

@@ -12,120 +12,18 @@ /**

/* globals __REACT_DEVTOOLS_GLOBAL_HOOK__*/
'use strict';
var ReactChildren = require("./ReactChildren");
var ReactComponent = require("./ReactComponent");
var ReactClass = require("./ReactClass");
var ReactCurrentOwner = require("./ReactCurrentOwner");
var ReactElement = require("./ReactElement");
var ReactElementValidator = require("./ReactElementValidator");
var ReactDOM = require("./ReactDOM");
var ReactDOMTextComponent = require("./ReactDOMTextComponent");
var ReactDefaultInjection = require("./ReactDefaultInjection");
var ReactInstanceHandles = require("./ReactInstanceHandles");
var ReactMount = require("./ReactMount");
var ReactPerf = require("./ReactPerf");
var ReactPropTypes = require("./ReactPropTypes");
var ReactReconciler = require("./ReactReconciler");
var ReactServerRendering = require("./ReactServerRendering");
var ReactDOMClient = require("./ReactDOMClient");
var ReactDOMServer = require("./ReactDOMServer");
var ReactIsomorphic = require("./ReactIsomorphic");
var assign = require("./Object.assign");
var findDOMNode = require("./findDOMNode");
var onlyChild = require("./onlyChild");
var warning = require("./warning");
ReactDefaultInjection.inject();
var React = {};
var createElement = ReactElement.createElement;
var createFactory = ReactElement.createFactory;
var cloneElement = ReactElement.cloneElement;
assign(React, ReactIsomorphic);
assign(React, ReactDOMClient);
assign(React, ReactDOMServer);
if ('production' !== process.env.NODE_ENV) {
createElement = ReactElementValidator.createElement;
createFactory = ReactElementValidator.createFactory;
cloneElement = ReactElementValidator.cloneElement;
}
React.version = '0.14.0-alpha2';
var render = ReactPerf.measure('React', 'render', ReactMount.render);
var React = {
Children: {
map: ReactChildren.map,
forEach: ReactChildren.forEach,
count: ReactChildren.count,
only: onlyChild
},
Component: ReactComponent,
DOM: ReactDOM,
PropTypes: ReactPropTypes,
createClass: ReactClass.createClass,
createElement: createElement,
cloneElement: cloneElement,
createFactory: createFactory,
createMixin: function (mixin) {
// Currently a noop. Will be used to validate and trace mixins.
return mixin;
},
constructAndRenderComponent: ReactMount.constructAndRenderComponent,
constructAndRenderComponentByID: ReactMount.constructAndRenderComponentByID,
findDOMNode: findDOMNode,
render: render,
renderToString: ReactServerRendering.renderToString,
renderToStaticMarkup: ReactServerRendering.renderToStaticMarkup,
unmountComponentAtNode: ReactMount.unmountComponentAtNode,
isValidElement: ReactElement.isValidElement,
// Hook for JSX spread, don't use this for anything else.
__spread: assign
};
// Inject the runtime into a devtools global hook regardless of browser.
// Allows for debugging when the hook is injected on the page.
if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.inject === 'function') {
__REACT_DEVTOOLS_GLOBAL_HOOK__.inject({
CurrentOwner: ReactCurrentOwner,
InstanceHandles: ReactInstanceHandles,
Mount: ReactMount,
Reconciler: ReactReconciler,
TextComponent: ReactDOMTextComponent
});
}
if ('production' !== process.env.NODE_ENV) {
var ExecutionEnvironment = require("./ExecutionEnvironment");
if (ExecutionEnvironment.canUseDOM && window.top === window.self) {
// If we're in Chrome, look for the devtools marker and provide a download
// link if not installed.
if (navigator.userAgent.indexOf('Chrome') > -1) {
if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') {
console.debug('Download the React DevTools for a better development experience: ' + 'https://fb.me/react-devtools');
}
}
// If we're in IE8, check to see if we are in combatibility mode and provide
// information on preventing compatibility mode
var ieCompatibilityMode = document.documentMode && document.documentMode < 8;
'production' !== process.env.NODE_ENV ? warning(!ieCompatibilityMode, 'Internet Explorer is running in compatibility mode; please add the ' + 'following tag to your HTML to prevent this from happening: ' + '<meta http-equiv="X-UA-Compatible" content="IE=edge" />') : null;
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 = 0; i < expectedFeatures.length; i++) {
if (!expectedFeatures[i]) {
console.error('One or more ES5 shim/shams expected by React are not available: ' + 'https://fb.me/react-warning-polyfills');
break;
}
}
}
}
React.version = '0.14.0-alpha1';
module.exports = React;

@@ -32,10 +32,11 @@ /**

function ForEachBookKeeping(forEachFunction, forEachContext) {
this.forEachFunction = forEachFunction;
this.forEachContext = forEachContext;
this.func = forEachFunction;
this.context = forEachContext;
this.count = 0;
}
PooledClass.addPoolingTo(ForEachBookKeeping, twoArgumentPooler);
function forEachSingleChild(traverseContext, child, name, i) {
var forEachBookKeeping = traverseContext;
forEachBookKeeping.forEachFunction.call(forEachBookKeeping.forEachContext, child, i);
function forEachSingleChild(traverseContext, child, name) {
var bookKeeping = traverseContext;
bookKeeping.func.call(bookKeeping.context, child, bookKeeping.count++);
}

@@ -73,11 +74,12 @@

function MapBookKeeping(mapResult, mapFunction, mapContext) {
this.mapResult = mapResult;
this.mapFunction = mapFunction;
this.mapContext = mapContext;
this.result = mapResult;
this.func = mapFunction;
this.context = mapContext;
this.count = 0;
}
PooledClass.addPoolingTo(MapBookKeeping, threeArgumentPooler);
function mapSingleChildIntoContext(traverseContext, child, name, i) {
var mapBookKeeping = traverseContext;
var mapResult = mapBookKeeping.mapResult;
function mapSingleChildIntoContext(traverseContext, child, name) {
var bookKeeping = traverseContext;
var mapResult = bookKeeping.result;

@@ -90,3 +92,3 @@ var keyUnique = mapResult[name] === undefined;

if (keyUnique) {
var mappedChild = mapBookKeeping.mapFunction.call(mapBookKeeping.mapContext, child, i);
var mappedChild = bookKeeping.func.call(bookKeeping.context, child, bookKeeping.count++);
mapResult[name] = mappedChild;

@@ -122,3 +124,3 @@ }

function forEachSingleChildDummy(traverseContext, child, name, i) {
function forEachSingleChildDummy(traverseContext, child, name) {
return null;

@@ -125,0 +127,0 @@ }

@@ -409,3 +409,3 @@ /**

if (name === MIXINS_KEY) {
// We have already handled mixins in a special case above
// We have already handled mixins in a special case above.
continue;

@@ -439,3 +439,3 @@ }

// These cases should already be caught by validateMethodOverride
// These cases should already be caught by validateMethodOverride.
'production' !== process.env.NODE_ENV ? invariant(isReactClassMethod && (specPolicy === SpecPolicy.DEFINE_MANY_MERGED || specPolicy === SpecPolicy.DEFINE_MANY), 'ReactClass: Unexpected spec policy %s for key %s ' + 'when mixing in component specs.', specPolicy, name) : invariant(isReactClassMethod && (specPolicy === SpecPolicy.DEFINE_MANY_MERGED || specPolicy === SpecPolicy.DEFINE_MANY));

@@ -739,3 +739,3 @@

// Initialize the defaultProps property after all mixins have been merged
// Initialize the defaultProps property after all mixins have been merged.
if (Constructor.getDefaultProps) {

@@ -742,0 +742,0 @@ Constructor.defaultProps = Constructor.getDefaultProps();

@@ -12,4 +12,2 @@ /**

/*jslint evil: true */
'use strict';

@@ -16,0 +14,0 @@

@@ -65,3 +65,13 @@ /**

var alreadyInjected = false;
function inject() {
if (alreadyInjected) {
// TODO: This is currently true because these injections are shared between
// the client and the server package. They should be built independently
// and not share any injection state. Then this problem will be solved.
return;
}
alreadyInjected = true;
ReactInjection.EventEmitter.injectReactEventListener(ReactEventListener);

@@ -68,0 +78,0 @@

@@ -176,8 +176,8 @@ /**

function processChildContext(context, tagName) {
function processChildContext(context, inst) {
if ('production' !== process.env.NODE_ENV) {
// Pass down our tag name to child components for validation purposes
context = assign({}, context);
var stack = context[validateDOMNesting.tagStackContextKey] || [];
context[validateDOMNesting.tagStackContextKey] = stack.concat([tagName]);
var info = context[validateDOMNesting.ancestorInfoContextKey];
context[validateDOMNesting.ancestorInfoContextKey] = validateDOMNesting.updatedAncestorInfo(info, inst._tag, inst);
}

@@ -233,4 +233,4 @@ return context;

if ('production' !== process.env.NODE_ENV) {
if (context[validateDOMNesting.tagStackContextKey]) {
validateDOMNesting(context[validateDOMNesting.tagStackContextKey], this._tag, this._currentElement);
if (context[validateDOMNesting.ancestorInfoContextKey]) {
validateDOMNesting(this._tag, this, context[validateDOMNesting.ancestorInfoContextKey]);
}

@@ -326,3 +326,3 @@ }

} else if (childrenToUse != null) {
var mountImages = this.mountChildren(childrenToUse, transaction, processChildContext(context, this._tag));
var mountImages = this.mountChildren(childrenToUse, transaction, processChildContext(context, this));
ret = mountImages.join('');

@@ -375,3 +375,3 @@ }

this._updateDOMProperties(prevElement.props, transaction);
this._updateDOMChildren(prevElement.props, transaction, processChildContext(context, this._tag));
this._updateDOMChildren(prevElement.props, transaction, processChildContext(context, this));
},

@@ -378,0 +378,0 @@

@@ -13,4 +13,2 @@ /**

/*jslint evil: true */
'use strict';

@@ -17,0 +15,0 @@

@@ -15,2 +15,3 @@ /**

var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
var ReactChildren = require("./ReactChildren");
var ReactClass = require("./ReactClass");

@@ -86,3 +87,18 @@ var ReactDOMSelect = require("./ReactDOMSelect");

return option(props, this.props.children);
var content = '';
// Flatten children and warn if they aren't strings or numbers;
// invalid types are ignored.
ReactChildren.forEach(this.props.children, function (child) {
if (child == null) {
return;
}
if (typeof child === 'string' || typeof child === 'number') {
content += child;
} else {
'production' !== process.env.NODE_ENV ? warning(false, 'Only strings and numbers are supported as <option> children.') : null;
}
});
return option(props, content);
}

@@ -89,0 +105,0 @@

@@ -67,4 +67,4 @@ /**

if ('production' !== process.env.NODE_ENV) {
if (context[validateDOMNesting.tagStackContextKey]) {
validateDOMNesting(context[validateDOMNesting.tagStackContextKey], 'span', null);
if (context[validateDOMNesting.ancestorInfoContextKey]) {
validateDOMNesting('span', null, context[validateDOMNesting.ancestorInfoContextKey]);
}

@@ -71,0 +71,0 @@ }

@@ -102,2 +102,15 @@ /**

// To make comparing ReactElements easier for testing purposes, we make
// the validation flag non-enumerable (where possible, which should
// include every environment we run tests in), so the test framework
// ignores it.
try {
Object.defineProperty(this._store, 'validated', {
configurable: false,
enumerable: false,
writable: true
});
} catch (x) {}
this._store.validated = false;
// We're not allowed to set props directly on the object so we early

@@ -152,16 +165,2 @@ // return and rely on the prototype membrane to forward to the backing

var childArray = Array(childrenLength);
// To make comparing ReactElements easier for testing purposes, we make
// the validation flag non-enumerable (where possible, which should
// include every environment we run tests in), so the test framework
// ignores it.
try {
Object.defineProperty(childArray, '_reactChildKeysValidated', {
configurable: false,
enumerable: false,
writable: true
});
} catch (x) {}
childArray._reactChildKeysValidated = true;
for (var i = 0; i < childrenLength; i++) {

@@ -199,2 +198,7 @@ childArray[i] = arguments[i + 2];

var newElement = new ReactElement(oldElement.type, oldElement.key, oldElement.ref, oldElement._owner, oldElement._context, newProps);
if ('production' !== process.env.NODE_ENV) {
// If the key on the original is valid, then the clone is valid
newElement._store.validated = oldElement._store.validated;
}
return newElement;

@@ -201,0 +205,0 @@ };

@@ -93,5 +93,7 @@ /**

function validateExplicitKey(element, parentType) {
if (element.key != null) {
if (element._store.validated || element.key != null) {
return;
}
element._store.validated = true;
warnAndMonitorForKeyUse('Each child in an array or iterator should have a unique "key" prop.', element, parentType);

@@ -162,6 +164,2 @@ }

if (Array.isArray(node)) {
if (node._reactChildKeysValidated) {
// All child elements were passed in a valid location.
return;
}
for (var i = 0; i < node.length; i++) {

@@ -171,10 +169,7 @@ var child = node[i];

validateExplicitKey(child, parentType);
} else {
// TODO: Warn on unkeyed arrays and suggest using createFragment
validateChildKeys(child, parentType);
}
}
} else if (typeof node === 'string' || typeof node === 'number' || ReactElement.isValidElement(node)) {
} else if (ReactElement.isValidElement(node)) {
// This element was passed in a valid location.
return;
node._store.validated = true;
} else if (node) {

@@ -190,4 +185,2 @@ var iteratorFn = getIteratorFn(node);

validateExplicitKey(step.value, parentType);
} else {
validateChildKeys(step.value, parentType);
}

@@ -201,3 +194,2 @@ }

validatePropertyKey(key, fragment[key], parentType);
validateChildKeys(fragment[key], parentType);
}

@@ -204,0 +196,0 @@ }

@@ -254,3 +254,4 @@ /**

}
context[validateDOMNesting.tagStackContextKey] = [container.nodeName.toLowerCase()];
var tag = container.nodeName.toLowerCase();
context[validateDOMNesting.ancestorInfoContextKey] = validateDOMNesting.updatedAncestorInfo(null, tag, null);
}

@@ -257,0 +258,0 @@ var markup = ReactReconciler.mountComponent(componentInstance, rootID, transaction, context);

@@ -89,12 +89,13 @@ /**

function createChainableTypeChecker(validate) {
function checkType(isRequired, props, propName, componentName, location) {
function checkType(isRequired, props, propName, componentName, location, propFullName) {
componentName = componentName || ANONYMOUS;
propFullName = propFullName || propName;
if (props[propName] == null) {
var locationName = ReactPropTypeLocationNames[location];
if (isRequired) {
return new Error('Required ' + locationName + ' `' + propName + '` was not specified in ' + ('`' + componentName + '`.'));
return new Error('Required ' + locationName + ' `' + propFullName + '` was not specified in ' + ('`' + componentName + '`.'));
}
return null;
} else {
return validate(props, propName, componentName, location);
return validate(props, propName, componentName, location, propFullName);
}

@@ -110,3 +111,3 @@ }

function createPrimitiveTypeChecker(expectedType) {
function validate(props, propName, componentName, location) {
function validate(props, propName, componentName, location, propFullName) {
var propValue = props[propName];

@@ -121,3 +122,3 @@ var propType = getPropType(propValue);

return new Error('Invalid ' + locationName + ' `' + propName + '` of type `' + preciseType + '` ' + ('supplied to `' + componentName + '`, expected `' + expectedType + '`.'));
return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
}

@@ -134,3 +135,3 @@ return null;

function createArrayOfTypeChecker(typeChecker) {
function validate(props, propName, componentName, location) {
function validate(props, propName, componentName, location, propFullName) {
var propValue = props[propName];

@@ -140,6 +141,6 @@ if (!Array.isArray(propValue)) {

var propType = getPropType(propValue);
return new Error('Invalid ' + locationName + ' `' + propName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
}
for (var i = 0; i < propValue.length; i++) {
var error = typeChecker(propValue, i, componentName, location);
var error = typeChecker(propValue, i, componentName, location, '' + propFullName + '[' + i + ']');
if (error instanceof Error) {

@@ -155,6 +156,6 @@ return error;

function createElementTypeChecker() {
function validate(props, propName, componentName, location) {
function validate(props, propName, componentName, location, propFullName) {
if (!ReactElement.isValidElement(props[propName])) {
var locationName = ReactPropTypeLocationNames[location];
return new Error('Invalid ' + locationName + ' `' + propName + '` supplied to ' + ('`' + componentName + '`, expected a ReactElement.'));
return new Error('Invalid ' + locationName + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a single ReactElement.'));
}

@@ -167,7 +168,7 @@ return null;

function createInstanceTypeChecker(expectedClass) {
function validate(props, propName, componentName, location) {
function validate(props, propName, componentName, location, propFullName) {
if (!(props[propName] instanceof expectedClass)) {
var locationName = ReactPropTypeLocationNames[location];
var expectedClassName = expectedClass.name || ANONYMOUS;
return new Error('Invalid ' + locationName + ' `' + propName + '` supplied to ' + ('`' + componentName + '`, expected instance of `' + expectedClassName + '`.'));
return new Error('Invalid ' + locationName + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected instance of `' + expectedClassName + '`.'));
}

@@ -180,3 +181,3 @@ return null;

function createEnumTypeChecker(expectedValues) {
function validate(props, propName, componentName, location) {
function validate(props, propName, componentName, location, propFullName) {
var propValue = props[propName];

@@ -191,3 +192,3 @@ for (var i = 0; i < expectedValues.length; i++) {

var valuesString = JSON.stringify(expectedValues);
return new Error('Invalid ' + locationName + ' `' + propName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
return new Error('Invalid ' + locationName + ' `' + propFullName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
}

@@ -198,3 +199,3 @@ return createChainableTypeChecker(validate);

function createObjectOfTypeChecker(typeChecker) {
function validate(props, propName, componentName, location) {
function validate(props, propName, componentName, location, propFullName) {
var propValue = props[propName];

@@ -204,7 +205,7 @@ var propType = getPropType(propValue);

var locationName = ReactPropTypeLocationNames[location];
return new Error('Invalid ' + locationName + ' `' + propName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
}
for (var key in propValue) {
if (propValue.hasOwnProperty(key)) {
var error = typeChecker(propValue, key, componentName, location);
var error = typeChecker(propValue, key, componentName, location, '' + propFullName + '.' + key);
if (error instanceof Error) {

@@ -221,6 +222,6 @@ return error;

function createUnionTypeChecker(arrayOfTypeCheckers) {
function validate(props, propName, componentName, location) {
function validate(props, propName, componentName, location, propFullName) {
for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
var checker = arrayOfTypeCheckers[i];
if (checker(props, propName, componentName, location) == null) {
if (checker(props, propName, componentName, location, propFullName) == null) {
return null;

@@ -231,3 +232,3 @@ }

var locationName = ReactPropTypeLocationNames[location];
return new Error('Invalid ' + locationName + ' `' + propName + '` supplied to ' + ('`' + componentName + '`.'));
return new Error('Invalid ' + locationName + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
}

@@ -238,6 +239,6 @@ return createChainableTypeChecker(validate);

function createNodeChecker() {
function validate(props, propName, componentName, location) {
function validate(props, propName, componentName, location, propFullName) {
if (!isNode(props[propName])) {
var locationName = ReactPropTypeLocationNames[location];
return new Error('Invalid ' + locationName + ' `' + propName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
return new Error('Invalid ' + locationName + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
}

@@ -250,3 +251,3 @@ return null;

function createShapeTypeChecker(shapeTypes) {
function validate(props, propName, componentName, location) {
function validate(props, propName, componentName, location, propFullName) {
var propValue = props[propName];

@@ -256,3 +257,3 @@ var propType = getPropType(propValue);

var locationName = ReactPropTypeLocationNames[location];
return new Error('Invalid ' + locationName + ' `' + propName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
}

@@ -264,3 +265,3 @@ for (var key in shapeTypes) {

}
var error = checker(propValue, key, componentName, location);
var error = checker(propValue, key, componentName, location, '' + propFullName + '.' + key);
if (error) {

@@ -267,0 +268,0 @@ return error;

@@ -12,4 +12,2 @@ /**

/*jslint bitwise: true*/
'use strict';

@@ -16,0 +14,0 @@

@@ -84,3 +84,2 @@ /**

* @param {!string} nameSoFar Name of the key path so far.
* @param {!number} indexSoFar Number of children encountered until this point.
* @param {!function} callback Callback to invoke with each child found.

@@ -91,3 +90,3 @@ * @param {?*} traverseContext Used to pass information throughout the traversal

*/
function traverseAllChildrenImpl(children, nameSoFar, indexSoFar, callback, traverseContext) {
function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) {
var type = typeof children;

@@ -104,7 +103,8 @@

// so that it's consistent if the number of children grows.
nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar, indexSoFar);
nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar);
return 1;
}
var child, nextName, nextIndex;
var child;
var nextName;
var subtreeCount = 0; // Count of children found in the current subtree.

@@ -116,4 +116,3 @@

nextName = (nameSoFar !== '' ? nameSoFar + SUBSEPARATOR : SEPARATOR) + getComponentKey(child, i);
nextIndex = indexSoFar + subtreeCount;
subtreeCount += traverseAllChildrenImpl(child, nextName, nextIndex, callback, traverseContext);
subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
}

@@ -130,4 +129,3 @@ } else {

nextName = (nameSoFar !== '' ? nameSoFar + SUBSEPARATOR : SEPARATOR) + getComponentKey(child, ii++);
nextIndex = indexSoFar + subtreeCount;
subtreeCount += traverseAllChildrenImpl(child, nextName, nextIndex, callback, traverseContext);
subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
}

@@ -145,4 +143,3 @@ } else {

nextName = (nameSoFar !== '' ? nameSoFar + SUBSEPARATOR : SEPARATOR) + wrapUserProvidedKey(entry[0]) + SUBSEPARATOR + getComponentKey(child, 0);
nextIndex = indexSoFar + subtreeCount;
subtreeCount += traverseAllChildrenImpl(child, nextName, nextIndex, callback, traverseContext);
subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
}

@@ -158,4 +155,3 @@ }

nextName = (nameSoFar !== '' ? nameSoFar + SUBSEPARATOR : SEPARATOR) + wrapUserProvidedKey(key) + SUBSEPARATOR + getComponentKey(child, 0);
nextIndex = indexSoFar + subtreeCount;
subtreeCount += traverseAllChildrenImpl(child, nextName, nextIndex, callback, traverseContext);
subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
}

@@ -190,5 +186,5 @@ }

return traverseAllChildrenImpl(children, '', 0, callback, traverseContext);
return traverseAllChildrenImpl(children, '', callback, traverseContext);
}
module.exports = traverseAllChildren;

@@ -14,2 +14,3 @@ /**

var assign = require("./Object.assign");
var emptyFunction = require("./emptyFunction");

@@ -35,28 +36,2 @@ var warning = require("./warning");

/**
* Return whether `stack` contains `tag` and the last occurrence of `tag` is
* deeper than any element in the `scope` array.
*
* https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-the-specific-scope
*
* Examples:
* stackHasTagInSpecificScope(['p', 'quote'], 'p', ['button']) is true
* stackHasTagInSpecificScope(['p', 'button'], 'p', ['button']) is false
*
* @param {Array<string>} stack
* @param {string} tag
* @param {Array<string>} scope
*/
var stackHasTagInSpecificScope = function (stack, tag, scope) {
for (var i = stack.length - 1; i >= 0; i--) {
if (stack[i] === tag) {
return true;
}
if (scope.indexOf(stack[i]) !== -1) {
return false;
}
}
return false;
};
// https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-scope

@@ -66,47 +41,78 @@ var inScopeTags = ['applet', 'caption', 'html', 'table', 'td', 'th', 'marquee', 'object', 'template',

// https://html.spec.whatwg.org/multipage/syntax.html#html-integration-point
// TODO: Distinguish by namespace here
// TODO: Distinguish by namespace here -- for <title>, including it here
// errs on the side of fewer warnings
'foreignObject', 'desc', 'title'];
var stackHasTagInScope = function (stack, tag) {
return stackHasTagInSpecificScope(stack, tag, inScopeTags);
};
// https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-button-scope
var buttonScopeTags = inScopeTags.concat(['button']);
var stackHasTagInButtonScope = function (stack, tag) {
return stackHasTagInSpecificScope(stack, tag, buttonScopeTags);
// https://html.spec.whatwg.org/multipage/syntax.html#generate-implied-end-tags
var impliedEndTags = ['dd', 'dt', 'li', 'option', 'optgroup', 'p', 'rp', 'rt'];
var emptyAncestorInfo = {
parentTag: null,
formTag: null,
aTagInScope: null,
buttonTagInScope: null,
nobrTagInScope: null,
pTagInButtonScope: null,
listItemTagAutoclosing: null,
dlItemTagAutoclosing: null
};
// See rules for 'li', 'dd', 'dt' start tags in
// https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody
var listItemTagAllowed = function (tags, stack) {
// tags is ['li'] or ['dd, 'dt']
for (var i = stack.length - 1; i >= 0; i--) {
if (tags.indexOf(stack[i]) !== -1) {
return false;
} else if (specialTags.indexOf(stack[i]) !== -1 && stack[i] !== 'address' && stack[i] !== 'div' && stack[i] !== 'p') {
return true;
}
var updatedAncestorInfo = function (oldInfo, tag, instance) {
var ancestorInfo = assign({}, oldInfo || emptyAncestorInfo);
var info = { tag: tag, instance: instance };
if (inScopeTags.indexOf(tag) !== -1) {
ancestorInfo.aTagInScope = null;
ancestorInfo.buttonTagInScope = null;
ancestorInfo.nobrTagInScope = null;
}
return true;
if (buttonScopeTags.indexOf(tag) !== -1) {
ancestorInfo.pTagInButtonScope = null;
}
// See rules for 'li', 'dd', 'dt' start tags in
// https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody
if (specialTags.indexOf(tag) !== -1 && tag !== 'address' && tag !== 'div' && tag !== 'p') {
ancestorInfo.listItemTagAutoclosing = null;
ancestorInfo.dlItemTagAutoclosing = null;
}
ancestorInfo.parentTag = info;
if (tag === 'form') {
ancestorInfo.formTag = info;
}
if (tag === 'a') {
ancestorInfo.aTagInScope = info;
}
if (tag === 'button') {
ancestorInfo.buttonTagInScope = info;
}
if (tag === 'nobr') {
ancestorInfo.nobrTagInScope = info;
}
if (tag === 'p') {
ancestorInfo.pTagInButtonScope = info;
}
if (tag === 'li') {
ancestorInfo.listItemTagAutoclosing = info;
}
if (tag === 'dd' || tag === 'dt') {
ancestorInfo.dlItemTagAutoclosing = info;
}
return ancestorInfo;
};
// https://html.spec.whatwg.org/multipage/syntax.html#generate-implied-end-tags
var impliedEndTags = ['dd', 'dt', 'li', 'option', 'optgroup', 'p', 'rp', 'rt'];
/**
* Returns whether we allow putting `tag` in the document if the current stack
* of open tags is `openTagStack`.
*
* Examples:
* isTagValidInContext('tr', [..., 'table', 'tbody']) is true
* isTagValidInContext('tr', [..., 'table']) is false
*
* @param {string} tag Lowercase HTML tag name or node name like '#text'
* @param {Array<string>} openTagStack
* Returns whether
*/
var isTagValidInContext = function (tag, openTagStack) {
var currentTag = openTagStack[openTagStack.length - 1];
var isTagValidWithParent = function (tag, parentTag) {
// First, let's check if we're in an unusual parsing mode...
switch (currentTag) {
switch (parentTag) {
// https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inselect

@@ -158,2 +164,40 @@ case 'select':

switch (tag) {
case 'h1':
case 'h2':
case 'h3':
case 'h4':
case 'h5':
case 'h6':
return parentTag !== 'h1' && parentTag !== 'h2' && parentTag !== 'h3' && parentTag !== 'h4' && parentTag !== 'h5' && parentTag !== 'h6';
case 'rp':
case 'rt':
return impliedEndTags.indexOf(parentTag) === -1;
case 'caption':
case 'col':
case 'colgroup':
case 'frame':
case 'head':
case 'tbody':
case 'td':
case 'tfoot':
case 'th':
case 'thead':
case 'tr':
// These tags are only valid with a few parents that have special child
// parsing rules -- if we're down here, then none of those matched and
// so we allow it only if we don't know what the parent is, as all other
// cases are invalid.
return parentTag == null;
}
return true;
};
/**
* Returns whether
*/
var findInvalidAncestorForTag = function (tag, ancestorInfo) {
switch (tag) {
case 'address':

@@ -192,3 +236,2 @@ case 'article':

case 'xmp':
return !stackHasTagInButtonScope(openTagStack, 'p');

@@ -201,16 +244,16 @@ case 'h1':

case 'h6':
return !stackHasTagInButtonScope(openTagStack, 'p') && currentTag !== 'h1' && currentTag !== 'h2' && currentTag !== 'h3' && currentTag !== 'h4' && currentTag !== 'h5' && currentTag !== 'h6';
return ancestorInfo.pTagInButtonScope;
case 'form':
return openTagStack.indexOf('form') === -1 && !stackHasTagInButtonScope(openTagStack, 'p');
return ancestorInfo.formTag || ancestorInfo.pTagInButtonScope;
case 'li':
return listItemTagAllowed(['li'], openTagStack);
return ancestorInfo.listItemTagAutoclosing;
case 'dd':
case 'dt':
return listItemTagAllowed(['dd', 'dt'], openTagStack);
return ancestorInfo.dlItemTagAutoclosing;
case 'button':
return !stackHasTagInScope(openTagStack, 'button');
return ancestorInfo.buttonTagInScope;

@@ -220,52 +263,100 @@ case 'a':

// equivalent to this check.
return !stackHasTagInScope(openTagStack, 'a');
return ancestorInfo.aTagInScope;
case 'nobr':
return !stackHasTagInScope(openTagStack, 'nobr');
return ancestorInfo.nobrTagInScope;
}
case 'rp':
case 'rt':
return impliedEndTags.indexOf(currentTag) === -1;
return null;
};
case 'caption':
case 'col':
case 'colgroup':
case 'frame':
case 'head':
case 'tbody':
case 'td':
case 'tfoot':
case 'th':
case 'thead':
case 'tr':
return currentTag === undefined;
/**
* Given a ReactCompositeComponent instance, return a list of its recursive
* owners, starting at the root and ending with the instance itself.
*/
var findOwnerStack = function (instance) {
if (!instance) {
return [];
}
return true;
var stack = [];
/*eslint-disable space-after-keywords */
do {
/*eslint-enable space-after-keywords */
stack.push(instance);
} while (instance = instance._currentElement._owner);
stack.reverse();
return stack;
};
validateDOMNesting = function (parentStack, childTag, element) {
if (!isTagValidInContext(childTag, parentStack)) {
var info = '';
var parentTag = parentStack[parentStack.length - 1];
if (parentTag === 'table' && childTag === 'tr') {
info += ' Add a <tbody> to your code to match the DOM tree generated by ' + 'the browser.';
validateDOMNesting = function (childTag, childInstance, ancestorInfo) {
ancestorInfo = ancestorInfo || emptyAncestorInfo;
var parentInfo = ancestorInfo.parentTag;
var parentTag = parentInfo && parentInfo.tag;
var invalidParent = isTagValidWithParent(childTag, parentTag) ? null : parentInfo;
var invalidAncestor = invalidParent ? null : findInvalidAncestorForTag(childTag, ancestorInfo);
var problematic = invalidParent || invalidAncestor;
if (problematic) {
var ancestorTag = problematic.tag;
var ancestorInstance = problematic.instance;
var childOwner = childInstance && childInstance._currentElement._owner;
var ancestorOwner = ancestorInstance && ancestorInstance._currentElement._owner;
var childOwners = findOwnerStack(childOwner);
var ancestorOwners = findOwnerStack(ancestorOwner);
var minStackLen = Math.min(childOwners.length, ancestorOwners.length);
var i;
var deepestCommon = -1;
for (i = 0; i < minStackLen; i++) {
if (childOwners[i] === ancestorOwners[i]) {
deepestCommon = i;
} else {
break;
}
}
if (element && element._owner) {
var name = element._owner.getName();
if (name) {
info += ' Check the render method of `' + name + '`.';
var UNKNOWN = '(unknown)';
var childOwnerNames = childOwners.slice(deepestCommon + 1).map(function (inst) {
return inst.getName() || UNKNOWN;
});
var ancestorOwnerNames = ancestorOwners.slice(deepestCommon + 1).map(function (inst) {
return inst.getName() || UNKNOWN;
});
var ownerInfo = [].concat(
// If the parent and child instances have a common owner ancestor, start
// with that -- otherwise we just start with the parent's owners.
deepestCommon !== -1 ? childOwners[deepestCommon].getName() || UNKNOWN : [], ancestorOwnerNames, ancestorTag,
// If we're warning about an invalid (non-parent) ancestry, add '...'
invalidAncestor ? ['...'] : [], childOwnerNames, childTag).join(' > ');
if (invalidParent) {
var info = '';
if (ancestorTag === 'table' && childTag === 'tr') {
info += ' Add a <tbody> to your code to match the DOM tree generated by ' + 'the browser.';
}
'production' !== process.env.NODE_ENV ? warning(false, 'validateDOMNesting(...): <%s> cannot appear as a child of <%s>. ' + 'See %s.%s', childTag, ancestorTag, ownerInfo, info) : null;
} else {
'production' !== process.env.NODE_ENV ? warning(false, 'validateDOMNesting(...): <%s> cannot appear as a descendant of ' + '<%s>. See %s.', childTag, ancestorTag, ownerInfo) : null;
}
'production' !== process.env.NODE_ENV ? warning(false, 'validateDOMNesting(...): <%s> cannot appear as a child of <%s> ' + 'in this context (%s).%s', childTag, parentTag, parentStack.join(' > '), info) : null;
}
};
validateDOMNesting.tagStackContextKey = '__validateDOMNesting_tagStack$' + Math.random().toString(36).slice(2);
validateDOMNesting.ancestorInfoContextKey = '__validateDOMNesting_ancestorInfo$' + Math.random().toString(36).slice(2);
validateDOMNesting.updatedAncestorInfo = updatedAncestorInfo;
// For testing
validateDOMNesting.isTagValidInContext = isTagValidInContext;
validateDOMNesting.isTagValidInContext = function (tag, ancestorInfo) {
ancestorInfo = ancestorInfo || emptyAncestorInfo;
var parentInfo = ancestorInfo.parentTag;
var parentTag = parentInfo && parentInfo.tag;
return isTagValidWithParent(tag, parentTag) && !findInvalidAncestorForTag(tag, ancestorInfo);
};
}
module.exports = validateDOMNesting;
{
"name": "react",
"description": "React is a JavaScript library for building user interfaces.",
"version": "0.14.0-alpha1",
"version": "0.14.0-alpha2",
"keywords": [

@@ -6,0 +6,0 @@ "react"

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc