Skip to content

Fix references to the old ReactID syntax #973

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 31, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/core/ReactInstanceHandles.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,8 @@ var ReactInstanceHandles = {

/**
* Traverse a node ID, calling the supplied `cb` for each ancestor ID. For
* example, passing `.r[0].{row-0}.[1]` would result in `cb` getting called
* with `.r[0]`, `.r[0].{row-0}`, and `.r[0].{row-0}.[1]`.
* example, passing `.0.$row-0.1` would result in `cb` getting called
* with `.0`, `.0.$row-0`, and `.0.$row-0.1`.
*
* NOTE: This traversal happens on IDs without touching the DOM.
*
Expand Down
2 changes: 1 addition & 1 deletion src/core/ReactMount.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ function findDeepestCachedAncestor(targetID) {
* );
*
* <div id="container"> <-- Supplied `container`.
* <div data-reactid=".r[3]"> <-- Rendered reactRoot of React
* <div data-reactid=".3"> <-- Rendered reactRoot of React
* // ... component.
* </div>
* </div>
Expand Down
6 changes: 3 additions & 3 deletions src/core/__tests__/ReactEventEmitter-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ var ON_CHANGE_KEY = keyOf({onChange: null});
var CHILD = document.createElement('div');
var PARENT = document.createElement('div');
var GRANDPARENT = document.createElement('div');
setID(CHILD, '.reactRoot.[0].[0].[0]');
setID(PARENT, '.reactRoot.[0].[0]');
setID(GRANDPARENT, '.reactRoot.[0]');
setID(CHILD, '.0.0.0.0');
setID(PARENT, '.0.0.0');
setID(GRANDPARENT, '.0.0');

function registerSimpleTestHandler() {
ReactEventEmitter.putListener(getID(CHILD), ON_CLICK_KEY, LISTENER);
Expand Down
18 changes: 9 additions & 9 deletions src/core/__tests__/ReactInstanceHandles-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ describe('ReactInstanceHandles', function() {
parentNode.appendChild(childNodeA);
parentNode.appendChild(childNodeB);

ReactMount.setID(parentNode, '.react[0]');
ReactMount.setID(childNodeA, '.react[0].0');
ReactMount.setID(childNodeB, '.react[0].0:1');
ReactMount.setID(parentNode, '.0');
ReactMount.setID(childNodeA, '.0.0');
ReactMount.setID(childNodeB, '.0.0:1');

expect(
ReactMount.findComponentRoot(
Expand All @@ -110,9 +110,9 @@ describe('ReactInstanceHandles', function() {
parentNode.appendChild(childNodeA);
parentNode.appendChild(childNodeB);

ReactMount.setID(parentNode, '.react[0]');
ReactMount.setID(parentNode, '.0');
// No ID on `childNodeA`.
ReactMount.setID(childNodeB, '.react[0].0:1');
ReactMount.setID(childNodeB, '.0.0:1');

expect(
ReactMount.findComponentRoot(
Expand All @@ -129,9 +129,9 @@ describe('ReactInstanceHandles', function() {
parentNode.appendChild(childNodeA);
childNodeA.appendChild(childNodeB);

ReactMount.setID(parentNode, '.react[0]');
ReactMount.setID(parentNode, '.0');
// No ID on `childNodeA`, it was "rendered by the browser".
ReactMount.setID(childNodeB, '.react[0].1:0');
ReactMount.setID(childNodeB, '.0.1:0');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So are these tests not actually testing anything?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zpao Work computer bugged out so I can't access it from home, they're OK I think, it's just that the ID they set is (basically) irrelevant.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see now. That's deceptive.


expect(ReactMount.findComponentRoot(
parentNode,
Expand All @@ -144,10 +144,10 @@ describe('ReactInstanceHandles', function() {
ReactMount.getID(childNodeB) + ":junk"
);
}).toThrow(
'Invariant Violation: findComponentRoot(..., .react[0].1:0:junk): ' +
'Invariant Violation: findComponentRoot(..., .0.1:0:junk): ' +
'Unable to find element. This probably means the DOM was ' +
'unexpectedly mutated (e.g., by the browser). Try inspecting the ' +
'child nodes of the element with React ID `.react[0]`.'
'child nodes of the element with React ID `.0`.'
);
});
});
Expand Down
2 changes: 1 addition & 1 deletion src/core/__tests__/ReactMultiChildReconcile-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var stripEmptyValues = function(obj) {
};

/**
* Child key names are wrapped like '{key}[0]'. We strip the extra chars out
* Child key names are wrapped like '.$key:0'. We strip the extra chars out
* here. This relies on an implementation detail of the rendering system.
*/
var getOriginalKey = function(childName) {
Expand Down
6 changes: 3 additions & 3 deletions src/eventPlugins/__tests__/ResponderEventPlugin-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ var ReactInstanceHandles;
var ResponderEventPlugin;
var SyntheticEvent;

var GRANDPARENT_ID = '.r[0]';
var PARENT_ID = '.r[0].0';
var CHILD_ID = '.r[0].0.0';
var GRANDPARENT_ID = '.0';
var PARENT_ID = '.0.0';
var CHILD_ID = '.0.0.0';

var topLevelTypes;
var responderEventTypes;
Expand Down
8 changes: 4 additions & 4 deletions src/test/ReactDefaultPerf.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ if (__DEV__) {
* Runs through the logs and builds an array of arrays, where each array
* walks through the mounting/updating of each component underneath.
*
* @param {string} rootID The reactID of the root node, e.g. '.r[2cpyq]'
* @param {string} rootID The reactID of the root node, e.g. '.0'
* @return {array<array>}
*/
getRawRenderHistory: function(rootID) {
Expand Down Expand Up @@ -94,7 +94,7 @@ if (__DEV__) {
* is a multiline formatted way of walking through the mounting/updating
* underneath.
*
* @param {string} rootID The reactID of the root node, e.g. '.r[2cpyq]'
* @param {string} rootID The reactID of the root node, e.g. '.0'
* @return {array<string>}
*/
getRenderHistory: function(rootID) {
Expand All @@ -107,7 +107,7 @@ if (__DEV__) {
);
return headerString + subHistory.map(function(log) {
// Add two spaces for every layer in the reactID.
var indents = '\t' + Array(log.reactID.split('.[').length).join(' ');
var indents = '\t' + Array(log.reactID.split('.').length).join(' ');
var delta = _microTime(log.timing.delta);
var bloat = _microTime(log.timing.timeToLog);

Expand All @@ -122,7 +122,7 @@ if (__DEV__) {
* This is currently the best way to display perf data from
* any React component; working on that.
*
* @param {string} rootID The reactID of the root node, e.g. '.r[2cpyq]'
* @param {string} rootID The reactID of the root node, e.g. '.0'
* @param {number} index
*/
printRenderHistory: function(rootID, index) {
Expand Down