Skip to content

Commit

Permalink
Merge pull request #2140 from ibolmo/fix-2100-ie-element-erase-class
Browse files Browse the repository at this point in the history
Fix #2100. Element.erase caused unexpected values for the attributes
  • Loading branch information
cpojer committed Nov 29, 2011
2 parents 74644b1 + 9726eff commit edb0324
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
30 changes: 17 additions & 13 deletions Source/Element/Element.js
Expand Up @@ -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;
});
Expand Down Expand Up @@ -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){
Expand All @@ -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;
},

Expand Down Expand Up @@ -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>*/
Expand Down
2 changes: 1 addition & 1 deletion Specs
Submodule Specs updated 1 files
+33 −0 1.4client/Element/Element.js

0 comments on commit edb0324

Please sign in to comment.