Skip to content
代码片段 群组 项目
未验证 提交 158ad68d 编辑于 作者: Mark Florian's avatar Mark Florian
浏览文件

refactor: Extract Mousetrap util file

This new ~/lib/utils/mousetrap file is similar to
~/lib/utils/axios_utils, in that it augments the raw package.

In particular, it makes it slightly easier to update Mousetrap's
`stopCallback` method.

They `Shortcut#addStopCallback` is an instance method rather than static
methods to encourage access via the (in theory) singleton Shortcuts
instance.

A problem this does not solve is the race between our overwriting of
`Mousetrap#stopCallback` and the `pause` plugin's overwriting of it:
https://github.com/ccampbell/mousetrap/blob/1.6.5/plugins/pause/mousetrap-pause.js#L10-L18.

If the `pause` plugin is loaded first, then our subsequent overwrites
will no longer be subject to the paused status of Mousetrap.

The bulk import path rename was done using this command:

    comby "import :[[name]] from 'mousetrap';" \
        "import :[name] from '~/lib/utils/mousetrap';" \
        {ee/,}{spec/frontend,app/assets/javascripts}/**/*.{js,vue} -i

See https://comby.dev/ for details about comby.

Finally, a redundant Mousetrap Jest mock has been removed, as the
package has provided a CommonJS module since v1.5.0:
https://github.com/ccampbell/mousetrap/releases/tag/1.5.0
上级 eba74ce3
No related branches found
No related tags found
无相关合并请求
显示
87 个添加45 个删除
加载中
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册