rlr/dotjs-addon

CSS isn't loaded if JS errors

keith opened this issue · 2 comments

keith commented

I noticed this interesting case that is possibly unintended.
If you have JS and CSS for a particular domain, and when loading the JS, it errors, the CSS will never be loaded.

This happens because when the eval fails, the entire load-scripts function bails. We could fix this with a try/catch like this:

diff --git i/data/dotjs.js w/data/dotjs.js
index 97aff6e..ec171ee 100644
--- i/data/dotjs.js
+++ w/data/dotjs.js
@@ -13,7 +13,11 @@
         }

         msg.js.forEach(function(script) {
-            eval(script);
+            try {
+                eval(script);
+            } catch(error) {
+                // Maybe log the error?
+            }
         });

         if (msg.coffee) {

For the JS, and coffee phases. I'm happy to submit a PR for this if it's something you think we should handle. Thanks!

rlr commented

sounds good! If you file the PR, I'll merge it. Thanks!

keith commented

Sorry I never got around to this, closing this now that it's marked as unmaintained.