Skip to content

NodeJS JSDOM support - ability to render on the backend #1424

@Darker

Description

@Darker

Would you like to work on this feature?

  • Check this if you would like to implement a PR, we are more than happy to help you go through the process.

What problem are you trying to solve?

I wanted to use this library to render a chart in an Express endpoint, or to a file.

Describe the solution you'd like

When I write code that manipulates DOM, I either have a optional argument for document or take document from element.ownerDocument if I am already taking an element as an argument. Similar solution would work here. This would require some changes to eliminate any global window and document references, but would help for two cases:

  1. Running this on the backend
  2. Trying to render chart in an iframe from the top level frame

Describe alternatives you've considered

I will try to mock window and document, but I don't think it is going to work.

Documentation, Adoption, Migration Strategy

Users should not notice a difference. The changes would only take an effect when the element is passed to chart constructor. In that case, that elements parent window and document would be used, instead of the globals.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions