mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-28 02:01:20 -08:00
fix(react): [EX-01] verify installed consumers and clean up callback failures
This commit is contained in:
1 parent
3e39fc745f
commit
e0d785662d
25 files changed
+3539
-98
No files matched your search
@@ -0,0 +1,21 @@
|
||||
import type Artplayer from 'artplayer'
|
||||
import type { Option } from 'artplayer'
|
||||
import type { ComponentProps } from 'react'
|
||||
import Player from './src/Player'
|
||||
|
||||
const option: Partial<Option> = { url: '/pattern.mp4' }
|
||||
const props: ComponentProps<typeof Player> = {
|
||||
option,
|
||||
getInstance(art: Artplayer) { art.pause() },
|
||||
style: { width: 640 },
|
||||
className: 'consumer-container',
|
||||
onClick(event) { event.currentTarget.dataset.clicked = 'yes' },
|
||||
}
|
||||
export const valid = <Player {...props} />
|
||||
export const optional = <Player option={{}} />
|
||||
// @ts-expect-error The historical callback receives a player, not a media element.
|
||||
export const wrongCallback = <Player option={option} getInstance={(video: HTMLVideoElement) => video.pause()} />
|
||||
// @ts-expect-error Native div attributes retain their original types.
|
||||
export const wrongStyle = <Player option={option} style="width: 640px" />
|
||||
// @ts-expect-error Player options still enforce field types.
|
||||
export const wrongOption = <Player option={{ url: 123 }} />
|
||||
Reference in new issue
Block a user