Skip to content

Commit 389e0cf

Browse files
committed
Use valid CSS selectors in useId format
1 parent defffdb commit 389e0cf

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 8 additions & 3 deletions
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)