Browse Source

Fetch x-init after running onBeforeComponentInitialized

Samuel Štancl 4 năm trước cách đây
mục cha
commit
2bb7df5159
1 tập tin đã thay đổi với 2 bổ sung1 xóa
  1. 2 1
      src/component.js

+ 2 - 1
src/component.js

@@ -16,7 +16,6 @@ export default class Component {
 
         const dataAttr = this.$el.getAttribute('x-data')
         const dataExpression = dataAttr === '' ? '{}' : dataAttr
-        const initExpression = this.$el.getAttribute('x-init')
 
         let dataExtras = {
             $el: this.$el,
@@ -82,6 +81,8 @@ export default class Component {
         this.showDirectiveLastElement
 
         componentForClone || Alpine.onBeforeComponentInitializeds.forEach(callback => callback(this))
+        
+        const initExpression = this.$el.getAttribute('x-init')
 
         var initReturnedCallback
         // If x-init is present AND we aren't cloning (skip x-init on clone)