rmariuzzo / react-new-window

🔲 Pop new windows in React, using `window.open`.
https://rmariuzzo.github.io/react-new-window/
MIT License
442 stars 107 forks source link

New window does not have a defined DOCTYPE, so renders in quirks mode #155

Open RobRendell opened 1 year ago

RobRendell commented 1 year ago

The content of the new window does not copy the parent window's DOCTYPE, and as a result the contents are being rendered in quirks mode in Chrome (and probably other browsers).

Since create-react-app inserts <!DOCTYPE html> at the top of index.html, this can lead to inconsistencies in components rendered in the new window vs. rendered in the original app. For example, tables in quirks mode do not inherit their text colour from their parent, while in strict mode they do.

If it is not possible to automatically copy the DOCTYPE of the parent window, adding an optional "doctype" prop to NewWindow we can use to set the DOCTYPE in the new window manually might be another way to deal with this.