Skip to content

preact/debug warnings not thrown because vnode.__k is not set #318

Open
@marvinhagemeister

Description

@marvinhagemeister

In preact/debug we have a branch for detecting invalid children being passed to a vnode:

vnode._children.forEach(child => {
  if (typeof child === 'object' && child && child.type === undefined) {
    const keys = Object.keys(child).join(',');
    throw new Error(
      `Objects are not valid as a child. Encountered an object with the keys {${keys}}.` +
      `\n\n${getOwnerStack(vnode)}`
    );
  }
});

But we never set that property when rendering on the server, so this check is never called.

Steps to reproduce

import "preact/debug";
import { renderToString } from "preact-render-to-string";

// This should throw
renderToString(<div>{{ foo: 123 }}</div>)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions