浏览代码

Fix "Invalid invocation" error when referencing $refs

Caleb Porzio 5 年之前
父节点
当前提交
486a37261a
共有 5 个文件被更改,包括 9 次插入2 次删除
  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.

文件差异内容过多而无法显示
+ 0 - 0
dist/alpine.js


文件差异内容过多而无法显示
+ 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

部分文件因为文件数量过多而无法显示