Commit fe23841 1 parent 899e9d9 commit fe23841 Copy full SHA for fe23841
File tree 2 files changed +32
-0
lines changed
2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ let oldBeforeRender = options._render;
25
25
let oldAfterDiff = options . diffed ;
26
26
let oldCommit = options . _commit ;
27
27
let oldBeforeUnmount = options . unmount ;
28
+ let oldRoot = options . _root ;
28
29
29
30
const RAF_TIMEOUT = 100 ;
30
31
let prevRaf ;
@@ -35,6 +36,14 @@ options._diff = vnode => {
35
36
if ( oldBeforeDiff ) oldBeforeDiff ( vnode ) ;
36
37
} ;
37
38
39
+ options . _root = ( vnode , parentDom ) => {
40
+ if ( parentDom . _children && parentDom . _children . _mask ) {
41
+ vnode . _mask = parentDom . _children . _mask ;
42
+ }
43
+
44
+ if ( oldRoot ) oldRoot ( vnode , parentDom ) ;
45
+ } ;
46
+
38
47
/** @type {(vnode: import('./internal').VNode) => void } */
39
48
options . _render = vnode => {
40
49
if ( oldBeforeRender ) oldBeforeRender ( vnode ) ;
Original file line number Diff line number Diff line change @@ -433,4 +433,27 @@ describe('useId', () => {
433
433
rerender ( ) ;
434
434
expect ( first ) . not . to . equal ( scratch . innerHTML ) ;
435
435
} ) ;
436
+
437
+ it ( 'should return a unique id across invocations of render' , ( ) => {
438
+ const Id = ( ) => {
439
+ const id = useId ( ) ;
440
+ return < div > My id is { id } </ div > ;
441
+ } ;
442
+
443
+ const App = props => {
444
+ return (
445
+ < div >
446
+ < Id />
447
+ { props . secondId ? < Id /> : null }
448
+ </ div >
449
+ ) ;
450
+ } ;
451
+
452
+ render ( createElement ( App , { secondId : false } ) , scratch ) ;
453
+ expect ( scratch . innerHTML ) . to . equal ( '<div><div>My id is P0-0</div></div>' ) ;
454
+ render ( createElement ( App , { secondId : true } ) , scratch ) ;
455
+ expect ( scratch . innerHTML ) . to . equal (
456
+ '<div><div>My id is P0-0</div><div>My id is P0-1</div></div>'
457
+ ) ;
458
+ } ) ;
436
459
} ) ;
You can’t perform that action at this time.
0 commit comments