Skip to content

Commit

Permalink
Merge pull request facebook#1419 from spicyj/inv-process
Browse files Browse the repository at this point in the history
Add clearer invariant in processUpdates
  • Loading branch information
chenglou committed Apr 17, 2014
2 parents e9c00b1 + 945d041 commit 13f799e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/browser/ui/dom/DOMChildrenOperations.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var Danger = require('Danger');
var ReactMultiChildUpdateTypes = require('ReactMultiChildUpdateTypes');

var getTextContentAccessor = require('getTextContentAccessor');
var invariant = require('invariant');

/**
* The DOM property to use when setting text content.
Expand Down Expand Up @@ -119,6 +120,17 @@ var DOMChildrenOperations = {
var updatedChild = update.parentNode.childNodes[updatedIndex];
var parentID = update.parentID;

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 <tbody> when using tables ' +
'or nesting <p> or <a> tags. Try inspecting the child nodes of the ' +
'element with React ID `%s`.',
updatedIndex,
parentID
);

initialChildren = initialChildren || {};
initialChildren[parentID] = initialChildren[parentID] || [];
initialChildren[parentID][updatedIndex] = updatedChild;
Expand Down

0 comments on commit 13f799e

Please sign in to comment.