Re: [geometry] DOMQuad is weird

On Wed, Oct 19, 2016 at 8:39 PM, Simon Fraser <smfr@me.com> wrote:

> > On Oct 19, 2016, at 3:02 pm, Tab Atkins Jr. <jackalmage@gmail.com>
> wrote:
> >
> > On Wed, Oct 19, 2016 at 12:00 PM, Simon Fraser <smfr@me.com> wrote:
> >> As a naive JavaScript author, I would consider a point to be a primitive
> >> type that's copied by value.
> >>
> >> Dean points out that the primitive types are actually DOMPoint.x and
> >> DOMPoint.y, so what I wrote above is "expected" JS behavior.
> >
> > Right. Given the attribute-based API, it's generally expected JS
> > behavior that you can detach an object, alter it, and the parent
> > object (which is still referencing it) will see that change.  It's the
> > same behavior you'd get from the original object you passed in to the
> > constructor.
> >
> >> Maybe DOMQuad should be entirely read-only, or should return copies
> >> of points (getP1(), getP2() etc).
> >
> > That would indeed communicate that the points are likely to be fresh
> > objects, but it's a rather non-idiomatic thing for such simple
> > objects.  Readonly is possible, but that precludes some use-cases.
>
> Why not follow DOMPoint and DOMRect and have read-only and mutable
> variants?
>

Doesn't that seem a bit like overkill?
Are there places in the platform where an assignment of an attribute
creates a copy? I know that there's a desire to not have live objects that
point to something on the native side but that doesn't apply here.

Also, Firefox is already shipping DOMQuad with this behavior.

Received on Thursday, 20 October 2016 06:16:06 UTC