1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | 'use strict';
|
10 |
|
11 | var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
|
12 |
|
13 | var useHasFeature;
|
14 | if (ExecutionEnvironment.canUseDOM) {
|
15 | useHasFeature = document.implementation && document.implementation.hasFeature &&
|
16 |
|
17 |
|
18 | document.implementation.hasFeature('', '') !== true;
|
19 | }
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 | function isEventSupported(eventNameSuffix, capture) {
|
36 | if (!ExecutionEnvironment.canUseDOM || capture && !('addEventListener' in document)) {
|
37 | return false;
|
38 | }
|
39 |
|
40 | var eventName = 'on' + eventNameSuffix;
|
41 | var isSupported = eventName in document;
|
42 |
|
43 | if (!isSupported) {
|
44 | var element = document.createElement('div');
|
45 | element.setAttribute(eventName, 'return;');
|
46 | isSupported = typeof element[eventName] === 'function';
|
47 | }
|
48 |
|
49 | if (!isSupported && useHasFeature && eventNameSuffix === 'wheel') {
|
50 |
|
51 | isSupported = document.implementation.hasFeature('Events.wheel', '3.0');
|
52 | }
|
53 |
|
54 | return isSupported;
|
55 | }
|
56 |
|
57 | module.exports = isEventSupported; |
\ | No newline at end of file |