Skip to content

Commit f6c1356

Browse files
authored
Merge pull request #68 from preactjs/fix-ref-forwarding
Fix ref forwarding test
2 parents 1923336 + bca2cee commit f6c1356

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

test/lazy.test.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ describe('lazy', () => {
4444
});
4545

4646
it('should forward refs', async () => {
47-
const A = () => <h1>A</h1>;
47+
const A = (props) => <h1 ref={props.ref}>A</h1>;
4848
const LazyA = lazy(() => Promise.resolve(A));
4949

5050
const ref = {};
@@ -57,6 +57,13 @@ describe('lazy', () => {
5757
);
5858
await new Promise(r => setTimeout(r, 1))
5959

60-
expect(ref.current.constructor).to.equal(A);
60+
if (ref.current.constructor === A) {
61+
// v10
62+
expect(ref.current.constructor).to.equal(A);
63+
} else {
64+
// v11+
65+
expect(ref.current).to.equal(scratch.firstChild);
66+
}
6167
});
6268
});
69+

0 commit comments

Comments
 (0)