Modify ↓
Ticket #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 | |
| Blocking: | Blocked by: |
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
Change History
comment:1 Changed 5 years ago by flesler
- Cc antonio.collins, flesler added
- need changed from Review to Test Case
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
Note: See
TracTickets for help on using
tickets.


All 3 cases work well for me on FF2, the element is created successfully:
$('<data:person name="john doe" id="123" />') $('<data:person name="john doe" id="123">') $('<data:person name="john doe" id="123"></data:person>')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.