Skip to content

Commit 929952b

Browse files
committed
Use valid CSS selectors in useId format
1 parent defffdb commit 929952b

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

packages/react-debug-tools/src/__tests__/ReactHooksInspectionIntegration-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1553,7 +1553,7 @@ describe('ReactHooksInspectionIntegration', () => {
15531553
expect(tree[0].id).toEqual(0);
15541554
expect(tree[0].isStateEditable).toEqual(false);
15551555
expect(tree[0].name).toEqual('Id');
1556-
expect(String(tree[0].value).startsWith(':r')).toBe(true);
1556+
expect(String(tree[0].value).startsWith('\u00ABr')).toBe(true);
15571557

15581558
expect(normalizeSourceLoc(tree)[1]).toMatchInlineSnapshot(`
15591559
{

packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,7 @@ export function makeId(
820820
): string {
821821
const idPrefix = resumableState.idPrefix;
822822

823-
let id = ':' + idPrefix + 'R' + treeId;
823+
let id = '\u00AB' + idPrefix + 'R' + treeId;
824824

825825
// Unless this is the first id at this level, append a number at the end
826826
// that represents the position of this useId hook among all the useId
@@ -829,7 +829,7 @@ export function makeId(
829829
id += 'H' + localId.toString(32);
830830
}
831831

832-
return id + ':';
832+
return id + '\u00BB';
833833
}
834834

835835
function encodeHTMLTextNode(text: string): string {

packages/react-reconciler/src/ReactFiberHooks.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -3527,7 +3527,7 @@ function mountId(): string {
35273527
const treeId = getTreeId();
35283528

35293529
// Use a captial R prefix for server-generated ids.
3530-
id = ':' + identifierPrefix + 'R' + treeId;
3530+
id = '\u00AB' + identifierPrefix + 'R' + treeId;
35313531

35323532
// Unless this is the first id at this level, append a number at the end
35333533
// that represents the position of this useId hook among all the useId
@@ -3537,11 +3537,16 @@ function mountId(): string {
35373537
id += 'H' + localId.toString(32);
35383538
}
35393539

3540-
id += ':';
3540+
id += '\u00BB';
35413541
} else {
35423542
// Use a lowercase r prefix for client-generated ids.
35433543
const globalClientId = globalClientIdCounter++;
3544-
id = ':' + identifierPrefix + 'r' + globalClientId.toString(32) + ':';
3544+
id =
3545+
'\u00AB' +
3546+
identifierPrefix +
3547+
'r' +
3548+
globalClientId.toString(32) +
3549+
'\u00BB';
35453550
}
35463551

35473552
hook.memoizedState = id;

0 commit comments

Comments
 (0)