Skip to content

Commit 6112766

Browse files
committed
Update Float
1 parent 987bb1f commit 6112766

File tree

4 files changed

+38
-13
lines changed

4 files changed

+38
-13
lines changed

packages/react-dom/src/__tests__/ReactDOMFloat-test.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,10 @@ describe('ReactDOMFloat', () => {
250250
node.tagName !== 'TEMPLATE' &&
251251
node.tagName !== 'template' &&
252252
!node.hasAttribute('hidden') &&
253-
!node.hasAttribute('aria-hidden'))
253+
!node.hasAttribute('aria-hidden') &&
254+
// Ignore the render blocking expect
255+
(node.getAttribute('rel') !== 'expect' ||
256+
node.getAttribute('blocking') !== 'render'))
254257
) {
255258
const props = {};
256259
const attributes = node.attributes;
@@ -690,7 +693,9 @@ describe('ReactDOMFloat', () => {
690693
pipe(writable);
691694
});
692695
expect(chunks).toEqual([
693-
'<!DOCTYPE html><html><head><script async="" src="foo"></script><title>foo</title></head><body>bar',
696+
'<!DOCTYPE html><html><head><script async="" src="foo"></script>' +
697+
'<link rel="expect" href="#«R»" blocking="render"/><title>foo</title></head>' +
698+
'<body>bar<template id="«R»"></template>',
694699
'</body></html>',
695700
]);
696701
});

packages/react-dom/src/__tests__/ReactDOMLegacyFloat-test.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ describe('ReactDOMFloat', () => {
3434
);
3535

3636
expect(result).toEqual(
37-
'<html><head><meta charSet="utf-8"/><title>title</title><script src="foo"></script></head></html>',
37+
'<html><head><meta charSet="utf-8"/><link rel="expect" href="#«R»" blocking="render"/>' +
38+
'<title>title</title><script src="foo"></script></head><template id="«R»"></template></html>',
3839
);
3940
});
4041
});

packages/react-dom/src/__tests__/ReactDOMSingletonComponents-test.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,10 @@ describe('ReactDOM HostSingleton', () => {
104104
el.tagName !== 'TEMPLATE' &&
105105
el.tagName !== 'template' &&
106106
!el.hasAttribute('hidden') &&
107-
!el.hasAttribute('aria-hidden')) ||
107+
!el.hasAttribute('aria-hidden') &&
108+
// Ignore the render blocking expect
109+
(node.getAttribute('rel') !== 'expect' ||
110+
node.getAttribute('blocking') !== 'render')) ||
108111
el.hasAttribute('data-meaningful')
109112
) {
110113
const props = {};

packages/react-dom/src/__tests__/ReactRenderDocument-test.js

+25-9
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,16 @@ describe('rendering React components at document', () => {
7777
await act(() => {
7878
root = ReactDOMClient.hydrateRoot(testDocument, <Root hello="world" />);
7979
});
80-
expect(testDocument.body.innerHTML).toBe('Hello world');
80+
expect(testDocument.body.innerHTML).toBe(
81+
'Hello world' + '<template id="«R»"></template>',
82+
);
8183

8284
await act(() => {
8385
root.render(<Root hello="moon" />);
8486
});
85-
expect(testDocument.body.innerHTML).toBe('Hello moon');
87+
expect(testDocument.body.innerHTML).toBe(
88+
'Hello moon' + '<template id="«R»"></template>',
89+
);
8690

8791
expect(body === testDocument.body).toBe(true);
8892
});
@@ -107,7 +111,9 @@ describe('rendering React components at document', () => {
107111
await act(() => {
108112
root = ReactDOMClient.hydrateRoot(testDocument, <Root />);
109113
});
110-
expect(testDocument.body.innerHTML).toBe('Hello world');
114+
expect(testDocument.body.innerHTML).toBe(
115+
'Hello world' + '<template id="«R»"></template>',
116+
);
111117

112118
const originalDocEl = testDocument.documentElement;
113119
const originalHead = testDocument.head;
@@ -118,8 +124,10 @@ describe('rendering React components at document', () => {
118124
expect(testDocument.firstChild).toBe(originalDocEl);
119125
expect(testDocument.head).toBe(originalHead);
120126
expect(testDocument.body).toBe(originalBody);
121-
expect(originalBody.firstChild).toEqual(null);
122-
expect(originalHead.firstChild).toEqual(null);
127+
expect(originalBody.innerHTML).toBe('<template id="«R»"></template>');
128+
expect(originalHead.innerHTML).toBe(
129+
'<link rel="expect" href="#«R»" blocking="render">',
130+
);
123131
});
124132

125133
it('should not be able to switch root constructors', async () => {
@@ -157,13 +165,17 @@ describe('rendering React components at document', () => {
157165
root = ReactDOMClient.hydrateRoot(testDocument, <Component />);
158166
});
159167

160-
expect(testDocument.body.innerHTML).toBe('Hello world');
168+
expect(testDocument.body.innerHTML).toBe(
169+
'Hello world' + '<template id="«R»"></template>',
170+
);
161171

162172
await act(() => {
163173
root.render(<Component2 />);
164174
});
165175

166-
expect(testDocument.body.innerHTML).toBe('Goodbye world');
176+
expect(testDocument.body.innerHTML).toBe(
177+
'<template id="«R»"></template>' + 'Goodbye world',
178+
);
167179
});
168180

169181
it('should be able to mount into document', async () => {
@@ -192,7 +204,9 @@ describe('rendering React components at document', () => {
192204
);
193205
});
194206

195-
expect(testDocument.body.innerHTML).toBe('Hello world');
207+
expect(testDocument.body.innerHTML).toBe(
208+
'Hello world' + '<template id="«R»"></template>',
209+
);
196210
});
197211

198212
it('cannot render over an existing text child at the root', async () => {
@@ -325,7 +339,9 @@ describe('rendering React components at document', () => {
325339
: [],
326340
);
327341
expect(testDocument.body.innerHTML).toBe(
328-
favorSafetyOverHydrationPerf ? 'Hello world' : 'Goodbye world',
342+
favorSafetyOverHydrationPerf
343+
? 'Hello world'
344+
: 'Goodbye world<template id="«R»"></template>',
329345
);
330346
});
331347

0 commit comments

Comments
 (0)