-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when form name with [] array #3618
Comments
Can you expand upon the issue you are facing by adding a few more pieces of information to your bug report?
The contributing guide contains a useful section with a few questions which can help us track down the bug and speed up the process of finding a fix for it. The creation of an isolated test case would also be useful. |
Like the example I reported above, the actual plugin select2() is running normally.
Bug: I've tried with Mozilla Firefox 39.0 I also use some plugins, such as TinyMCE, typeahead, and others. jQuery v2.1.4 |
I get the same error with Select2 4.0.1 and jQuery.min.js 2.1.4 Tested with browsers Firefox 42 and Opera 34. Edit: Uncaught SyntaxError: Invalid regular expression: /(^|\.)select2\.(?:.*\.|)select2-input-params-data-source[show-issues]-g0(\.|$)/: Range out of order in character class |
Yeah, this seems to be the problem. |
there is also a problem when in the name there is a "-" is followed by a number, inside brackets. name="group[guid-xp]" - ok example: https://jsfiddle.net/ogg1o102/ |
I ran into this issue in our own code. It actually appears to be the result of a more general bug relating to any time square bracket appears in an attribute The problem is that generateId takes the name attribute directly and then uses it for namespacing events, e.g. here. It looks like jQuery passes the namespace strings directly into a RegExp constructor when matching events and so the square brackets get treated as regex square brackets. This results in the errors above because the namespace is a malformed regex. It also causes other bugs any time a square bracket appears in a name. Because jQuery is interpreting the square brackets as regex square brackets, it can't correctly unbind events attached when there is a square bracket in the event namespace. Look at this fiddle for example. In fact, I encountered this bug for that reason. A scroll handler wasn't getting correctly unbound when the select2 container closed. Because the bug is the result of |
I think escaping the name/id in |
For example I created a form select using [] array.
Then I initialization select()
then when I observed on the web browser console, an error occurs.
I tried to eliminate the name without the array. The results are normal.
The text was updated successfully, but these errors were encountered: