Skip to content
This repository
Browse code

Default the input type attribute to text.

  • Loading branch information...
commit a593f86f23e685449a8bae356dd1b2a25fb51199 1 parent e058810
Domenic Denicola authored December 19, 2012
5  lib/jsdom/level2/html.js
@@ -843,6 +843,11 @@ define('HTMLOptionElement', {
843 843
 
844 844
 define('HTMLInputElement', {
845 845
   tagName: 'INPUT',
  846
+  init: function() {
  847
+    if (!this.hasAttribute('type')) {
  848
+      this.setAttribute('type', 'text');
  849
+    }
  850
+  },
846 851
   proto: {
847 852
     _initDefaultValue: function() {
848 853
       if (this._defaultValue === undefined) {
12  test/jsdom/index.js
@@ -1438,5 +1438,17 @@ exports.tests = {
1438 1438
       test.ok(true);
1439 1439
       test.done();
1440 1440
     });
  1441
+  },
  1442
+
  1443
+  inputs_should_default_to_type_text : function(test) {
  1444
+    test.expect(3);
  1445
+
  1446
+    var doc = jsdom.jsdom('<html><head></head><body><input id="input" /></body></html>');
  1447
+    var inputEl = doc.getElementById("input");
  1448
+    test.equal(inputEl.hasAttribute('type'), true);
  1449
+    test.equal(inputEl.getAttribute('type'), 'text');
  1450
+    test.equal(inputEl.type, 'text');
  1451
+
  1452
+    test.done();
1441 1453
   }
1442 1454
 };

0 notes on commit a593f86

Please sign in to comment.
Something went wrong with that request. Please try again.