Re: [geometry] DOMQuad is weird

> On Oct 19, 2016, at 3:02 pm, Tab Atkins Jr. <> wrote:
> On Wed, Oct 19, 2016 at 12:00 PM, Simon Fraser <> 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?


Received on Thursday, 20 October 2016 03:39:41 UTC