domgeom
Note: this is a work in progress.
A polyfill for the DOM Geometry Interfaces Level 1 for JavaScript runtimes that don’t include them.
Installation
domgeom is available as an npm package:
npm install --save domgeom
Usage
import {
DOMMatrix,
DOMMatrixReadOnly,
DOMPoint,
DOMPointReadOnly,
DOMRect,
DOMRectReadOnly,
DOMQuad
} from 'domgeom';
globalThis.DOMMatrix = DOMMatrix;
globalThis.DOMMatrixReadOnly = DOMMatrixReadOnly;
globalThis.DOMPoint = DOMPoint;
globalThis.DOMPointReadOnly = DOMPointReadOnly;
globalThis.DOMRect = DOMRect;
globalThis.DOMRectReadOnly = DOMRectReadOnly;
globalThis.DOMQuad = DOMQuad;
Differences from the spec
DOMMatrixReadOnly.prototype.toString()
throws an Error
instead of an "InvalidStateError" DOMException
.
- The read-only interfaces are not actually read only (it just seemed tedious to implement).
Also note that due to numerical errors there may be slight differences in the matrix values compared to browser environments. In tests, rounding the values before comparisons is recommended.
Further reading