[fxtf-drafts] [geometry] WebIDL serializer has been deprecated in favor of toJSON operation

tobie has just created a new issue for https://github.com/w3c/fxtf-drafts:

== [geometry] WebIDL serializer has been deprecated in favor of toJSON operation ==
Hi!

We recently [deprecated WebIDL serializers][0]. You can now directly specify [toJSON operations][1] instead, which you previously weren't allowed to do.

To deal with common cases, we added a new [\[Default\] extended attribute][2] which triggers the [default toJSON operation][3] that behaves similarly to how `serializers={attributes}` or `serializers={attributes, inherit}` used to. That is, it serializes all attributes that are of a [JSON type][4] into a vanilla JSON object.

It seems the following interfaces in this spec are impacted by this change:

- [ ] [`DOMPointReadOnly`](https://drafts.fxtf.org/geometry/#dompointreadonly)
- [ ] [`DOMRectReadOnly`](https://drafts.fxtf.org/geometry/#domrectreadonly)
- [ ] [`DOMQuad`](https://drafts.fxtf.org/geometry/#domquad)
- [ ] [`DOMMatrixReadOnly`](https://drafts.fxtf.org/geometry/#dommatrixreadonly)

All of these seem good candidate for the [default toJSON operation][3], so the below should be all you need:

```webidl
 // Extended attributes
interface DOMPointReadOnly {
    [NewObject] static DOMPointReadOnly fromPoint(optional DOMPointInit other);

    readonly attribute unrestricted double x;
    // Etc...

    DOMPoint matrixTransform(optional DOMMatrixInit matrix);

    [Default] object toJSON();
};

// Extended attributes
interface DOMRectReadOnly {
    [NewObject] static DOMRectReadOnly fromRect(optional DOMRectInit other);

    readonly attribute unrestricted double x;
    // Etc...

    [Default] object toJSON();
};

// Extended attributes
interface DOMQuad {
    [NewObject] static DOMQuad fromRect(optional DOMRectInit other);
    // Etc...

    [SameObject] readonly attribute DOMPoint p1;
    // Etc...

    [NewObject] DOMRect getBounds();

    [Default] object toJSON();
};

// Extended attributes
interface DOMMatrixReadOnly {
    [NewObject] static DOMMatrixReadOnly fromMatrix(optional DOMMatrixInit other);
    // Etc...
    
    [Exposed=Window] stringifier;
    
    [Default] object toJSON();
};
```
I'm sorry for the inconvenience this causes, but our hope is that this ultimately makes things a lot simpler and clearer for everybody.

Please feel free to reach out if you have any questions.

Thanks!

[0]: https://github.com/heycam/webidl/commit/a505f33
[1]: https://heycam.github.io/webidl/#idl-tojson-operation
[2]: https://heycam.github.io/webidl/#Default
[3]: https://heycam.github.io/webidl/#es-default-tojson
[4]: https://heycam.github.io/webidl/#dfn-json-types

Please view or discuss this issue at https://github.com/w3c/fxtf-drafts/issues/200 using your GitHub account

Received on Friday, 23 June 2017 00:00:32 UTC