Skip to main content

Bug Tracker

Side navigation

#7583 closed bug (invalid)

Opened November 21, 2010 02:49AM UTC

Closed November 21, 2010 03:09AM UTC

Last modified November 23, 2010 10:13PM UTC

strange xml attribute with IE8

Reported by: helfima@wanadoo.fr Owned by:
Priority: undecided Milestone: 1.5
Component: unfiled Version: 1.4.4
Keywords: Cc:
Blocked by: Blocking:
Description

i use a textarea for build xml and after i parse it with $()

but in IE8 i have a strange result if i try to add a attribute on a node with another attribute, if the node have no attribute the result is ok. Use my script for test it, before change the javascript source.

the result:

<LIST name="toto" label="Les menus"></LIST name="toto">

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script type="text/javascript" src="./lib/js/jquery-1.4.4.min.js"></script>
<title>Insert title here</title>
</head>
<body>
<textarea id="xml"><list label="Les menus" ></list></textarea>
<script type="text/javascript" >
	var text = $('#xml').text();
	var xml = $(text);
	xml.attr('name', 'toto');
	var root = $('<root></root>');
	root.append(xml);
	alert(root.html());
</script>
</body>
</html>
Attachments (0)
Change History (2)

Changed November 21, 2010 03:09AM UTC by snover comment:1

description: \ i use a textarea for build xml and after i parse it with $() \ but in IE8 i have a strange result if i try to add a attribute on a node with another attribute, if the node have no attribute the result is ok. Use my script for test it, before change the javascript source. \ \ the result: \ <LIST name="toto" label="Les menus"></LIST name="toto"> \ \ {{{ \ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> \ <html> \ <head> \ <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> \ <script type="text/javascript" src="./lib/js/jquery-1.4.4.min.js"></script> \ <title>Insert title here</title> \ </head> \ <body> \ <textarea id="xml">&lt;list label="Les menus" &gt;&lt;/list&gt;</textarea> \ <script type="text/javascript" > \ var text = $('#xml').text(); \ var xml = $(text); \ xml.attr('name', 'toto'); \ var root = $('<root></root>'); \ root.append(xml); \ alert(root.html()); \ </script> \ </body> \ </html> \ }}} \ i use a textarea for build xml and after i parse it with $() \ but in IE8 i have a strange result if i try to add a attribute on a node with another attribute, if the node have no attribute the result is ok. Use my script for test it, before change the javascript source. \ \ the result: \ <LIST name="toto" label="Les menus"></LIST name="toto"> \ \ {{{ \ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> \ <html> \ <head> \ <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> \ <script type="text/javascript" src="./lib/js/jquery-1.4.4.min.js"></script> \ <title>Insert title here</title> \ </head> \ <body> \ <textarea id="xml">&lt;list label="Les menus" &gt;&lt;/list&gt;</textarea> \ <script type="text/javascript" > \ var text = $('#xml').text(); \ var xml = $(text); \ xml.attr('name', 'toto'); \ var root = $('<root></root>'); \ root.append(xml); \ alert(root.html()); \ </script> \ </body> \ </html> \ }}} \
resolution: → invalid
status: newclosed

Thanks for the report, but this is not a jQuery bug. You cannot create arbitrary elements from strings in IE without a third-party compatibility library like innerShiv. Even if you use such a thing, you are likely to run into more issues, so generally speaking you simply should not try to use jQuery to operate on non-HTML documents. In the future, please use the jQuery Forum for support requests.

Changed November 23, 2010 10:13PM UTC by paul.carroll@gmail.com comment:2

if this is the case then why does jquery pass back a jquery object of the xml received after an$.ajax operation?

i only ask as i'm experiencing a null exception moving from 1.4.3 to 1.4.4 whilst working with jquery/xml and was wondering whether to log a bug and test case