Closed joeldenning closed 8 years ago
JSON.stringify(window)
in browsers and JSON.stringify(global)
in node already have this problem, since they already contain window.window
and global.global
respectively. Naively stringifying an object, especially a global one, just isn't something that anyone needs to be concerned about :-)
I totally agree that stringifying the window doesn't make sense. What I was thinking was that perhaps stringifying the System object might make a bit more sense, especially since there are many other proposals (both ecmascript specs and in userland) that plan on putting properties on the System object (i.e., whatwg/loader's System.loader
spec, or SystemJS' configuration options that are put on the System object).
However, as I think about this more, I don't think that that is an especially strong use case either. And I can't think of any other reason why a circular structure would be undesirable. So I agree that this is not really a problem.
Reflecting/introspecting on System
, absolutely! Stringifying it en-masse, however - especially when JSON doesn't support functions and most of the useful things are functions - doesn't seem that likely.
If I understand the spec correctly,
System.global === System.global.System.global === System.global.System.global.System.global
. Are there any problems with this? Potentially thatJSON.stringify(System)
will throw errors since it now contains circular references.