浏览代码

Support selecting options with falsy values

Previously you could not select an option which had the number 0
as its value, because there was a check which would detect it as
an option without a value. There was a similar issue with selecting
options which had a blank string as the value.

This closes https://github.com/select2/select2/issues/4604.
This closes https://github.com/select2/select2/issues/4516.
This closes https://github.com/select2/select2/issues/3252.
This closes https://github.com/select2/select2/issues/3519.

This closes https://github.com/select2/select2/pull/4605.
This closes https://github.com/select2/select2/pull/4517.
Mike Dearman 8 年之前
父节点
当前提交
16b4840c0e
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      src/js/select2/data/select.js

+ 1 - 1
src/js/select2/data/select.js

@@ -170,7 +170,7 @@ define([
       }
       }
     }
     }
 
 
-    if (data.id) {
+    if (data.id !== undefined) {
       option.value = data.id;
       option.value = data.id;
     }
     }