Permalink
Browse files

Merge pull request #2140 from ibolmo/fix-2100-ie-element-erase-class

Fix #2100. Element.erase caused unexpected values for the attributes
  • Loading branch information...
2 parents 74644b1 + 9726eff commit edb0324524822c9697998c3a0ecd6297bd0cda44 @cpojer cpojer committed Nov 29, 2011
Showing with 18 additions and 14 deletions.
  1. +17 −13 Source/Element/Element.js
  2. +1 −1 Specs
View
@@ -507,7 +507,7 @@ var propertyGetters = {}, propertySetters = {};
var properties = {};
Array.forEach([
'type', 'value', 'defaultValue', 'accessKey', 'cellPadding', 'cellSpacing', 'colSpan',
- 'frameBorder', 'readOnly', 'rowSpan', 'tabIndex', 'useMap'
+ 'frameBorder', 'rowSpan', 'tabIndex', 'useMap'
], function(property){
properties[property.toLowerCase()] = property;
});
@@ -555,7 +555,7 @@ Array.forEach(bools, function(bool){
Object.append(propertySetters, {
'class': function(node, value){
- ('className' in node) ? node.className = value : node.setAttribute('class', value);
+ ('className' in node) ? node.className = (value || '') : node.setAttribute('class', value);
},
'for': function(node, value){
@@ -564,26 +564,30 @@ Object.append(propertySetters, {
'style': function(node, value){
(node.style) ? node.style.cssText = value : node.setAttribute('style', value);
+ },
+
+ 'value': function(node, value){
+ node.value = value || '';
}
});
+propertyGetters['class'] = function(node){
+ return ('className' in node) ? node.className || null : node.getAttribute('class');
+};
+
/* getProperty, setProperty */
Element.implement({
setProperty: function(name, value){
- var lower = name.toLowerCase();
- if (value == null){
- if (!booleans[lower]){
- this.removeAttribute(name);
- return this;
- }
- value = false;
+ var setter = propertySetters[name.toLowerCase()];
+ if (setter){
+ setter(this, value);
+ } else {
+ if (value == null) this.removeAttribute(name);
+ else this.setAttribute(name, value);
}
- var setter = propertySetters[lower];
- if (setter) setter(this, value);
- else this.setAttribute(name, value);
return this;
},
@@ -968,7 +972,7 @@ if (el.getAttributeNode('id')) Element.Properties.id = {
return this.id || null;
},
erase: function(){
- this.id = this.getAttributeNode('id').value = null;
+ this.id = this.getAttributeNode('id').value = '';
}
};
/*</IE>*/
2 Specs

0 comments on commit edb0324

Please sign in to comment.