#13351 closed bug (notabug)
Syntax error, unrecognized expression with whitespace
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.9.0 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
If you do an insertAfter, or even an appendTo for that matter, with an HTML string that has whitespace (tabbed whitespace), you get an error: "Syntax error, unrecognized expression".
This can be remedied by executing jQuery.trim onto the HTML string, but this never used to break in earlier versions of jQuery like v1.7.2. Only the new release v1.9.0. You shouldn't need to do jQuery trim. So older code breaks with zero changes.
Example: http://jsfiddle.net/6XTk2/
Change History (6)
comment:1 Changed 10 years ago by
comment:2 Changed 10 years ago by
Sorry, another update. But this is even worse, it's not even tabbed whitespace, it's ANY whitespace.
A even more powerful example -> http://jsfiddle.net/6XTk2/2/
comment:4 follow-up: 6 Changed 10 years ago by
Resolution: | → notabug |
---|---|
Status: | new → closed |
Yes, that's documented in the upgrade guide. By far, the most common situation where whitespace may appear is when processing an HTML template. For those cases, use $.parseHTML
to specify (for both your sake and the sake of anyone else reading the code) whether you intend for scripts to be run in the incoming HTML.
comment:6 Changed 9 years ago by
Replying to dmethvin:
Yes, that's documented in the upgrade guide. By far, the most common situation where whitespace may appear is when processing an HTML template. For those cases, use
$.parseHTML
to specify (for both your sake and the sake of anyone else reading the code) whether you intend for scripts to be run in the incoming HTML.
Why is this documented in the changelogs but not in the normal documentation?
Please see an even more powerful and simple example -> http://jsfiddle.net/6XTk2/2/
It just has one simple tab of whitespace.
Replying to [email protected]…: