Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
fix: Next.js SSR document type error
Browse files Browse the repository at this point in the history
  • Loading branch information
luwes committed Apr 19, 2023
1 parent 38a9bf0 commit 7a2b43f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 22 deletions.
4 changes: 4 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ <h1>&lt;vimeo-video&gt;</h1>
video.src = 'https://vimeo.com/638371504';
}

video.addEventListener('loadstart', (e) => {
console.log(e.type);
});

video.addEventListener('play', (e) => {
console.log(e.type);
});
Expand Down
46 changes: 24 additions & 22 deletions vimeo-video-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,29 @@ import VimeoPlayerAPI from '@vimeo/player/dist/player.es.js';
const EMBED_BASE = 'https://player.vimeo.com/video';
const MATCH_SRC = /vimeo\.com\/(?:video\/)?(\d+)/;

const templateShadowDOM = document.createElement('template');
templateShadowDOM.innerHTML = /*html*/`
<style>
:host {
display: inline-block;
min-width: 300px;
min-height: 150px;
position: relative;
}
iframe {
position: absolute;
top: 0;
left: 0;
}
:host(:not([controls])) {
pointer-events: none;
}
</style>
`;

class VimeoVideoElement extends HTMLElement {
const templateShadowDOM = globalThis.document?.createElement('template');
if (templateShadowDOM) {
templateShadowDOM.innerHTML = /*html*/`
<style>
:host {
display: inline-block;
min-width: 300px;
min-height: 150px;
position: relative;
}
iframe {
position: absolute;
top: 0;
left: 0;
}
:host(:not([controls])) {
pointer-events: none;
}
</style>
`;
}

class VimeoVideoElement extends (globalThis.HTMLElement ?? class {}) {
static observedAttributes = [
'autoplay',
'controls',
Expand Down Expand Up @@ -519,7 +521,7 @@ function createTimeRangesObj(ranges) {
return ranges;
}

if (!globalThis.customElements.get('vimeo-video')) {
if (globalThis.customElements && !globalThis.customElements.get('vimeo-video')) {
globalThis.customElements.define('vimeo-video', VimeoVideoElement);
}

Expand Down

1 comment on commit 7a2b43f

@vercel
Copy link

@vercel vercel bot commented on 7a2b43f Apr 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

vimeo-video-element – ./

vimeo-video-element-git-main-luwes.vercel.app
vimeo-video-element-luwes.vercel.app
vimeo-video-element.vercel.app

Please sign in to comment.