forms-formattribute.js 788 B

1234567891011121314151617181920212223242526272829
  1. // Detects whether input form="form_id" is available on the platform
  2. // E.g. IE 10 (and below), don't support this
  3. Modernizr.addTest("formattribute", function() {
  4. var form = document.createElement("form"),
  5. input = document.createElement("input"),
  6. div = document.createElement("div"),
  7. id = "formtest"+(new Date().getTime()),
  8. attr,
  9. bool = false;
  10. form.id = id;
  11. //IE6/7 confuses the form idl attribute and the form content attribute
  12. if(document.createAttribute){
  13. attr = document.createAttribute("form");
  14. attr.nodeValue = id;
  15. input.setAttributeNode(attr);
  16. div.appendChild(form);
  17. div.appendChild(input);
  18. document.documentElement.appendChild(div);
  19. bool = form.elements.length === 1 && input.form == form;
  20. div.parentNode.removeChild(div);
  21. }
  22. return bool;
  23. });