Skip to content

Commit

Permalink
#16 global variables checking for server-side render
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Dec 11, 2017
1 parent 85077bf commit 1f93969
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions src/hotkeys.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,13 +274,14 @@ function getKeys(key) {
}

// 在全局document上设置快捷键
addEvent(document, 'keydown', function (event) {
dispatch(event);
});

addEvent(document, 'keyup', function (event) {
clearModifier(event);
});
if (typeof document !== 'undefined') {
addEvent(document, "keydown", function (event) {
dispatch(event);
});
addEvent(document, "keyup", function (event) {
clearModifier(event);
});
}

// 清除修饰键
function clearModifier(event) {
Expand Down Expand Up @@ -347,17 +348,16 @@ _api = {
};

for (var a in _api) hotkeys[a] = _api[a];

var _hotkeys = window.hotkeys

hotkeys.noConflict = function (deep) {
if (deep && window.hotkeys === hotkeys) {
window.hotkeys = _hotkeys;
}

return hotkeys;
};

if (typeof window !== 'undefined') {
var _hotkeys = window.hotkeys;
hotkeys.noConflict = function (deep) {
if (deep && window.hotkeys === hotkeys) {
window.hotkeys = _hotkeys;
}
return hotkeys;
};
window.hotkeys = hotkeys;
}
window.hotkeys = hotkeys;

return hotkeys;

0 comments on commit 1f93969

Please sign in to comment.