Skip to content

Commit 4c051b8

Browse files
author
Sebastien Pereira
committed
make has module runnable/loadable on Node.js
1 parent 7fc42bd commit 4c051b8

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

handlers/features.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
define([
55
"requirejs-dplugins/has"
66
], function (has) {
7-
has.add("touch-events", "ontouchstart" in document); // UA supports Touch Events
8-
has.add("pointer-events", "onpointerdown" in document); // UA supports Pointer Events
9-
has.add("mspointer-events", "onmspointerdown" in document); // UA supports Pointer Events (IE10+IE11 preview)
10-
has.add("touch-device", /(mobile)|(android)/i.test(navigator.userAgent)); // mobile device
11-
has.add("css-touch-action", "touchAction" in document.body.style);// touch-action CSS
12-
has.add("css-ms-touch-action", "msTouchAction" in document.body.style);// -ms-touch-action CSS
7+
if (typeof document !== "undefined") {
8+
has.add("touch-events", "ontouchstart" in document); // UA supports Touch Events
9+
has.add("pointer-events", "onpointerdown" in document); // UA supports Pointer Events
10+
has.add("mspointer-events", "onmspointerdown" in document); // UA supports Pointer Events (IE10+IE11 preview)
11+
has.add("touch-device", /(mobile)|(android)/i.test(navigator.userAgent)); // mobile device
12+
has.add("css-touch-action", "touchAction" in document.body.style);// touch-action CSS
13+
has.add("css-ms-touch-action", "msTouchAction" in document.body.style);// -ms-touch-action CSS
14+
}
1315
return has;
1416
});

0 commit comments

Comments
 (0)