phoenixframework / phoenix_live_reload

Provides live-reload functionality for Phoenix
MIT License
315 stars 90 forks source link

Update css reload strategy #153

Closed walkr closed 6 months ago

walkr commented 6 months ago

Live reload was not loading on css changes. This update seems to fix it.

Bug

kolen commented 6 months ago

Another way is to add semicolon after querySelectorAll(...)

--- a/priv/static/phoenix_live_reload.js
+++ b/priv/static/phoenix_live_reload.js
@@ -28,7 +28,7 @@ let repaint = () => {
 let cssStrategy = () => {
   let reloadableLinkElements = window.parent.document.querySelectorAll(
     "link[rel=stylesheet]:not([data-no-reload]):not([data-pending-removal])"
-  )
+  );

   ([].slice).call(reloadableLinkElements)
     .filter(link => link.href)

This fixes this problem for me.

The issue is that without semicolon ([].slice) is parsed as continuation of let, and it tries to call what querySelectorAll returned as a function with [].slice argument.

walkr commented 6 months ago

@kolen Ah, gotcha! Thank you for the explanation!

chrismccord commented 6 months ago

❤️❤️❤️🐥🔥