You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Apparently, there is an empty? window object in the global namespace within the deno environment. I don't know why, other than deno is aiming towards creating a browser environment on the server (somewhat) for cross-compatible code. However, there is no default document-object/DOM.
Hence, in src/core/get-sheet.js
exportletgetSheet=(target)=>{if(typeofwindow==='object'){// THIS TRIGGERS AS TRUEreturn(...
Object.assign((target||document.head)...)// THIS CAUSES REFERENCE ERROR).firstChild;}
Note: It still works fine in node.js because node does not have a window object—and obviously the browser which has both.
I dealt with the exact same issue today. I fixed it in my use case by simply deleting the window object if the document object is undefined but the window object isn't.
EDIT: You can set the DENO_FUTURE=1 environment variable to disable the window global in Deno 1.42, and apparently it'll be removed altogether in version 2.
Error
Any attempt to render goober styles within a deno instance results in
ReferenceError: document is not defined
Environment
I'm the first to admit the problem might be a configuration problem on my end.
Steps to reproduce
deno run example.js
Investigation
Apparently, there is an empty?
window
object in the global namespace within the deno environment. I don't know why, other than deno is aiming towards creating a browser environment on the server (somewhat) for cross-compatible code. However, there is no defaultdocument
-object/DOM.Hence, in
src/core/get-sheet.js
Note: It still works fine in node.js because node does not have a
window
object—and obviously the browser which has both.Suggested Fix
I just don't know if that would break something somewhere, like if
target
has a passed value.Urgency
Low: For my own uses I cloned the repo and hacked a local copy, then bundled the official version for client-side. Doesn't help anyone else, but...
The text was updated successfully, but these errors were encountered: