瀏覽代碼

replace .forEach with .some on x-bind checkbox

Reed Jones 5 年之前
父節點
當前提交
6a40aa9dde
共有 1 個文件被更改,包括 1 次插入8 次删除
  1. 1 8
      src/directives/bind.js

+ 1 - 8
src/directives/bind.js

@@ -23,14 +23,7 @@ export function handleAttributeBindingDirective(component, el, attrName, express
                 // I'm purposely not using Array.includes here because it's
                 // strict, and because of Numeric/String mis-casting, I
                 // want the "includes" to be "fuzzy".
-                let valueFound = false
-                value.forEach(val => {
-                    if (val == el.value) {
-                        valueFound = true
-                    }
-                })
-
-                el.checked = valueFound
+                el.checked = value.some(val => val == el.value)
             } else {
                 el.checked = !! value
             }