forked from capricorn86/happy-dom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DOMRect.ts
47 lines (37 loc) · 1020 Bytes
/
DOMRect.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
import DOMRectReadOnly, { IDOMRectInit } from './DOMRectReadOnly.js';
import * as PropertySymbol from '../../PropertySymbol.js';
/* eslint-disable jsdoc/require-jsdoc */
/**
* Bounding rect object.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMRect
*/
export default class DOMRect extends DOMRectReadOnly {
public set x(value: number) {
this[PropertySymbol.x] = value;
}
public get x(): number {
return this[PropertySymbol.x];
}
public set y(value: number) {
this[PropertySymbol.y] = value;
}
public get y(): number {
return this[PropertySymbol.y];
}
public set width(value: number) {
this[PropertySymbol.width] = value;
}
public get width(): number {
return this[PropertySymbol.width];
}
public set height(value: number) {
this[PropertySymbol.height] = value;
}
public get height(): number {
return this[PropertySymbol.height];
}
public static fromRect(other: IDOMRectInit): DOMRect {
return new DOMRect(other.x, other.y, other.width, other.height);
}
}