Re: [Prototype-core] JSON encoding inconsistencies with host objects
On Mar 3, 2011, at 2:40 AM, andris wrote: > The question is, should Prototype address it or is it a developers > problem? Isn't the work of a JS library to smooth out these kind of > inconsistencies - for example either falling back to a non native > encoder with WebKit or forcing other browser to follow the same rules? Falling back to a non-native encoder isn't an option; it would result in a _massive_ performance drop, an issue far more severe than the one you're describing. Forcing other browsers to follow the same rules isn't an option; not only would it require us to do non-native JSON encoding for certain code paths, it would also require us to comb an object for any references to host objects to know whether or not we'd need to bypass the native encoder. So it's got to be the developer's problem because there's nothing Prototype can do, even if we wanted to. Cheers, Andrew -- You received this message because you are subscribed to the Google Groups "Prototype: Core" group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to prototype-core-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en
Re: [Prototype-core] JSON encoding inconsistencies with host objects
It will feel SO much better when you stop! I can't see supporting serializing host objects, ever. But I could support doing something to make it ALWAYS error. It IS the developer's problem, but sometimes it helps to have one's mistakes pointed out to you promptly, before you go public... On Thu, Mar 3, 2011 at 12:40 AM, andris wrote: > Hi, > > Native JSON encoding in WbKit based browsers is a bit different from > the others - if an object that is being encoded contains a host object > (DOM elements etc.), then the encoding fails and a TypeError is cast. > > When other browsers simply skip host objects (treated as being empty > "{}"), then WebKit is actually trying to serialize these and ends up > with recursions (element.ownerDocument.body.ownerDocument etc.). > > For example JSON.stringify({elm: document.createElement("div"}) ends > up with an error in WebKit but not in other browsers. See my testpage > here http://node.ee/json.html > > I filed a bug to V8 (http://code.google.com/p/v8/issues/detail? > id=1223) but it was rejected as WorkingAsIntended and I don't blame > them, there really isn't any specs defining correct behavior for this. > > The question is, should Prototype address it or is it a developers > problem? Isn't the work of a JS library to smooth out these kind of > inconsistencies - for example either falling back to a non native > encoder with WebKit or forcing other browser to follow the same rules? > > Best regards, > Andris Reinman > > -- > You received this message because you are subscribed to the Google Groups > "Prototype: Core" group. > To post to this group, send email to prototype-core@googlegroups.com > To unsubscribe from this group, send email to > prototype-core-unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/prototype-core?hl=en > -- You received this message because you are subscribed to the Google Groups "Prototype: Core" group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to prototype-core-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en
[Prototype-core] JSON encoding inconsistencies with host objects
Hi, Native JSON encoding in WbKit based browsers is a bit different from the others - if an object that is being encoded contains a host object (DOM elements etc.), then the encoding fails and a TypeError is cast. When other browsers simply skip host objects (treated as being empty "{}"), then WebKit is actually trying to serialize these and ends up with recursions (element.ownerDocument.body.ownerDocument etc.). For example JSON.stringify({elm: document.createElement("div"}) ends up with an error in WebKit but not in other browsers. See my testpage here http://node.ee/json.html I filed a bug to V8 (http://code.google.com/p/v8/issues/detail? id=1223) but it was rejected as WorkingAsIntended and I don't blame them, there really isn't any specs defining correct behavior for this. The question is, should Prototype address it or is it a developers problem? Isn't the work of a JS library to smooth out these kind of inconsistencies - for example either falling back to a non native encoder with WebKit or forcing other browser to follow the same rules? Best regards, Andris Reinman -- You received this message because you are subscribed to the Google Groups "Prototype: Core" group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to prototype-core-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en