File tree 3 files changed +33
-2
lines changed
3 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -131,7 +131,7 @@ class AbstractChosen
131
131
132
132
group_el = document .createElement (" li" )
133
133
group_el .className = classes .join (" " )
134
- group_el .innerHTML = group .highlighted_html or group .label
134
+ group_el .innerHTML = group .highlighted_html or this . escape_html ( group .label )
135
135
group_el .title = group .title if group .title
136
136
137
137
this .outerHTML (group_el)
Original file line number Diff line number Diff line change @@ -47,7 +47,22 @@ describe "Searching", ->
47
47
expect (div .find (" .active-result" ).length ).toBe (1 )
48
48
expect (div .find (" .active-result" ).first ().html ()).toBe (" <em>A</em> & B" )
49
49
50
- it " renders optgroups correctly when they contain characters that require HTML encoding" , ->
50
+ it " renders optgroups correctly when they contain html encoded tags" , ->
51
+ div = $ (" <div>" ).html ("""
52
+ <select>
53
+ <optgroup label="A <b>hi</b> B">
54
+ <option value="Item">Item</option>
55
+ </optgroup>
56
+ </select>
57
+ """ )
58
+
59
+ div .find (" select" ).chosen ()
60
+ div .find (" .chosen-container" ).trigger (" mousedown" ) # open the drop
61
+
62
+ expect (div .find (" .group-result" ).length ).toBe (1 )
63
+ expect (div .find (" .group-result" ).first ().html ()).toBe (" A <b>hi</b> B" )
64
+
65
+ it " renders optgroups correctly when they contain characters that require HTML encoding when searching" , ->
51
66
div = $ (" <div>" ).html ("""
52
67
<select>
53
68
<optgroup label="A & B">
Original file line number Diff line number Diff line change @@ -51,6 +51,22 @@ describe "Searching", ->
51
51
expect (div .down (" .active-result" ).innerHTML ).toBe (" <em>A</em> & B" )
52
52
53
53
it " renders optgroups correctly when they contain characters that require HTML encoding" , ->
54
+ div = new Element (" div" )
55
+ div .update ("""
56
+ <select>
57
+ <optgroup label="A <b>hi</b> B">
58
+ <option value="Item">Item</option>
59
+ </optgroup>
60
+ </select>
61
+ """ )
62
+
63
+ new Chosen (div .down (" select" ))
64
+ simulant .fire (div .down (" .chosen-container" ), " mousedown" ) # open the drop
65
+
66
+ expect (div .select (" .group-result" ).length ).toBe (1 )
67
+ expect (div .down (" .group-result" ).innerHTML ).toBe (" A <b>hi</b> B" )
68
+
69
+ it " renders optgroups correctly when they contain characters that require HTML encoding when searching" , ->
54
70
div = new Element (" div" )
55
71
div .update ("""
56
72
<select>
You can’t perform that action at this time.
0 commit comments