Caleb Porzio 2 年之前
父節點
當前提交
394edf0057
共有 2 個文件被更改,包括 8 次插入2 次删除
  1. 2 2
      packages/alpinejs/src/evaluator.js
  2. 6 0
      packages/navigate/src/index.js

+ 2 - 2
packages/alpinejs/src/evaluator.js

@@ -68,9 +68,9 @@ function generateFunctionFromString(expression, el) {
     // calling function so that we don't throw an error AND a "return" statement can b e used.
     // calling function so that we don't throw an error AND a "return" statement can b e used.
     let rightSideSafeExpression = 0
     let rightSideSafeExpression = 0
         // Support expressions starting with "if" statements like: "if (...) doSomething()"
         // Support expressions starting with "if" statements like: "if (...) doSomething()"
-        || /^[\n\s]*if.*\(.*\)/.test(expression)
+        || /^[\n\s]*if.*\(.*\)/.test(expression.trim())
         // Support expressions starting with "let/const" like: "let foo = 'bar'"
         // Support expressions starting with "let/const" like: "let foo = 'bar'"
-        || /^(let|const)\s/.test(expression)
+        || /^(let|const)\s/.test(expression.trim())
             ? `(async()=>{ ${expression} })()`
             ? `(async()=>{ ${expression} })()`
             : expression
             : expression
 
 

+ 6 - 0
packages/navigate/src/index.js

@@ -104,6 +104,12 @@ export default function (Alpine) {
 
 
         })
         })
     })
     })
+
+    // Because DOMContentLoaded is fired on first load,
+    // we should fire alpine:navigated as a replacement as well...
+    setTimeout(() => {
+        fireEventForOtherLibariesToHookInto()
+    })
 }
 }
 
 
 function fetchHtmlOrUsePrefetchedHtml(fromDestination, callback) {
 function fetchHtmlOrUsePrefetchedHtml(fromDestination, callback) {