Permalink
Browse files

Update feature-detects/forms-formattribute.js

  • Loading branch information...
1 parent fb75a44 commit ef85994b4eba67ecfdbc524cefb42d28e2fd1591 @danielchatfield danielchatfield committed Jul 23, 2012
Showing with 23 additions and 20 deletions.
  1. +23 −20 feature-detects/forms-formattribute.js
View
43 feature-detects/forms-formattribute.js
@@ -1,27 +1,30 @@
-
// Detects whether input form="form_id" is available on the platform
// E.g. IE 10 (and below), don't support this
Modernizr.addTest("formattribute", function(){
- var form = document.createElement("form"),
- input = document.createElement("input"),
- div = document.createElement("div"),
- id = "formtest",
- bool = false;
-
- form.id = id;
- input.setAttribute("form",id);
-
- div.appendChild(form);
- div.appendChild(input);
-
- document.documentElement.appendChild(div);
-
- bool = form.elements.length === 1;
-
- div.parentNode.removeChild(div);
-
- return bool;
+ try {
+ var form = document.createElement("form"),
+ input = document.createElement("input"),
+ div = document.createElement("div"),
+ id = "formtest",
+ bool = false;
+
+ form.id = id;
+ input.setAttribute("form",id);
+
+ div.appendChild(form);
+ div.appendChild(input);
+
+ document.documentElement.appendChild(div);
+
+ bool = form.elements.length === 1;
+
+ div.parentNode.removeChild(div);
+
+ return bool;
+ } catch (e) {
+ return false;
+ }
});

0 comments on commit ef85994

Please sign in to comment.