Browse Source

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 năm trước cách đây
mục cha
commit
16b4840c0e
1 tập tin đã thay đổi với 1 bổ sung1 xóa
  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;
     }