forked from Modernizr/Modernizr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestDOMProps.js
32 lines (26 loc) · 897 Bytes
/
testDOMProps.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
define(['is', 'fnBind'], function( is ) {
/**
* testDOMProps is a generic DOM property test; if a browser supports
* a certain property, it won't return undefined for it.
*/
function testDOMProps( props, obj, elem ) {
var item;
for ( var i in props ) {
if ( props[i] in obj ) {
// return the property name as a string
if (elem === false) return props[i];
item = obj[props[i]];
// let's bind a function (and it has a bind method -- certain native objects that report that they are a
// function don't [such as webkitAudioContext])
if (is(item, 'function') && 'bind' in item){
// default to autobind unless override
return item.bind(elem || obj);
}
// return the unbound function or obj or value
return item;
}
}
return false;
}
return testDOMProps;
});