- From: Silvia Pfeiffer <silviapfeiffer1@gmail.com>
- Date: Sat, 15 Feb 2014 15:59:55 +1100
- To: Brendan Long <self@brendanlong.com>
- Cc: public-html <public-html@w3.org>
On Sat, Feb 15, 2014 at 2:31 PM, Brendan Long <self@brendanlong.com> wrote: > > I'm still wondering about my original two questions: > > According to this, .text can be null: > > The text attribute, on getting, must return UTF-16 text converted from data > of thetext track cue that the TextTrackCue object represents. If a > conversion of the content in data is not possible, e.g. because the UA is > unable to identify the encoding, it must return null. > > So shouldn't the WebIDL say "DOMString?" with a question mark to indicate > that it's nullable? Good idea. https://www.w3.org/Bugs/Public/show_bug.cgi?id=24676 > The other question is, is there a general rule where we take a copy of > objects in constructors? Otherwise we get weird behavior like this: > >> buf = new ArrayBuffer(4) > < ArrayBuffer > >> bufView = new Uint16Array(buf) > < [0, 0] >> bufView[0] = "hi".charCodeAt(0=) > < 104 >> bufView[1] = "hi".charCodeAt(1) > < 105 > >> cue = new DataCue(1, 2, buf) > < DataCue > >> cue.text > < "hi" The constructor is just a function. So, its parameters could be interpreted by the object either as an object to copy or as a storage location. E.g. Uint16Array provides both: https://developer.mozilla.org/en-US/docs/Web/API/Uint16Array In our case, I thought it was clear that a copy was taken and stored withing the DataCue object. >> bufView[0] = "no".charCodeAt(0) > < 110 >> bufView[1] = "no".charCodeAt(1) > < 111 >> cue.text > < "no" > > I'm not sure if I was implementing this wrong, Yes, I think that's wrong. That should not be possible. > or if we need to change the > spec to specify that .data is a copy of the ArrayBuffer we give it. Well, the spec for the constructor says "The data argument sets the raw data of the text track cue." Not sure if "set" implies copying. I wonder if we need to say that .data is a "structured clone" of the data parameter object (referring to "2.7.6 Safe passing of structured data")? Silvia.
Received on Saturday, 15 February 2014 05:00:43 UTC