Ticket #1826 (new feature)
namespaces handling for XMLs
| Reported by: | Orange | Owned by: | |
|---|---|---|---|
| Priority: | minor | Milestone: | 1.2.2 |
| Component: | core | Version: | 1.2.1 |
| Keywords: | Cc: | ||
| Needs: | Review |
Description
Actual jQuery does return wrong results as soon as the user uses namespaces in an xml, because IE does not handle namespaces the same way as other browsers does.
In jQuery, this concerns the use of "nodeName" which returns "prefix:tagName" instead of "tagName". This concerns the following lines in jQuery-1.2.1.js which should be corrected with the following, in order to hide namespaces :
line 1260: c.nodeName.replace(/^.*:/,'').toUpperCase() instead of c.nodeName.toUpperCase()
line 1284: n.nodeName.replace(/^.*:/,'').toUpperCase() instead of n.nodeName.toUpperCase()
An other element that causes wrong behavior is "getElementsByTagName" which has to be used in IE with "prefix:tagName". This could be corrected by the following change :
line 1362: r = jQuery.merge( r, ret[i].getElementsByTagName( tag )); should be changed in :
// getElementsByTagName will not work with IE & namespaces
var retour = [];
if (jQuery.browser.msie && (ret[i].namespaces!=null) && (ret[i].namespaces.length>0)) {
retour = jQuery.merge(retour,ret[i].getElementsByTagName(tag));
for(var nsIndex = 0; nsIndex<ret[i].namespaces.length; nsIndex++) {
var ns = "xmlns:ns='"+ret[i].namespaces(nsIndex)+"'";
ret[i].setProperty("SelectionNamespaces", ns);
var IeReturn = ret[i].selectNodes("ns:"+tag);
retour = jQuery.merge(retour, IeReturn);
}
} else {
retour = ret[i].getElementsByTagName(tag);
}
r = jQuery.merge(r, retour);
Changes have been tested on IE6/7, Mozilla, Safari & Opera. They may be easier way to perform it, but this one works.
