diff --git a/coffee/lib/abstract-chosen.coffee b/coffee/lib/abstract-chosen.coffee index b42391f0104..a83c194f826 100644 --- a/coffee/lib/abstract-chosen.coffee +++ b/coffee/lib/abstract-chosen.coffee @@ -131,7 +131,7 @@ class AbstractChosen group_el = document.createElement("li") group_el.className = classes.join(" ") - group_el.innerHTML = group.highlighted_html or group.label + group_el.innerHTML = group.highlighted_html or this.escape_html(group.label) group_el.title = group.title if group.title this.outerHTML(group_el) diff --git a/spec/jquery/searching.spec.coffee b/spec/jquery/searching.spec.coffee index 7368ad8378b..d17f62f85bc 100644 --- a/spec/jquery/searching.spec.coffee +++ b/spec/jquery/searching.spec.coffee @@ -47,7 +47,22 @@ describe "Searching", -> expect(div.find(".active-result").length).toBe(1) expect(div.find(".active-result").first().html()).toBe("A & B") - it "renders optgroups correctly when they contain characters that require HTML encoding", -> + it "renders optgroups correctly when they contain html encoded tags", -> + div = $("
").html(""" + + """) + + div.find("select").chosen() + div.find(".chosen-container").trigger("mousedown") # open the drop + + expect(div.find(".group-result").length).toBe(1) + expect(div.find(".group-result").first().html()).toBe("A <b>hi</b> B") + + it "renders optgroups correctly when they contain characters that require HTML encoding when searching", -> div = $("
").html(""" + + + + + """) + + new Chosen(div.down("select")) + simulant.fire(div.down(".chosen-container"), "mousedown") # open the drop + + expect(div.select(".group-result").length).toBe(1) + expect(div.down(".group-result").innerHTML).toBe("A <b>hi</b> B") + + it "renders optgroups correctly when they contain characters that require HTML encoding when searching", -> div = new Element("div") div.update("""