happy-dom
happy-dom copied to clipboard
#475@minor: Adds support for HTMLMediaElement.
Resolves https://github.com/capricorn86/happy-dom/issues/484 Resolves https://github.com/capricorn86/happy-dom/issues/475
It's a very basic implementation mostly covering the API (at least what is common between audio and video and widely supported in browsers) timeRanges
implementation coming from jsdom as the comment mentioned.
I try to implement some basic logic but mostly is missing, I hope this can be good enough as a first step.
References: https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement https://html.spec.whatwg.org/#htmlmediaelement https://github.com/jsdom/jsdom
p.s.: should I need to add HTMLAudioElement and HTMLVideoELement to window.ts and index.ts or the changes is the packages/happy-dom/src/config/ElementTag.ts in enough for use?
although those tags extend from HTMLMediaElement
, I think we should implement for HTMLVideoElement
and HTMLAudioElement
before removing or adding these tags in ElementTag.ts
.
Of course this is my personal advice, perhaps repo owner's advice is more valuable.
Hi @Mas0nShi ,
thanks for the feedback.
HTMLAudioElement
has a same API
as HTMLMediaElement
, only mozzilla-specific API is a difference if I understand correctly the documentation.
https://html.spec.whatwg.org/multipage/media.html#htmlaudioelement
(maybe better doing this here as well? creating an audio element and that is just extending the Media element? 🤔 )
HTMLVideoElement
has some widely supported properties/attributes that are not coming from HTMLMediaElement
, so yes maybe better implement that as well before adding or removing it from the not implemented list, but still after this, most of the API working in the test.
https://html.spec.whatwg.org/multipage/media.html#the-video-element
(maybe better doing this here as well? creating an audio element and that is just extending the Media element? 🤔 )
yes, it's my advices, we can add HTMLMediaElement and HTMLVideoElement though identical or incomplete.
(maybe better doing this here as well? creating an audio element and that is just extending the Media element? 🤔 )
yes, it's my advices, we can add HTMLMediaElement and HTMLVideoElement though identical or incomplete.
done
Hi @rudywaltz and @Mas0nShi ! 🙂
Sorry for not looking into this earlier. It has been a lot going on in my private and work life.
I have managed to get the PR build to work and it seems like this PR is failing to build.
I can merge this when the build is successful.
Hi @Mas0nShi ! 🙂
Sorry for not looking into this earlier. It has been a lot going on in my private and work life.
I have managed to get the PR build to work and it seems like this PR is failing to build.
I can merge this when the build is successful.
Hi @capricorn86 , thank you for taking care of this repo. Can I ask some hint where is the missing part. I see the error locally as well
src/window/Window.ts(256,18): error TS2416: Property 'self' in type 'Window' is not assignable to the same property in base type 'IWindow'.
Type 'this' is not assignable to type 'IWindow'.
Property 'HTMLAudioElement' is missing in type 'Window' but required in type 'IWindow'.
but I have no idea where is the missing part. I try to follow the DialogElement implementation and I don't find any place where the Audio is missing ):
Hi @capricorn86 , thank you for taking care of this repo. Can I ask some hint where is the missing part. I see the error locally as well
src/window/Window.ts(256,18): error TS2416: Property 'self' in type 'Window' is not assignable to the same property in base type 'IWindow'. Type 'this' is not assignable to type 'IWindow'. Property 'HTMLAudioElement' is missing in type 'Window' but required in type 'IWindow'.
but I have no idea where is the missing part. I try to follow the DialogElement implementation and I don't find any place where the Audio is missing ):
@rudywaltz I found the error. In Window.ts
the property HTMLAudiolement
should be renamed to HTMLAudioElement
:slightly_smiling_face:
It's failing because the interface is using the name HTMLAudioElement
and it doesn't follow the interface correctly.
It seems like we got a small merge conflict as well. When that and the property is fixed I will merge it :slightly_smiling_face:
With this last "config resolve commit" the history is not too nice, if you need I can try rebasing and creating a new PR with more flat commit history.
@rudywaltz I made a squash 🙂