865bd57357
* Allow clicks inside dialog panel when target is inside shadow root * Introduce resettable “server” state This will aid in testing * Add SSR and hydration tests for react * Fix server rendering of Tabs on React 17 * Fix CS * Skip hydration tests * Tweak SSR implementation in Vue * Update changelog
16 lines
475 B
TypeScript
16 lines
475 B
TypeScript
import { watchEffect } from 'vue'
|
|
import { env } from '../utils/env'
|
|
|
|
export function useDocumentEvent<TType extends keyof DocumentEventMap>(
|
|
type: TType,
|
|
listener: (this: Document, ev: DocumentEventMap[TType]) => any,
|
|
options?: boolean | AddEventListenerOptions
|
|
) {
|
|
if (env.isServer) return
|
|
|
|
watchEffect((onInvalidate) => {
|
|
document.addEventListener(type, listener, options)
|
|
onInvalidate(() => document.removeEventListener(type, listener, options))
|
|
})
|
|
}
|