-
-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into 1406-fix-issue-with-insertbefore-and-comme…
…nt-node
- Loading branch information
Showing
12 changed files
with
604 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,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 { | ||
public x = 0; | ||
public y = 0; | ||
public width = 0; | ||
public height = 0; | ||
public top = 0; | ||
public right = 0; | ||
public bottom = 0; | ||
public left = 0; | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param [x] X position. | ||
* @param [y] Y position. | ||
* @param [width] Width. | ||
* @param [height] Height. | ||
*/ | ||
constructor(x?, y?, width?, height?) { | ||
this.x = x || 0; | ||
this.y = y || 0; | ||
this.width = width || 0; | ||
this.height = height || 0; | ||
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import * as PropertySymbol from '../../PropertySymbol.js'; | ||
|
||
/* eslint-disable jsdoc/require-jsdoc */ | ||
|
||
/** | ||
* Bounding rect readonly object. | ||
* | ||
* @see https://drafts.fxtf.org/geometry/#DOMRect | ||
*/ | ||
export default class DOMRectReadOnly implements IDOMRectInit { | ||
protected [PropertySymbol.x]: number = 0; | ||
protected [PropertySymbol.y]: number = 0; | ||
protected [PropertySymbol.width]: number = 0; | ||
protected [PropertySymbol.height]: number = 0; | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param [x] X position. | ||
* @param [y] Y position. | ||
* @param [width] Width. | ||
* @param [height] Height. | ||
*/ | ||
constructor(x?: number | null, y?: number | null, width?: number | null, height?: number | null) { | ||
this[PropertySymbol.x] = x !== undefined && x !== null ? Number(x) : 0; | ||
this[PropertySymbol.y] = y !== undefined && y !== null ? Number(y) : 0; | ||
this[PropertySymbol.width] = width !== undefined && width !== null ? Number(width) : 0; | ||
this[PropertySymbol.height] = height !== undefined && height !== null ? Number(height) : 0; | ||
} | ||
|
||
public get x(): number { | ||
return this[PropertySymbol.x]; | ||
} | ||
|
||
public get y(): number { | ||
return this[PropertySymbol.y]; | ||
} | ||
|
||
public get width(): number { | ||
return this[PropertySymbol.width]; | ||
} | ||
|
||
public get height(): number { | ||
return this[PropertySymbol.height]; | ||
} | ||
|
||
public get top(): number { | ||
return Math.min(this[PropertySymbol.y], this[PropertySymbol.y] + this[PropertySymbol.height]); | ||
} | ||
|
||
public get right(): number { | ||
return Math.max(this[PropertySymbol.x], this[PropertySymbol.x] + this[PropertySymbol.width]); | ||
} | ||
|
||
public get bottom(): number { | ||
return Math.max(this[PropertySymbol.y], this[PropertySymbol.y] + this[PropertySymbol.height]); | ||
} | ||
|
||
public get left(): number { | ||
return Math.min(this[PropertySymbol.x], this[PropertySymbol.x] + this[PropertySymbol.width]); | ||
} | ||
|
||
public toJSON(): object { | ||
return { | ||
x: this.x, | ||
y: this.y, | ||
width: this.width, | ||
height: this.height, | ||
top: this.top, | ||
right: this.right, | ||
bottom: this.bottom, | ||
left: this.left | ||
}; | ||
} | ||
|
||
public static fromRect(other: IDOMRectInit): DOMRectReadOnly { | ||
return new DOMRectReadOnly(other.x, other.y, other.width, other.height); | ||
} | ||
} | ||
|
||
export interface IDOMRectInit { | ||
readonly x: number; | ||
readonly y: number; | ||
readonly width: number; | ||
readonly height: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.