Procházet zdrojové kódy

Scope the change until after data methods are reactive

Kevin Batdorf před 4 roky
rodič
revize
39aee36458
1 změnil soubory, kde provedl 3 přidání a 1 odebrání
  1. 3 1
      src/component.js

+ 3 - 1
src/component.js

@@ -22,8 +22,10 @@ export default class Component {
             $el: this.$el,
         }
 
+        let canonicalComponentElementReference = componentForClone ? componentForClone.$el : this.$el
+
         Object.entries(Alpine.magicProperties).forEach(([name, callback]) => {
-            Object.defineProperty(dataExtras, `$${name}`, { get: function () { return callback(this.$el) } });
+            Object.defineProperty(dataExtras, `$${name}`, { get: function () { return callback(canonicalComponentElementReference) } });
         })
 
         this.unobservedData = componentForClone ? componentForClone.getUnobservedData() : saferEval(dataExpression, dataExtras)