Opened 14 years ago
Closed 13 years ago
#3295 closed bug (invalid)
jQuery 1.2.X's .clean() mangles namespaced elements
Reported by: | antonio.collins | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 1.3 |
Component: | core | Version: | 1.2.6 |
Keywords: | Cc: | antonio.collins, flesler | |
Blocked by: | Blocking: |
Description
The .clean() method tries to replace empty elements defined as <elem /> with <elem></elem>. Here's the code from .clean():
// Convert html string into DOM nodes if ( typeof elem == "string" ) { // Fix "XHTML"-style tags in all browsers elem = elem.replace(/(<(\w+)[^>]*?)\/>/g, function(all, front, tag){ return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i) ? all : front + "></" + tag + ">"; });
If the element is namespaced like this:
<data:person name="john doe" id="123" />
the manufactured closing tag is incorrect and will cause some DOM injection methods to fail:
<data:person name="john doe" id="123" ></data>
Changing the regular expression's (\w+) to ([A-Za-z0-9_:]+) fixes the problem.
Attachments (1)
Change History (4)
comment:1 Changed 14 years ago by
Cc: | antonio.collins flesler added |
---|---|
need: | Review → Test Case |
comment:2 Changed 14 years ago by
I see the problem in IE7. FF3, Chrome 1.0, Safari 3.2.1, and Opera 9.63 work properly. The closing tag coming out of the code quoted above is incorrect, so I think the HTML parser must be fixing it for all but IE.
Test case attached.
comment:3 Changed 13 years ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
Hey, waitaminit. This is XML and not HTML. jQuery doesn't parse XML.
All 3 cases work well for me on FF2, the element is created successfully:
Could you provide a test case ? a minimalistic html file with the requires html and js to reproduce the problem. Specifying failing browser/OS as well.