Skip to content

Commit

Permalink
chore: [#1079] Continues on implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
capricorn86 committed Oct 15, 2024
1 parent 8acdc9a commit 9a44a9a
Show file tree
Hide file tree
Showing 46 changed files with 4,041 additions and 358 deletions.
1 change: 1 addition & 0 deletions packages/happy-dom/src/PropertySymbol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,3 +371,4 @@ export const rotateFromVectorSelf = Symbol('rotateFromVectorSelf');
export const flipXSelf = Symbol('flipXSelf');
export const flipYSelf = Symbol('flipYSelf');
export const invertSelf = Symbol('invertSelf');
export const getLength = Symbol('getLength');
11 changes: 0 additions & 11 deletions packages/happy-dom/src/dom/DOMPoint.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import DOMPointReadOnly from './DOMPointReadOnly.js';
import * as PropertySymbol from '../PropertySymbol.js';
import IDOMPointInit from './IDOMPointInit.js';

/**
* DOM Point.
Expand Down Expand Up @@ -79,14 +78,4 @@ export default class DOMPoint extends DOMPointReadOnly {
public get w(): number {
return this[PropertySymbol.w];
}

/**
* Returns a new DOMPoint object.
*
* @param other
* @returns Cloned object.
*/
public static fromPoint(other: IDOMPointInit): DOMPoint {
return new DOMPoint(other.x, other.y, other.z, other.w);
}
}
14 changes: 11 additions & 3 deletions packages/happy-dom/src/dom/DOMPointReadOnly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,18 @@ export default class DOMPointReadOnly implements IDOMPointInit {
/**
* Returns a new DOMPointReadOnly object.
*
* @param other
* @param [otherPoint] Other point.
* @returns Cloned object.
*/
public static fromPoint(other: IDOMPointInit): DOMPointReadOnly {
return new DOMPointReadOnly(other.x, other.y, other.z, other.w);
public static fromPoint(otherPoint?: IDOMPointInit): DOMPointReadOnly {
if (!otherPoint) {
return new this();
}
return new this(
otherPoint.x ?? null,
otherPoint.y ?? null,
otherPoint.z ?? null,
otherPoint.w ?? null
);
}
}
17 changes: 17 additions & 0 deletions packages/happy-dom/src/dom/DOMRectList.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
import DOMRect from './DOMRect.js';
import * as PropertySymbol from '../PropertySymbol.js';

/**
* DOM Rect List.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMRectList
*/
export default class DOMRectList extends Array<DOMRect> {
/**
* Constructor.
*
* @param illegalConstructorSymbol Illegal constructor symbol.
*/
constructor(illegalConstructorSymbol: symbol) {
super();
// "illegalConstructorSymbol" can be "1" when calling the "splice()" method
if (
<number>(<unknown>illegalConstructorSymbol) !== 1 &&
illegalConstructorSymbol !== PropertySymbol.illegalConstructor
) {
throw new TypeError('Illegal constructor');
}
}

/**
* Returns item by index.
*
Expand Down
7 changes: 6 additions & 1 deletion packages/happy-dom/src/dom/DOMStringMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@ export default class DOMStringMap {
/**
* Constructor.
*
* @param illegalConstructorSymbol Illegal constructor symbol.
* @param element Element.
*/
constructor(element: Element) {
constructor(illegalConstructorSymbol: symbol, element: Element) {
if (illegalConstructorSymbol !== PropertySymbol.illegalConstructor) {
throw new TypeError('Illegal constructor');
}

// Documentation for Proxy:
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy
return new Proxy(this, {
Expand Down
63 changes: 26 additions & 37 deletions packages/happy-dom/src/dom/dom-matrix/DOMMatrix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,8 @@ export default class DOMMatrix extends DOMMatrixReadOnly {
* @returns Self.
*/
public scaleSelf(
scaleX = 1,
scaleY = 1,
scaleX?: number,
scaleY?: number,
scaleZ = 1,
originX = 0,
originY = 0,
Expand Down Expand Up @@ -406,49 +406,41 @@ export default class DOMMatrix extends DOMMatrixReadOnly {
}

/**
* Set self to be multiplied by each of 3 rotation matrices about the major axes, first X, then Y, then Z.
* Sets self to be multiplied by a rotation matrix with the given axis and `angle`.
*
* @param [x] X component of the rotation, or Z if Y and Z are null.
* @param [y] Y component of the rotation value.
* @param [z] Z component of the rotation value.
* @param [x] The X component of the axis vector.
* @param [y] The Y component of the axis vector.
* @param [z] The Z component of the axis vector.
* @param [angle] Angle of rotation about the axis vector, in degrees.
* @returns Self.
*/
public rotateSelf(x = 0, y?: number, z?: number): DOMMatrixReadOnly {
this[PropertySymbol.rotateSelf](x, y, z);
public rotateAxisAngleSelf(x = 0, y = 0, z = 0, angle = 0): DOMMatrixReadOnly {
this[PropertySymbol.rotateAxisAngleSelf](x, y, z, angle);
return this;
}

/**
* Sets self to be multiplied by a rotation matrix with the given axis and `angle`.
* Set self to be multiplied by each of 3 rotation matrices about the major axes, first X, then Y, then Z.
*
* @param [x] The X component of the axis vector.
* @param [y] The Y component of the axis vector.
* @param [z] The Z component of the axis vector.
* @param [angle] Angle of rotation about the axis vector, in degrees.
* @param [x] X component of the rotation, or Z if Y and Z are null.
* @param [y] Y component of the rotation value.
* @param [z] Z component of the rotation value.
* @returns Self.
*/
public rotateAxisAngleSelf(
x?: number,
y?: number,
z?: number,
angle?: number
): DOMMatrixReadOnly {
this[PropertySymbol.rotateAxisAngleSelf](x, y, z, angle);
public rotateSelf(x = 0, y?: number, z?: number): DOMMatrixReadOnly {
this[PropertySymbol.rotateSelf](x, y, z);
return this;
}

/**
* Sets self to be multiplied by a skew matrix along the X axis by the given angle.
*
* Not implemented in Happy DOM yet.
*
* @param [_x] X-Axis skew.
* @param [_y] Y-Axis skew.
* @param [x] X-Axis skew.
* @param [y] Y-Axis skew.
*/
public rotateFromVectorSelf(_x: number = 0, _y: number = 0): DOMMatrixReadOnly {
throw new TypeError(
`Failed to execute 'rotateFromVectorSelf' on '${this.constructor.name}': Method has not been implemented in Happy DOM yet.`
);
public rotateFromVectorSelf(x = 0, y = 0): DOMMatrixReadOnly {
this[PropertySymbol.rotateFromVectorSelf](x, y);
return this;
}

/**
Expand Down Expand Up @@ -477,26 +469,23 @@ export default class DOMMatrix extends DOMMatrixReadOnly {
* Set self to be specified as matrix flipped on X-axis.
*/
public flipXSelf(): DOMMatrixReadOnly {
throw new TypeError(
`Failed to execute 'flipXSelf' on '${this.constructor.name}': Method has not been implemented in Happy DOM yet.`
);
this[PropertySymbol.flipXSelf]();
return this;
}

/**
* Set self to be specified as matrix flipped on Y-axis.
*/
public flipYSelf(): DOMMatrixReadOnly {
throw new TypeError(
`Failed to execute 'flipYSelf' on '${this.constructor.name}': Method has not been implemented in Happy DOM yet.`
);
this[PropertySymbol.flipYSelf]();
return this;
}

/**
* Set self to be specified as matrix inverted.
*/
public invertSelf(): DOMMatrixReadOnly {
throw new TypeError(
`Failed to execute 'invertSelf' on '${this.constructor.name}': Method has not been implemented in Happy DOM yet.`
);
this[PropertySymbol.invertSelf]();
return this;
}
}
Loading

0 comments on commit 9a44a9a

Please sign in to comment.