Skip to content

Commit

Permalink
Fix SSR rendering of arrays and fragments for queue-streaming renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
jhsware committed Jan 28, 2020
1 parent c2339b2 commit bcc0b87
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions packages/inferno-server/src/renderToString.queuestream.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {EMPTY_OBJ} from 'inferno';
import {
combineFrom,
isArray,
isFunction,
isInvalid,
isNull,
Expand Down Expand Up @@ -281,6 +282,22 @@ export class RenderQueueStream extends Readable {
// Push text directly to queue
} else if ((flags & VNodeFlags.Text) > 0) {
this.addToQueue(children === '' ? ' ' : escapeText(children), position);
// Handle fragments and arrays
} else if (isArray(vNode) || (flags & VNodeFlags.Fragment) !== 0) {

const childFlags = vNode.childFlags;

if (childFlags === ChildFlags.HasVNodeChildren || (isArray(vNode) && vNode.length === 0)) {
this.addToQueue ('<!--!-->', position);
} else if (childFlags & ChildFlags.MultipleChildren || isArray(vNode)) {
const children = isArray(vNode) ? vNode : vNode.children;

for (let i = 0, len = children.length; i < len; ++i) {
this.renderVNodeToQueue(children[i], context, position);
}
return;
}

// Handle errors
} else {
if (process.env.NODE_ENV !== 'production') {
Expand Down

0 comments on commit bcc0b87

Please sign in to comment.