Skip to content

Commit

Permalink
Merge remote branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
davglass committed Oct 10, 2010
2 parents aa436e1 + fa8e6e0 commit a470c83
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 31 deletions.
2 changes: 1 addition & 1 deletion lib/jsdom/browser/domtohtml.js
Expand Up @@ -168,7 +168,7 @@ var generateHtmlRecursive = function(element) {
ret += current.end;
break;
case element.TEXT_NODE:
ret += escapeText(element.nodeValue);
ret += element.nodeValue;
break;
case element.COMMENT_NODE:
ret += '<!--' + element.nodeValue + '-->';
Expand Down
54 changes: 24 additions & 30 deletions lib/jsdom/browser/index.js
Expand Up @@ -598,40 +598,34 @@ var browserAugmentation = exports.browserAugmentation = function(dom, options) {
});

dom.Element.prototype.__defineGetter__('value', function() {
if (this.tagName.toUpperCase() == 'INPUT') {
return this.getAttribute('value') || '';
}
if (this.tagName.toUpperCase() == 'TEXTAREA') {
return this.innerHTML;
}
if (this.tagName.toUpperCase() == 'OPTION') {
return this.getAttribute('value') || this.innerHTML;
}

if (this.tagName.toUpperCase() == 'SELECT') {
if (this.selectedIndex == -1) {
return '';
}
return this.options[this.selectedIndex].value;
if (this.tagName.toUpperCase() === 'TEXTAREA') {
return this.innerHTML;
} else if (this.tagName.toUpperCase() === 'OPTION') {
return this.getAttribute('value');// || this.innerHTML;
} else if (this.tagName.toUpperCase() === 'SELECT') {
if (this.selectedIndex === -1) {
return '';
}
return undefined;
return this.options[this.selectedIndex].value;
}
return this.getAttribute('value') || '';
});

dom.Element.prototype.__defineSetter__('value', function(val) {
if (this.nodeName.toUpperCase() == 'INPUT') {
this.setAttribute('value', val);
} else if (this.nodeName.toUpperCase() == 'TEXTAREA') {
this.nodeValue = this.innerHTML = val;
} else if (this.nodeName.toUpperCase() == 'SELECT') {
for (var i = 0; i < this.options.length; i++) {
if (this.options[i].value == val) {
this.selectedIndex = i;
}
}
} else {
//Throw Error
}
});
if (this.nodeName.toUpperCase() === 'TEXTAREA') {
this.nodeValue = this.innerHTML = val;
} else if (this.nodeName.toUpperCase() === 'SELECT') {
for (var i = 0; i < this.options.length; i++) {
if (this.options[i].value === val) {
this.selectedIndex = i;
}
}
return;
} else {
//this.nodeValue = this.innerHTML = val;
return this.setAttribute('value', val);
}
});

dom.Element.prototype.__defineGetter__('form', function() {
var e = this;
Expand Down

0 comments on commit a470c83

Please sign in to comment.