瀏覽代碼

fix usecase when a placeholder is not defined but an option with an empty value exists. fixes #1573

Igor Vaynberg 11 年之前
父節點
當前提交
4dce07a431
共有 1 個文件被更改,包括 5 次插入5 次删除
  1. 5 5
      select2.js

+ 5 - 5
select2.js

@@ -2083,11 +2083,11 @@ the specific language governing permissions and limitations under the Apache Lic
 
         isPlaceholderOptionSelected: function() {
             var placeholderOption;
-            return this.opts.placeholder &&
-                ((placeholderOption = this.getPlaceholderOption()) !== undefined && placeholderOption.is(':selected')) ||
-                   (this.opts.element.val() === "") ||
-                   (this.opts.element.val() === undefined) ||
-                   (this.opts.element.val() === null);
+            if (!this.opts.placeholder) return false; // no placeholder specified so no option should be considered
+            return ((placeholderOption = this.getPlaceholderOption()) !== undefined && placeholderOption.is(':selected'))
+                || (this.opts.element.val() === "")
+                || (this.opts.element.val() === undefined)
+                || (this.opts.element.val() === null);
         },
 
         // single