Permalink
Browse files

Default the input type attribute to text.

  • Loading branch information...
1 parent e058810 commit a593f86f23e685449a8bae356dd1b2a25fb51199 @domenic domenic committed Dec 19, 2012
Showing with 17 additions and 0 deletions.
  1. +5 −0 lib/jsdom/level2/html.js
  2. +12 −0 test/jsdom/index.js
View
@@ -843,6 +843,11 @@ define('HTMLOptionElement', {
define('HTMLInputElement', {
tagName: 'INPUT',
+ init: function() {
+ if (!this.hasAttribute('type')) {
+ this.setAttribute('type', 'text');
+ }
+ },
proto: {
_initDefaultValue: function() {
if (this._defaultValue === undefined) {
View
@@ -1438,5 +1438,17 @@ exports.tests = {
test.ok(true);
test.done();
});
+ },
+
+ inputs_should_default_to_type_text : function(test) {
+ test.expect(3);
+
+ var doc = jsdom.jsdom('<html><head></head><body><input id="input" /></body></html>');
+ var inputEl = doc.getElementById("input");
+ test.equal(inputEl.hasAttribute('type'), true);
+ test.equal(inputEl.getAttribute('type'), 'text');
+ test.equal(inputEl.type, 'text');
+
+ test.done();
}
};

0 comments on commit a593f86

Please sign in to comment.