Permalink
Browse files

Merge: Fix IE9 which trowed an error when setting an input type to "e…

…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 d16b5b2e23a56d3e19ec0943c487a6a18c47e804
Showing with 24 additions and 6 deletions.
  1. +19 −6 Source/Element/Element.js
  2. +5 −0 Specs/Element/Element.js
View
@@ -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 */
View
@@ -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 });

0 comments on commit d16b5b2

Please sign in to comment.