Skip to content

Commit

Permalink
Separate root id + id part to avoid ambuigity
Browse files Browse the repository at this point in the history
  • Loading branch information
marvinhagemeister committed Oct 25, 2022
1 parent 2fdf1dd commit ff240e1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion hooks/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ export function useId() {
}

let mask = root._mask || (root._mask = [0, 0]);
state._value = 'P' + mask[0] + mask[1]++ + currentIndex;
state._value = 'P' + mask[0] + '-' + mask[1]++;
}

return state._value;
Expand Down
12 changes: 6 additions & 6 deletions hooks/test/browser/useId.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ describe('useId', () => {

render(<Comp />, scratch);
expect(scratch.innerHTML).to.equal(
'<div id="P001"><div id="P011"><span id="P022">h</span></div></div>'
'<div id="P0-0"><div id="P0-1"><span id="P0-2">h</span></div></div>'
);

render(<Comp />, scratch);
expect(scratch.innerHTML).to.equal(
'<div id="P001"><div id="P011"><span id="P022">h</span></div></div>'
'<div id="P0-0"><div id="P0-1"><span id="P0-2">h</span></div></div>'
);
});

Expand All @@ -83,12 +83,12 @@ describe('useId', () => {

render(<Comp />, scratch);
expect(scratch.innerHTML).to.equal(
'<div id="P001"><span id="P011">h</span><span id="P021">h</span><span id="P031">h</span></div>'
'<div id="P0-0"><span id="P0-1">h</span><span id="P0-2">h</span><span id="P0-3">h</span></div>'
);

render(<Comp />, scratch);
expect(scratch.innerHTML).to.equal(
'<div id="P001"><span id="P011">h</span><span id="P021">h</span><span id="P031">h</span></div>'
'<div id="P0-0"><span id="P0-1">h</span><span id="P0-2">h</span><span id="P0-3">h</span></div>'
);
});

Expand Down Expand Up @@ -121,13 +121,13 @@ describe('useId', () => {

render(<Comp />, scratch);
expect(scratch.innerHTML).to.equal(
'<div id="P001"><div><span id="P011">h</span></div></div>'
'<div id="P0-0"><div><span id="P0-1">h</span></div></div>'
);

set(true);
rerender();
expect(scratch.innerHTML).to.equal(
'<div id="P001"><div><span id="P011">h</span><span id="P021">h</span></div></div>'
'<div id="P0-0"><div><span id="P0-1">h</span><span id="P0-2">h</span></div></div>'
);
});

Expand Down

0 comments on commit ff240e1

Please sign in to comment.