I've stumbled upon Rect()
function, which is present in both Firefox and Chrome (but not IE 10):
typeof Rect; // "function"
Rect; // function Rect() { [native code] }
But this function isn't accessible neither directly, nor as a constructor:
Rect(); // TypeError: Illegal constructor
new Rect(); // TypeError: Illegal constructor
What is the purpose of this function?
The Rect
is an interface defined in Document Object Model (DOM) Level 2 Style Specification to be used when dealing with CSS rect()
in DOM bindings (such as the Javascript DOM bindings in a browser).
As you noticed you cannot call it as a constructor yourself, but objects implementing this interface are returned by various functions e.g. .getRectValue()
:
function doSomething(v) {
if (v instanceof Rect) {
...
}
else {
...
}
}
doSomething(window.getComputedStyle(elem, null).
getPropertyCSSValue(styleProp).getRectValue());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With