Re: [heycam/webidl] Consider simplifying serializers (#188)

Talking a bit with @tobie in IRC, I'm hopeful that we can come up with something as simple as "declare your own toJSON method, always". Then you can either go completely custom (using a custom dictionary type, for example, as the return value, or returning a certain string like URL wants to) or you can call some helper abstract op we define in Web IDL that gives you some kind of "serialize all attributes" behavior.

The `jsonifier;` solution @bzbarsky describes seems a bit too powerful: I would anticipate we want to provide a helper that just always serializes the entire proto chain, and maybe, if there are cases in the platform that want it, one that serializes only own properties. I don't think we need the ability for each link in the inheritance chain to opt-in to whether or not its attributes should be serialized. Do we?

----

Another issue: the spec doesn't currently seem clear on whether the default serializer observably does a `Get(this, "attributeName")` or not. It just says:

> Let V be the value of the attribute with identifier i.

This seems pretty bogus...

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/heycam/webidl/issues/188#issuecomment-268608298

Received on Wednesday, 21 December 2016 18:53:25 UTC