What is Rect function in Chrome/Firefox for?
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());