Closed ghost closed 12 years ago
the problem is that IE9 enforces proper handling of namespaces. so jsjac should use .setAttributeNS or the like to set xml:lang (at least for IE9 - but I'm sure it'd break a lot of other things/browsers if doing so). I'll have a look (see other comment).
Maybe JSJaC should do this:
yes, this or the other way round. I've been doing this already at other parts of the code.
Am 14.06.2011 um 15:52 schrieb Vanaryon:
Maybe JSJaC should do this:
- try with the old method
- if this is null (meaning that there were a bug while setting the attribute), try with the fallback method
Reply to this email directly or view it on GitHub: https://github.com/sstrigler/JSJaC/issues/13#issuecomment-1366035
I tested using setAttributeNS. The method works, but not with the "xml:lang" attribute using Firefox. It works using "lang", but Firefox applies the following attribute instead: "a0:lang", which is pretty strange.
I have no running IE9, because I only have a Windows XP VM on an Ubuntu machine, I let you try to fix it ;) Thanks!
Am 22.06.2011 um 22:49 schrieb Vanaryon reply@reply.github.com:
I tested using setAttributeNS. The method works, but not with the "xml:lang" attribute using Firefox. It works using "lang", but Firefox applies the following attribute instead: "a0:lang", which is pretty strange.
I have no running IE9, because I only have a Windows XP VM on an Ubuntu machine, I let you try to fix it ;) Thanks!
Lol! No problem with that but please give me some time. Got lots of work to do ... :/
Greets, Steve
I replaced the setXMLLang function by this:
JSJaCPacket.prototype.setXMLLang = function(xmllang) {
try {
// Fix for the IE9 invalid attribute test
if(this.getNode().removeAttributeNS && this.getNode().setAttributeNS) {
if (!xmllang || xmllang == '')
this.getNode().removeAttributeNS('jabber:client','xml:lang');
else
this.getNode().setAttributeNS('jabber:client','xml:lang',xmllang);
}
// Legacy
else {
if (!xmllang || xmllang == '')
this.getNode().removeAttribute('xml:lang');
else
this.getNode().setAttribute('xml:lang',xmllang);
}
return this;
} catch(e) { alert(e); return this; }
};
Using Firefox 5.0, I got this error message:
[Exception... "An attempt was made to create or change an object in a way which is incorrect with regard to namespaces" code: "14" nsresult: "0x8053000e (NS_ERROR_DOM_NAMESPACE_ERR)" location: "https://laptop.vanaryon.eu/projects/jappix/trunk/php/get.php?h=322e59b9999cf2e060f4444c630cb798&l=fr&t=js&g=desktop.xml Line: 10884"]
Can you try it under IE9?
Okay, I asked a friend of me to test this. It returns DOM Exception: NAMESPACE_ERR (14) using IE9 using the first method (attributeNS).
I also tried another solution, with a try {} catch(e) {} but IE9 does not fire any error using setAttribute()!
The last thing I tried is to return the new XML only if it exists, but the "this" var still contains a XML object, which is broken.
No solution for me, the best one (and the dirtiest) is to detect the browser name & version as we do now for Jappix... :S
Maybe a stupid idea but have you tried one of these:
this.getNode().setAttributeNS('xml', 'lang', xmllang);
or this.getNode().setAttributeNS(this.getNode().namespaceURI, 'xml:lang', xmllang); ?
Greets, Steve
Btw, I found this one which doesn't look very promising: http://reference.sitepoint.com/javascript/Element/setAttributeNS
Am 23.06.2011 um 14:28 schrieb Vanaryon:
Okay, I asked a friend of me to test this. It returns DOM Exception: NAMESPACE_ERR (14) using IE9 using the first method (attributeNS).
I also tried another solution, with a try {} catch(e) {} but IE9 does not fire any error using setAttribute()!
The last thing I tried is to return the new XML only if it exists, but the "this" var still contains a XML object, which is broken.
No solution for me, the best one (and the dirtiest) is to detect the browser name & version as we do now for Jappix... :S
Reply to this email directly or view it on GitHub: https://github.com/sstrigler/JSJaC/issues/13#issuecomment-1424831
Nope, does not work for the two items... Will have to find another solution.
First argument to setAttributeNS and removeAttributeNS is a namespace (not a namespace prefix), so I believe this should be:
setAttributeNS('http://www.w3.org/XML/1998/namespace', 'xml:lang', xmllang);
and
removeAttributeNS('http://www.w3.org/XML/1998/namespace', 'lang');
Tested on latest Fx, Opera and Chrome, but I don't currently have IE9;)
I've verified that this works on IE9. However, it causes xml prefix to be redefined, which can cause other problems.
hi, sorry all. I'm still very busy with my current job. I promise to investigate all of those issues soon. so please stay tuned. in the meantime help yourself with those proposed patches. that's how opensource works!
Hi!
We use JSJaC for Jappix since its inception, and I can say it is just great! But we found some bugs, I am now decided to report them all, if it can solve everyone's problems!
The first bug is that IE9 is not able to use the setXMLLang() function, because of the "xml:lang" attribute (the ":" especially), it returns nothing. I did not found any other way to set it, but another way to apply it may exists.
Here is our code modification, which is just something to avoid using it through IE9 (a try {} catch(e) {} does not work, since IE9 does not report any error): http://codingteam.net/project/jappix/browse/trunk/js/jsjac.js#line-1656
Thanks!
Valérian Saliou, Jappix founder