Skip to content

Commit 02d6f9f

Browse files
committed
escape special characters in containerId selector
1 parent 3276e22 commit 02d6f9f

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

select2.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,7 @@
560560
this.container = this.createContainer();
561561

562562
this.containerId="s2id_"+(opts.element.attr("id") || "autogen"+nextUid());
563+
this.containerSelector="#"+this.containerId.replace(/([;&,\.\+\*\~':"\!\^#$%@\[\]\(\)=>\|])/g, '\\$1');
563564
this.container.attr("id", this.containerId);
564565

565566
// cache the body so future lookups are cheap
@@ -942,7 +943,7 @@
942943
*/
943944
// abstract
944945
opening: function() {
945-
var cid = this.containerId, selector = "#"+ cid.replace(/([;&,\.\+\*\~':"\!\^#$%@\[\]\(\)=>\|])/g, '\\$1'),
946+
var cid = this.containerId, selector = this.containerSelector,
946947
scroll = "scroll." + cid, resize = "resize." + cid;
947948

948949
this.container.parents().each(function() {

0 commit comments

Comments
 (0)