Description
Issue or Feature
In typeson-registry
, we need to detect object type in order to properly serialize objects for JSON.
For some reason, on Node 14 in Linux (Xenial), this is failing, but it is not failing in Node 10 or 12 in Linux, nor in Node 14 on the Mac. This is failing on Node 14.7, but not in Node 10 or 12.
In performing some logging, it turns out that calling Object.prototype.toString.call()
on ImageData
objects will give [object Object]
in Node 14.7, but in other environments, as expected, it gives [object ImageData]
.
Perhaps this is due to a proper fix in Node 14.7 since objects should only give [object Object]
unless Symbol.toStringTag
is used, but in any case, if it is not doing so already, I'd hope your build process could add the equivalent of the following to ImageData
to ensure it behaves as in the browser so that one can detect the type of such objects (this approach will, unlike instanceof
, also ensure detection continues to work cross-frame when used in polyglot browser code).
get [Symbol.toStringTag] () {
return 'ImageData';
}
Steps to Reproduce
const {ImageData} = require('canvas');
const imageData = new ImageData(1, 3);
console.log(Object.prototype.toString.call(imageData));
// Expected `[object ImageData]` but get `[object Object]` in Node 14 Linux
Your Environment
- Version of node-canvas (output of
npm list canvas
oryarn list canvas
): 2.6.1 - Environment (e.g. node 4.2.0 on Mac OS X 10.8): Node 14.7 on Linux xenial or MacOSX; see the Travis job
Thanks!