Skip to content

Commit

Permalink
Merge: Fix IE9 which trowed an error when setting an input type to "e…
Browse files Browse the repository at this point in the history
…mail"

Closes #2471, fixes #2443

Fix IE9 which trowed an error when setting an input type to "email"
Adding tests for #2443
  • Loading branch information
SergioCrisostomo committed Jun 2, 2014
2 parents 8a2d548 + e2134dd commit d16b5b2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
25 changes: 19 additions & 6 deletions Source/Element/Element.js
Expand Up @@ -593,15 +593,28 @@ el = null;
/* </webkit> */

/*<IE>*/
var input = document.createElement('input');
var input = document.createElement('input'), volatileInputValue, html5InputSupport;

// #2178
input.value = 't';
input.type = 'submit';
if (input.value != 't') propertySetters.type = function(node, type){
var value = node.value;
node.type = type;
node.value = value;
};
volatileInputValue = input.value != 't';

// #2443 - IE throws "Invalid Argument" when trying to use html5 input types
try {
input.type = 'email';
html5InputSupport = input.type == 'email';
} catch(e){}

input = null;

if (volatileInputValue || !html5InputSupport) propertySetters.type = function(node, type){
try {
var value = node.value;
node.type = type;
node.value = value;
} catch (e){}
};
/*</IE>*/

/* getProperty, setProperty */
Expand Down
5 changes: 5 additions & 0 deletions Specs/Element/Element.js
Expand Up @@ -67,6 +67,11 @@ describe('Element constructor', function(){
});
});

it('should create an element with type="email"', function(){
var el = new Element('input', {type: 'email'});
expect(el.get('type').match(/email|text/)).toBeTruthy();
});

it('should return input Elements that are checked', function(){
var check1 = new Element('input', { type: 'checkbox' });
var check2 = new Element('input', { type: 'checkbox', checked: true });
Expand Down

0 comments on commit d16b5b2

Please sign in to comment.