Skip to content

Commit

Permalink
use shorter notation
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock committed Jan 15, 2025
1 parent 6017e2d commit 5b02ce4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
4 changes: 3 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,9 @@ function _renderToString(
try {
rendered = type.call(component, props, cctx);
} catch (e) {
if (asyncMode) vnode._suspended = true;
if (asyncMode) {
vnode._suspended = true;
}
throw e;
}
}
Expand Down
23 changes: 13 additions & 10 deletions test/compat/async.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('Async renderToString', () => {
</Suspense>
);

const expected = `<!-- $s --><div class="foo">bar</div><!-- /$s -->`;
const expected = `<!--$s--><div class="foo">bar</div><!--/$s-->`;

suspended.resolve();

Expand All @@ -40,7 +40,7 @@ describe('Async renderToString', () => {
</Suspense>
);

const expected = `<!-- $s --><!-- /$s --><div class="foo">bar</div>`;
const expected = `<!--$s--><!--/$s--><div class="foo">bar</div>`;

suspended.resolve();

Expand Down Expand Up @@ -73,7 +73,7 @@ describe('Async renderToString', () => {
</ul>
);

const expected = `<ul><!-- $s --><li>one</li><!-- $s --><li>two</li><!-- /$s --><li>three</li><!-- /$s --></ul>`;
const expected = `<ul><!--$s--><li>one</li><!--$s--><li>two</li><!--/$s--><li>three</li><!--/$s--></ul>`;

suspendedOne.resolve();
suspendedTwo.resolve();
Expand Down Expand Up @@ -109,7 +109,7 @@ describe('Async renderToString', () => {
</ul>
);

const expected = `<ul><!-- $s --><li>one</li><!-- $s --><li>two</li><!-- /$s --><li>three</li><!-- /$s --></ul>`;
const expected = `<ul><!--$s--><li>one</li><!--$s--><li>two</li><!--/$s--><li>three</li><!--/$s--></ul>`;

suspendedOne.resolve();
suspendedTwo.resolve();
Expand Down Expand Up @@ -152,7 +152,7 @@ describe('Async renderToString', () => {
</ul>
);

const expected = `<ul><!-- $s --><li>one</li><!-- $s --><li>two</li><!-- /$s --><!-- $s --><li>three</li><!-- /$s --><li>four</li><!-- /$s --></ul>`;
const expected = `<ul><!--$s--><li>one</li><!--$s--><li>two</li><!--/$s--><!--$s--><li>three</li><!--/$s--><li>four</li><!--/$s--></ul>`;

suspendedOne.resolve();
suspendedTwo.resolve();
Expand All @@ -164,7 +164,7 @@ describe('Async renderToString', () => {
expect(rendered).to.equal(expected);
});

it.only('should render JSX with deeply nested suspense boundaries', async () => {
it('should render JSX with deeply nested suspense boundaries', async () => {
const {
Suspender: SuspenderOne,
suspended: suspendedOne
Expand Down Expand Up @@ -199,7 +199,7 @@ describe('Async renderToString', () => {
</ul>
);

const expected = `<ul><!-- $s --><li>one</li><!-- $s --><li>two</li><!-- $s --><li>three</li><!-- /$s --><!-- /$s --><li>four</li><!-- /$s --></ul>`;
const expected = `<ul><!--$s--><li>one</li><!--$s--><li>two</li><!--$s--><li>three</li><!--/$s--><!--/$s--><li>four</li><!--/$s--></ul>`;

suspendedOne.resolve();
suspendedTwo.resolve();
Expand Down Expand Up @@ -243,7 +243,7 @@ describe('Async renderToString', () => {
</ul>
);

const expected = `<ul><!-- $s --><li>one</li><!-- /$s --><!-- $s --><li>two</li><!-- /$s --><!-- $s --><li>three</li><!-- /$s --></ul>`;
const expected = `<ul><!--$s--><li>one</li><!--/$s--><!--$s--><li>two</li><!--/$s--><!--$s--><li>three</li><!--/$s--></ul>`;

suspendedOne.resolve();
suspendedTwo.resolve();
Expand Down Expand Up @@ -303,7 +303,7 @@ describe('Async renderToString', () => {

suspended.resolve();
const rendered = await promise;
expect(rendered).to.equal('<!-- $s --><p>ok</p><!-- /$s -->');
expect(rendered).to.equal('<!--$s--><p>ok</p><!--/$s-->');
});

it('should work with an in-render suspension', async () => {
Expand Down Expand Up @@ -340,7 +340,10 @@ describe('Async renderToString', () => {
</Context.Provider>
);

expect(rendered).to.equal(`<div>2</div>`);
// Before we get to the actual DOM this suspends twice
expect(rendered).to.equal(
`<!--$s--><!--$s--><div>2</div><!--/$s--><!--/$s-->`
);
});

describe('dangerouslySetInnerHTML', () => {
Expand Down

0 comments on commit 5b02ce4

Please sign in to comment.