Side navigation
#13429 closed bug (duplicate)
Opened February 10, 2013 09:34PM UTC
Closed February 10, 2013 09:45PM UTC
jQuery(html) won't work if html start with a new line
Reported by: | jonathan.pasquier@gmail.com | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | core | Version: | 1.9.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
As of 1.9.1, it is not possible to create DOM element from HTML code with the jQuery function if the HTML code starts with a \\n
This code won't work (although it used to with 1.8.3):
$("\\n<p>Hi</p>").appendTo(aDiv);
But this one will!
aDiv.append("\\n<p>Hi</p>");
(here is a JSFiddle with a test case: http://jsfiddle.net/H2nWM/)
I understand that this is a consequence of #11290, but maybe jQuery(html) detection should take into account every whitespace characters before the first < and not only whitespace?
I'm working with FF 18 but was able to reproduce the bug on Chromium 23.
Thanks,
Jonathan
Attachments (0)
Change History (3)
Changed February 10, 2013 09:41PM UTC by comment:1
resolution: | → notabug |
---|---|
status: | new → closed |
Changed February 10, 2013 09:44PM UTC by comment:2
component: | unfiled → core |
---|---|
resolution: | notabug |
status: | closed → reopened |
Use jQuery.parseHTML
if you want to keep the leading whitespace as a text node; otherwise jQuery.trim
the input before passing it to jQuery
. Even if we do relax our requirements in the future, your code will be more clear and robust.
Changed February 10, 2013 09:45PM UTC by comment:3
resolution: | → duplicate |
---|---|
status: | reopened → closed |
Duplicate of #13223.Use jQuery.parseHTML
if you want to keep the leading whitespace as a text node; otherwise jQuery.trim
the input before passing it to jQuery
. Even if we do relax our requirements in the future, your code will be more clear and robust.
Did you mean "not only space"?
Anyway, read the 1.9 upgrade: http://jquery.com/upgrade-guide/1.9/#jquery-htmlstring-versus-jquery-selectorstring