Compare commits

...

1 commit

6 changed files with 29 additions and 8 deletions

View file

@ -55,7 +55,7 @@
disabled: group_disabled === true ? group_disabled : option.disabled, disabled: group_disabled === true ? group_disabled : option.disabled,
group_array_index: group_position, group_array_index: group_position,
classes: option.className, classes: option.className,
style: option.style.cssText style: this.readAttr(option, "style")
}); });
} else { } else {
this.parsed.push({ this.parsed.push({
@ -67,6 +67,14 @@
return this.options_index += 1; return this.options_index += 1;
} }
}; };
SelectParser.prototype.readAttr = function(ele, attr) {
var res;
res = ele.getAttribute != null ? ele.getAttribute(attr) : ele[attr];
if (res) {
res.toLowerCase();
}
return res;
};
return SelectParser; return SelectParser;
})(); })();
SelectParser.select_to_array = function(select) { SelectParser.select_to_array = function(select) {
@ -153,7 +161,7 @@
if (option.classes !== "") { if (option.classes !== "") {
classes.push(option.classes); classes.push(option.classes);
} }
style = option.style.cssText !== "" ? " style=\"" + option.style + "\"" : ""; style = (option.style != null) && option.style !== "" ? " style=\"" + option.style + ";\"" : "";
return '<li id="' + option.dom_id + '" class="' + classes.join(' ') + '"' + style + '>' + option.html + '</li>'; return '<li id="' + option.dom_id + '" class="' + classes.join(' ') + '"' + style + '>' + option.html + '</li>';
} else { } else {
return ""; return "";

File diff suppressed because one or more lines are too long

View file

@ -55,7 +55,7 @@
disabled: group_disabled === true ? group_disabled : option.disabled, disabled: group_disabled === true ? group_disabled : option.disabled,
group_array_index: group_position, group_array_index: group_position,
classes: option.className, classes: option.className,
style: option.style.cssText style: this.readAttr(option, "style")
}); });
} else { } else {
this.parsed.push({ this.parsed.push({
@ -67,6 +67,14 @@
return this.options_index += 1; return this.options_index += 1;
} }
}; };
SelectParser.prototype.readAttr = function(ele, attr) {
var res;
res = ele.getAttribute != null ? ele.getAttribute(attr) : ele[attr];
if (res) {
res.toLowerCase();
}
return res;
};
return SelectParser; return SelectParser;
})(); })();
SelectParser.select_to_array = function(select) { SelectParser.select_to_array = function(select) {
@ -153,7 +161,7 @@
if (option.classes !== "") { if (option.classes !== "") {
classes.push(option.classes); classes.push(option.classes);
} }
style = option.style.cssText !== "" ? " style=\"" + option.style + "\"" : ""; style = (option.style != null) && option.style !== "" ? " style=\"" + option.style + ";\"" : "";
return '<li id="' + option.dom_id + '" class="' + classes.join(' ') + '"' + style + '>' + option.html + '</li>'; return '<li id="' + option.dom_id + '" class="' + classes.join(' ') + '"' + style + '>' + option.html + '</li>';
} else { } else {
return ""; return "";

File diff suppressed because one or more lines are too long

View file

@ -52,7 +52,7 @@ class AbstractChosen
classes.push "group-option" if option.group_array_index? classes.push "group-option" if option.group_array_index?
classes.push option.classes if option.classes != "" classes.push option.classes if option.classes != ""
style = if option.style.cssText != "" then " style=\"#{option.style}\"" else "" style = if option.style? && option.style != "" then " style=\"#{option.style};\"" else ""
'<li id="' + option.dom_id + '" class="' + classes.join(' ') + '"'+style+'>' + option.html + '</li>' '<li id="' + option.dom_id + '" class="' + classes.join(' ') + '"'+style+'>' + option.html + '</li>'
else else

View file

@ -35,7 +35,7 @@ class SelectParser
disabled: if group_disabled is true then group_disabled else option.disabled disabled: if group_disabled is true then group_disabled else option.disabled
group_array_index: group_position group_array_index: group_position
classes: option.className classes: option.className
style: option.style.cssText style: this.readAttr option, "style"
else else
@parsed.push @parsed.push
array_index: @parsed.length array_index: @parsed.length
@ -43,6 +43,11 @@ class SelectParser
empty: true empty: true
@options_index += 1 @options_index += 1
readAttr: (ele, attr) ->
res = if ele.getAttribute? then ele.getAttribute(attr) else ele[attr]
res.toLowerCase() if res
return res
SelectParser.select_to_array = (select) -> SelectParser.select_to_array = (select) ->
parser = new SelectParser() parser = new SelectParser()
parser.add_node( child ) for child in select.childNodes parser.add_node( child ) for child in select.childNodes