-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#1711のテスト書いてみた #1
The head ref may contain hidden characters: "\u30C6\u30B9\u30C8\u66F8\u3044\u3066\u307F\u305F"
#1711のテスト書いてみた #1
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
テスト書いてみたので、よかったら!!
import { isMac } from "@/type/preload"; | ||
|
||
const createUseKey = (key: string) => (): Ref<boolean> => { | ||
// FIXME: Vue3.3以上では定義済みなので削除する |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
早くバージョン上げたい。
|
||
type Target = EventTarget & GlobalEventHandlers; | ||
|
||
const useCreateUseKey = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
コンポーザブルを作る関数はちょっと合法か怪しかったのでコンポーザブルに変えてみました。
(たぶん今のとこ合法)
|
||
const useCreateUseKey = ( | ||
key: string, | ||
_target: MaybeRefOrGetter<Target> = window |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DIできるようにしてみたけど・・・。
onUnmounted(() => { | ||
target.removeEventListener("keydown", onKeydown); | ||
target.removeEventListener("keyup", onKeyup); | ||
target.removeEventListener("blur", onBlur); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ベストプラクティスで「後処理もしましょう」みたいなことがVueUseに書いてたので。
if (isMac) { | ||
return useMetaKey(); | ||
return useMetaKey(target); | ||
} | ||
return useControlKey(); | ||
return useControlKey(target); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ifのなかでcomposable実行するのは今のとこ合法っぽい。
(今のVueコンポーネントがどれかさえ追えればなんでも良い)
const mountWrapper = (func: (elem: HTMLElement) => Ref<boolean>) => | ||
mount({ | ||
setup: () => { | ||
const elem = document.createElement("div"); | ||
return { elem, isActive: func(elem) }; | ||
}, | ||
render: () => null, // 警告防止 | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
これにたどり着くまでにすごく時間がかかった。。。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTMです。合法とかの概念があるんですね(知らなかった)
といってもVueのコンポーザブルのとこにちょっと書いてるくらいなんですけどね。 あ、これ @sevenc-nanashi さんのリポジトリへのプルリクなので、マージしていただければ @sevenc-nanashi さんのプルリクに反映されると思います! |
(マージ忘れてました) |
53e1e12
into
sevenc-nanashi:fix/multi-select-with-unfocus
* Refactor: 修飾キーのcomposableを追加 * Dlete: 不要なexportを削除 Co-authored-by: Hiroshiba <[email protected]> * #1711のテスト書いてみた (#1) --------- Co-authored-by: Hiroshiba <[email protected]>
内容
VOICEVOX#1711 のテストを書いてみました。
めちゃくちゃ難しかったです。。。。。。。
その他