浏览代码

Correct isEmpty check for functions (#1496)

* BUGFIX: $h.isEmpty treat value = function() with zero args, as empty

due to value.length === 0 => https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/Function/length

isEmpty should check is the value of type "function" before check its length.

ex:

```
...
uploadUrl: function() { return ajax_url + '/upload/' + $el.data('id'); }
...
```

```self.isAjaxUpload = $h.hasFileUploadSupport() && !$h.isEmpty(self.uploadUrl); // => false, but must be true```

* Update fileinput.js

* Update fileinput.min.js
Illirgway 5 年之前
父节点
当前提交
1ec4dee0e7
共有 2 个文件被更改,包括 6 次插入2 次删除
  1. 6 2
      js/fileinput.js
  2. 0 0
      js/fileinput.min.js

+ 6 - 2
js/fileinput.js

@@ -211,8 +211,12 @@
                 $modal.appendTo($body);
             }
         },
+        // https://stackoverflow.com/a/6000016
+        isFunction: function (v) {
+            return !!(v && v.constructor && v.call && v.apply);
+        },
         isEmpty: function (value, trim) {
-            return value === undefined || value === null || value.length === 0 || (trim && $.trim(value) === '');
+            return value === undefined || value === null || (!$h.isFunction(value) && ( value.length === 0 || (trim && $.trim(value) === '')));
         },
         isArray: function (a) {
             return Array.isArray(a) || Object.prototype.toString.call(a) === '[object Array]';
@@ -5658,4 +5662,4 @@
             $input.fileinput();
         }
     });
-}));
+}));

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


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