Fix for/htmlFor translation in IE8

This commit is contained in:
Juriy Zaytsev 2009-03-20 18:08:34 -04:00
parent 30c1935cdb
commit 06068431f7
2 changed files with 18 additions and 4 deletions

View File

@ -1,3 +1,5 @@
* Fix another failure in IE8, `for`/`htmlFor` {get/set}Attribute translation. (kangax)
* Fix `Element#writeAttribute` and `Element#readAttribute` failures in IE8 due to lack of proper feature testing. (kangax)
* Remove sniffing from one of the DOM tests, which produced failures in IE8. (kangax)

View File

@ -1169,7 +1169,7 @@ Element._attributeTranslations = {
write: {
names: {
className: 'class',
htmlFor: 'for'
htmlFor: 'for'
},
values: { }
}
@ -1309,13 +1309,14 @@ else if (Prototype.Browser.IE) {
Element._attributeTranslations = (function(){
var classProp = 'className';
var forProp = 'for';
var el = document.createElement('div');
// try "className" first (IE <8)
el.setAttribute(classProp, 'x');
if (el.className !== 'x') {
// try "class" (IE 8)
el.setAttribute('class', 'x');
if (el.className === 'x') {
@ -1324,12 +1325,23 @@ else if (Prototype.Browser.IE) {
}
el = null;
el = document.createElement('label');
el.setAttribute(forProp, 'x');
if (el.htmlFor !== 'x') {
el.setAttribute('htmlFor', 'x');
if (el.htmlFor === 'x') {
forProp = 'htmlFor';
}
}
el = null;
return {
read: {
names: {
'class': classProp,
'className': classProp,
'for': 'htmlFor'
'for': forProp,
'htmlFor': forProp
},
values: {
_getAttr: function(element, attribute) {
@ -1905,4 +1917,4 @@ Element.addMethods({
return value;
}
});
});