Files
Modernizr/feature-detects/input/formattribute.js
Veeck 08ab91b828 Cleanup feature detects (#2639)
* Move tests with storage tag into that subdirectory

* Move tests with canvas tag into that subdirectory

* Move tests with image tag into that subdirectory

* Fix error

* Fix typo

* Move audio test into audio subdirectory

* Move battery test into that subdirectory

* Move canvas test into that subdirectory

* Move video test into that subdirectory

* Update dependencies

* Move form and input tests into input subdirectory

* Update dependencies again

* Move webgl, svg and event tests into subdirectories

* Update README
2021-03-10 08:18:51 +01:00

48 lines
1.2 KiB
JavaScript

/*!
{
"name": "input[form] Attribute",
"property": "formattribute",
"tags": ["attribute", "forms", "input"],
"builderAliases": ["forms_formattribute"]
}
!*/
/* DOC
Detects whether input form="form_id" is available on the platform
E.g. IE 10 (and below), don't support this
*/
define(['Modernizr', 'createElement', 'docElement'], function(Modernizr, createElement, docElement) {
Modernizr.addTest('formattribute', function() {
var form = createElement('form');
var input = createElement('input');
var div = createElement('div');
var id = 'formtest' + (new Date()).getTime();
var attr;
var bool = false;
form.id = id;
//IE6/7 confuses the form idl attribute and the form content attribute, so we use document.createAttribute
try {
input.setAttribute('form', id);
}
catch (e) {
if (document.createAttribute) {
attr = document.createAttribute('form');
attr.nodeValue = id;
input.setAttributeNode(attr);
}
}
div.appendChild(form);
div.appendChild(input);
docElement.appendChild(div);
bool = form.elements && form.elements.length === 1 && input.form === form;
div.parentNode.removeChild(div);
return bool;
});
});