#16 global variables checking for server-side render

pull/17/head
jaywcjlove 7 years ago
parent 85077bfee3
commit 1f93969dd4

@ -274,13 +274,14 @@ function getKeys(key) {
} }
// 在全局document上设置快捷键 // 在全局document上设置快捷键
addEvent(document, 'keydown', function (event) { if (typeof document !== 'undefined') {
dispatch(event); addEvent(document, "keydown", function (event) {
}); dispatch(event);
});
addEvent(document, 'keyup', function (event) { addEvent(document, "keyup", function (event) {
clearModifier(event); clearModifier(event);
}); });
}
// 清除修饰键 // 清除修饰键
function clearModifier(event) { function clearModifier(event) {
@ -347,17 +348,16 @@ _api = {
}; };
for (var a in _api) hotkeys[a] = _api[a]; for (var a in _api) hotkeys[a] = _api[a];
if (typeof window !== 'undefined') {
var _hotkeys = window.hotkeys var _hotkeys = window.hotkeys;
hotkeys.noConflict = function (deep) {
hotkeys.noConflict = function (deep) { if (deep && window.hotkeys === hotkeys) {
if (deep && window.hotkeys === hotkeys) { window.hotkeys = _hotkeys;
window.hotkeys = _hotkeys; }
} return hotkeys;
};
return hotkeys; window.hotkeys = hotkeys;
}; }
window.hotkeys = hotkeys; window.hotkeys = hotkeys;
return hotkeys; return hotkeys;

Loading…
Cancel
Save