- From: Simon Fraser <smfr@me.com>
- Date: Wed, 19 Oct 2016 20:39:01 -0700
- To: "Tab Atkins Jr." <jackalmage@gmail.com>
- Cc: Rik Cabanier <cabanier@gmail.com>, "public-fx@w3.org" <public-fx@w3.org>
> 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? Simon
Received on Thursday, 20 October 2016 03:39:41 UTC