modernizr
Version:
Modernizr is a JavaScript library that detects HTML5 and CSS3 features in the user’s browser.
31 lines (28 loc) • 943 B
JavaScript
/*!
{
"name": "Content Editable",
"property": "contenteditable",
"caniuse": "contenteditable",
"notes": [{
"name": "WHATWG spec",
"href": "https://html.spec.whatwg.org/multipage/interaction.html#contenteditable"
}]
}
!*/
/* DOC
Detects support for the `contenteditable` attribute of elements, allowing their DOM text contents to be edited directly by the user.
*/
define(['Modernizr', 'createElement', 'docElement'], function(Modernizr, createElement, docElement) {
Modernizr.addTest('contenteditable', function() {
// early bail out
if (!('contentEditable' in docElement)) {
return;
}
// some mobile browsers (android < 3.0, iOS < 5) claim to support
// contentEditable, but but don't really. This test checks to see
// confirms whether or not it actually supports it.
var div = createElement('div');
div.contentEditable = true;
return div.contentEditable === 'true';
});
});