forked from capricorn86/happy-dom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HTMLMediaElement.ts
137 lines (126 loc) · 2.38 KB
/
HTMLMediaElement.ts
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
import HTMLElement from '../html-element/HTMLElement';
import IHTMLMediaElement from './IHTMLMediaElement';
/**
* HTML Base Element.
*
* Reference:
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base.
*/
export default class HTMLMediaElement extends HTMLElement implements IHTMLMediaElement {
/**
* Returns autoplay.
*
* @returns Autoplay.
*/
public get autoplay(): boolean {
return this.getAttributeNS(null, 'autoplay') !== null;
}
/**
* Sets autoplay.
*
* @param autoplay Autoplay.
*/
public set autoplay(autoplay: boolean) {
if (!autoplay) {
this.removeAttributeNS(null, 'autoplay');
} else {
this.setAttributeNS(null, 'autoplay', '');
}
}
/**
* Returns controls.
*
* @returns Controls.
*/
public get controls(): boolean {
return this.getAttributeNS(null, 'controls') !== null;
}
/**
* Sets controls.
*
* @param controls Controls.
*/
public set controls(controls: boolean) {
if (!controls) {
this.removeAttributeNS(null, 'controls');
} else {
this.setAttributeNS(null, 'controls', '');
}
}
/**
* Returns paused.
*
* @returns Paused.
*/
public get paused(): boolean {
return this.getAttributeNS(null, 'paused') !== null;
}
/**
* Sets paused.
*
* @param paused Paused.
*/
public set paused(paused: boolean) {
if (!paused) {
this.removeAttributeNS(null, 'paused');
} else {
this.setAttributeNS(null, 'paused', '');
}
}
/**
* Returns loop.
*
* @returns Loop.
*/
public get loop(): boolean {
return this.getAttributeNS(null, 'loop') !== null;
}
/**
* Sets loop.
*
* @param loop Loop.
*/
public set loop(loop: boolean) {
if (!loop) {
this.removeAttributeNS(null, 'loop');
} else {
this.setAttributeNS(null, 'loop', '');
}
}
/**
* Returns muted.
*
* @returns muted.
*/
public get muted(): boolean {
return this.getAttributeNS(null, 'muted') !== null;
}
/**
* Sets muted.
*
* @param muted muted.
*/
public set muted(muted: boolean) {
if (!muted) {
this.removeAttributeNS(null, 'muted');
} else {
this.setAttributeNS(null, 'muted', '');
}
}
/**
*
*/
public pause(): void {
this.paused = true;
}
/**
* Clones a node.
*
* @override
* @param [deep=false] "true" to clone deep.
* @returns Cloned node.
*/
public cloneNode(deep = false): IHTMLMediaElement {
return <IHTMLMediaElement>super.cloneNode(deep);
}
}