Skip to content

Commit

Permalink
Fixes mootools#2443 - Fix IE9 which trowed an error when setting an i…
Browse files Browse the repository at this point in the history
…nput type to "email"
  • Loading branch information
arian committed Feb 11, 2013
1 parent fd09665 commit 6345dee
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 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
2 changes: 1 addition & 1 deletion Specs/1.5client/Element/Element.js
Expand Up @@ -3,7 +3,7 @@ describe('creating new Elements', function(){

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

});

0 comments on commit 6345dee

Please sign in to comment.