gdotdesign / elm-ui

UI library for making web applications with Elm
https://elm-ui.netlify.com
BSD 2-Clause "Simplified" License
920 stars 39 forks source link

Set window to dummy object if not defined #78

Open bakkdoor opened 7 years ago

bakkdoor commented 7 years ago

This fixes an error when using elm-ui with rtfeldman/elm-css. Similar to e778f0aa1aff6cb62c9bc7434173725350947a0f

bakkdoor commented 7 years ago

A 1.2.2 release upon merge would be appreciated :) Related to #77

bakkdoor commented 7 years ago

I ran into this after trying to use the Ui.Input component.

bakkdoor commented 7 years ago

Not sure what the best way is to fix that CI failure. Looks like it can't find XMLHttpRequest now for some reason 😞

fosskers commented 7 years ago

This happens when importing certain modules, but not all. I use emacs's elm-mode, and importing Chooser or NotificationCenter gives me:

> import Day1 exposing (..)
/home/colin/code/horizon/aafa/ui/repl-temp-000.js:5916
    var styles = window.getComputedStyle(document.documentElement, '');
                 ^

ReferenceError: window is not defined
    at /home/colin/code/horizon/aafa/ui/repl-temp-000.js:5916:18
    at Object.<anonymous> (/home/colin/code/horizon/aafa/ui/repl-temp-000.js:5924:2)
    at Object.<anonymous> (/home/colin/code/horizon/aafa/ui/repl-temp-000.js:15243:4)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:423:7)

when I try to recompile my code in my embedded repl.

gdotdesign commented 7 years ago

This commit https://github.com/gdotdesign/elm-ui/commit/f983acf0e5f1c22b620b22458985a5142b07ae63 should fix the original issue, I'm not sure if would fix elm-mode errors.