Browse Source

Fix "Invalid invocation" error when referencing $refs

Caleb Porzio 5 năm trước cách đây
mục cha
commit
486a37261a
5 tập tin đã thay đổi với 9 bổ sung2 xóa
  1. 1 1
      README.md
  2. 0 0
      dist/alpine.js
  3. 0 0
      dist/alpine.js.map
  4. 1 1
      package.json
  5. 7 0
      src/component.js

+ 1 - 1
README.md

@@ -12,7 +12,7 @@ Think of it like [Tailwind](https://tailwindcss.com/) for JavaScript.
 
 **From CDN:** Add the following script to the end of your `<head>` section.
 ```html
-<script src="https://cdn.jsdelivr.net/gh/alpinejs/alpine@v1.3.0/dist/alpine.js" defer></script>
+<script src="https://cdn.jsdelivr.net/gh/alpinejs/alpine@v1.3.1/dist/alpine.js" defer></script>
 ```
 
 That's it. It will initialize itself.

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 0
dist/alpine.js


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 0
dist/alpine.js.map


+ 1 - 1
package.json

@@ -1,7 +1,7 @@
 {
   "main": "dist/alpine.js",
   "name": "alpinejs",
-  "version": "1.3.0",
+  "version": "1.3.1",
   "repository": {
     "type": "git",
     "url": "git://github.com/alpinejs/alpine.git"

+ 7 - 0
src/component.js

@@ -41,6 +41,11 @@ export default class Component {
                 return setWasSuccessful
             },
             get(target, key) {
+                if (key === 'isProxy') return true
+
+                // If the property we are trying to get is a proxy, just return it.
+                if (target[key] && target[key].isProxy) return target[key]
+
                 if (typeof target[key] === 'object' && target[key] !== null) {
                     const propertyName = keyPrefix ? `${keyPrefix}.${key}` : key
 
@@ -421,6 +426,8 @@ export default class Component {
         // For this reason, I'm using an "on-demand" proxy to fake a "$refs" object.
         return new Proxy({}, {
             get(object, property) {
+                if (property === 'isProxy') return true
+
                 var ref
 
                 // We can't just query the DOM because it's hard to filter out refs in

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác