For testing purposes I decided to test a function I have written which returns a DOMRect
object.
In the console I can see that the DOMRect is intact and has all of its properties. However, when I have JSON.stringify(rect)
(where rect is the variable with the return result), I get the empty object {}
.
I don’t know whether that means that there’s something special about a DOMRect
, or whether JSON.stringify
doesn’t do what I thought it would do, which is to serialize the properties of an object.
The question is: why won’t JSON.stringify work on a DOMRect
(and will it also fail on some other obects?
FWIW, I am testing on a current Mac, and have tried both Firefox and Webkit.