blob: 163a38dfc03ba193381504e23cea82e037d35509 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
/* eslint-env browser */
import videojs from '../../../src/js/video.js';
export class TestCustomElement extends HTMLElement {
constructor() {
super();
const shadowRoot = this.attachShadow({ mode: 'closed' });
const containerElem = document.createElement('div');
containerElem.setAttribute('data-vjs-player', '');
shadowRoot.appendChild(containerElem);
const videoElem = document.createElement('video');
videoElem.setAttribute('width', 640);
videoElem.setAttribute('height', 260);
containerElem.appendChild(videoElem);
this.innerPlayer = videojs(videoElem);
}
}
export class TestSlotElement extends HTMLElement {
constructor() {
super();
const shadowRoot = this.attachShadow({ mode: 'open' });
const wrapperEl = document.createElement('div');
wrapperEl.style = this.dataset.style;
const slot = document.createElement('slot');
wrapperEl.appendChild(slot);
shadowRoot.appendChild(wrapperEl);
}
}
// Not supported on Chrome < 54
if ('customElements' in window) {
window.customElements.define('test-custom-element', TestCustomElement);
window.customElements.define('test-slot-element', TestSlotElement);
}
|