mirror of
https://github.com/facebook/react.git
synced 2026-11-18 20:15:56 +00:00
ID not Id
This commit is contained in:
1 parent
6c0ab0b60e
commit
7032e88c25
4 files changed
+27
-27
No files matched your search
@@ -22,7 +22,7 @@ var invariant = require('invariant');
|
||||
var setInnerHTML = require('setInnerHTML');
|
||||
|
||||
/**
|
||||
* Errors for properties that should not be updated with `updatePropertyById()`.
|
||||
* Errors for properties that should not be updated with `updatePropertyByID()`.
|
||||
*
|
||||
* @type {object}
|
||||
* @private
|
||||
|
||||
@@ -106,13 +106,13 @@ function handleTopLevelWithPath(bookKeeping) {
|
||||
var currentNativeTarget = path[0];
|
||||
for (var i = 0; i < path.length; i++) {
|
||||
var currentPathElement = path[i];
|
||||
var currentPathElemenId = ReactMount.getID(currentPathElement);
|
||||
var currentPathElemenID = ReactMount.getID(currentPathElement);
|
||||
if (currentPathElement.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE) {
|
||||
currentNativeTarget = path[i + 1];
|
||||
}
|
||||
if (ReactMount.isRenderedByReact(currentPathElement)) {
|
||||
var newRootId = ReactInstanceHandles.getReactRootIDFromNodeID(
|
||||
currentPathElemenId
|
||||
var newRootID = ReactInstanceHandles.getReactRootIDFromNodeID(
|
||||
currentPathElemenID
|
||||
);
|
||||
bookKeeping.ancestors.push(currentPathElement);
|
||||
|
||||
@@ -126,10 +126,10 @@ function handleTopLevelWithPath(bookKeeping) {
|
||||
);
|
||||
|
||||
// Jump to the root of this React render tree
|
||||
while (currentPathElemenId !== newRootId) {
|
||||
while (currentPathElemenID !== newRootID) {
|
||||
i++;
|
||||
currentPathElement = path[i];
|
||||
currentPathElemenId = ReactMount.getID(currentPathElement);
|
||||
currentPathElemenID = ReactMount.getID(currentPathElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,9 +27,9 @@ describe('ReactIdentity', function() {
|
||||
});
|
||||
|
||||
var idExp = /^\.[^.]+(.*)$/;
|
||||
function checkId(child, expectedId) {
|
||||
function checkID(child, expectedID) {
|
||||
var actual = idExp.exec(ReactMount.getID(child));
|
||||
var expected = idExp.exec(expectedId);
|
||||
var expected = idExp.exec(expectedID);
|
||||
expect(actual).toBeTruthy();
|
||||
expect(expected).toBeTruthy();
|
||||
expect(actual[1]).toEqual(expected[1]);
|
||||
@@ -51,8 +51,8 @@ describe('ReactIdentity', function() {
|
||||
instance = React.render(instance, document.createElement('div'));
|
||||
var node = React.findDOMNode(instance);
|
||||
expect(node.childNodes.length).toBe(2);
|
||||
checkId(node.childNodes[0], '.0.$first:0');
|
||||
checkId(node.childNodes[1], '.0.$second:0');
|
||||
checkID(node.childNodes[0], '.0.$first:0');
|
||||
checkID(node.childNodes[1], '.0.$second:0');
|
||||
});
|
||||
|
||||
it('should allow key property to express identity', function() {
|
||||
@@ -67,10 +67,10 @@ describe('ReactIdentity', function() {
|
||||
instance = React.render(instance, document.createElement('div'));
|
||||
var node = React.findDOMNode(instance);
|
||||
expect(node.childNodes.length).toBe(4);
|
||||
checkId(node.childNodes[0], '.0.$apple');
|
||||
checkId(node.childNodes[1], '.0.$banana');
|
||||
checkId(node.childNodes[2], '.0.$0');
|
||||
checkId(node.childNodes[3], '.0.$123');
|
||||
checkID(node.childNodes[0], '.0.$apple');
|
||||
checkID(node.childNodes[1], '.0.$banana');
|
||||
checkID(node.childNodes[2], '.0.$0');
|
||||
checkID(node.childNodes[3], '.0.$123');
|
||||
});
|
||||
|
||||
it('should use instance identity', function() {
|
||||
@@ -92,12 +92,12 @@ describe('ReactIdentity', function() {
|
||||
var node = React.findDOMNode(instance);
|
||||
expect(node.childNodes.length).toBe(3);
|
||||
|
||||
checkId(node.childNodes[0], '.0.$wrap1');
|
||||
checkId(node.childNodes[0].firstChild, '.0.$wrap1.$squirrel');
|
||||
checkId(node.childNodes[1], '.0.$wrap2');
|
||||
checkId(node.childNodes[1].firstChild, '.0.$wrap2.$bunny');
|
||||
checkId(node.childNodes[2], '.0.2');
|
||||
checkId(node.childNodes[2].firstChild, '.0.2.$chipmunk');
|
||||
checkID(node.childNodes[0], '.0.$wrap1');
|
||||
checkID(node.childNodes[0].firstChild, '.0.$wrap1.$squirrel');
|
||||
checkID(node.childNodes[1], '.0.$wrap2');
|
||||
checkID(node.childNodes[1].firstChild, '.0.$wrap2.$bunny');
|
||||
checkID(node.childNodes[2], '.0.2');
|
||||
checkID(node.childNodes[2].firstChild, '.0.2.$chipmunk');
|
||||
});
|
||||
|
||||
function renderAComponentWithKeyIntoContainer(key, container) {
|
||||
@@ -124,8 +124,8 @@ describe('ReactIdentity', function() {
|
||||
|
||||
key = key.replace(/=/g, '=0');
|
||||
|
||||
checkId(React.findDOMNode(span1), '.0.$' + key);
|
||||
checkId(React.findDOMNode(span2), '.0.1:$' + key + ':0');
|
||||
checkID(React.findDOMNode(span1), '.0.$' + key);
|
||||
checkID(React.findDOMNode(span2), '.0.1:$' + key + ':0');
|
||||
}
|
||||
|
||||
it('should allow any character as a key, in a detached parent', function() {
|
||||
|
||||
@@ -189,21 +189,21 @@ function verifyDomOrderingAccurate(parentInstance, statusDisplays) {
|
||||
var containerNode = React.findDOMNode(parentInstance);
|
||||
var statusDisplayNodes = containerNode.childNodes;
|
||||
var i;
|
||||
var orderedDomIds = [];
|
||||
var orderedDomIDs = [];
|
||||
for (i = 0; i < statusDisplayNodes.length; i++) {
|
||||
orderedDomIds.push(ReactMount.getID(statusDisplayNodes[i]));
|
||||
orderedDomIDs.push(ReactMount.getID(statusDisplayNodes[i]));
|
||||
}
|
||||
|
||||
var orderedLogicalIds = [];
|
||||
var orderedLogicalIDs = [];
|
||||
var username;
|
||||
for (username in statusDisplays) {
|
||||
if (!statusDisplays.hasOwnProperty(username)) {
|
||||
continue;
|
||||
}
|
||||
var statusDisplay = statusDisplays[username];
|
||||
orderedLogicalIds.push(ReactInstanceMap.get(statusDisplay)._rootNodeID);
|
||||
orderedLogicalIDs.push(ReactInstanceMap.get(statusDisplay)._rootNodeID);
|
||||
}
|
||||
expect(orderedDomIds).toEqual(orderedLogicalIds);
|
||||
expect(orderedDomIDs).toEqual(orderedLogicalIDs);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user