Skip to content

Safely access bare document in Preact 11 #5118

Description

@natemoo-re

Describe the feature you'd love to see
For an upcoming bomb.sh project, we'll be publishing Preact bindings for TUI projects. Because we're running in a non-browser environment, there is no global document variable.

To my great pleasure, I saw that Preact 11 has moved to scoped doc references that are dervied from node.ownerDocument.

This almost unburdens us from needing a globalThis.document shim. Unfortunately, there's still a single unguarded document reference in render.js.

Additional context
On our side, we need to define globalThis.document = undefined to avoid the ReferenceError (or wire a proper document shim).

If Preact 11 added a typeof document !== 'undefined' or 'document' in globalThis before checking if parentDom == document, we'd be able to remove our userland shim and Preact would be fully "native-compatible".

Fairly minimal change, but it would bring me great joy to contribute a fix here.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions