Permalink
Browse files

Fixes #2443 - Fix IE9 which trowed an error when setting an input typ…

…e to "email"
  • Loading branch information...
1 parent fd09665 commit 6345deee551504cedd00546509c325dc064ab44b @arian committed Feb 11, 2013
Showing with 20 additions and 7 deletions.
  1. +19 −6 Source/Element/Element.js
  2. +1 −1 Specs/1.5client/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 */
@@ -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.