Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need to define global used to create the ArrayBuffer and Uint8Array in TextEncoder's encode() #150

Open
bzbarsky opened this issue Aug 6, 2018 · 7 comments

Comments

@bzbarsky
Copy link

bzbarsky commented Aug 6, 2018

Firefox and Chrome seem to use the current global. Safari seems to use the relevant global. Edge doesn't implement this API.

@ricea
Copy link
Collaborator

ricea commented Aug 7, 2018

For what it's worth, the TextEncoderStream test expects the Uint8Array to be created in the realm of the constructor: https://github.com/GoogleChromeLabs/text-encode-transform-prollyfill/blob/master/tests/realms.html#L190

For the algorithm for TextEncoderStream I've just copied the equivalent text from TextEncoder.

@bzbarsky
Copy link
Author

bzbarsky commented Aug 7, 2018

For the algorithm for TextEncoderStream I've just copied the equivalent text from TextEncoder.

Can you link to that, please?

@ricea
Copy link
Collaborator

ricea commented Aug 7, 2018

@bzbarsky
Copy link
Author

bzbarsky commented Aug 7, 2018

OK, that wording assumes there is a current Realm. It's not clear to me whether that's true in the streams case, esp. because the algorithm in question is being called async (unlike encode, which is an ES Function and so clearly has a current Realm).

@ricea
Copy link
Collaborator

ricea commented Aug 7, 2018

This may be an unintended side-effect of supplying the CreateTransformStream() operation for specs to use rather than expecting them to create a transformer object and pass it to the TransformStream constructor.

I'd like the realm used to be the realm of the constructor, because that's what the polyfill does, and I've convinced myself that behaviour is correct. Can you propose some wording that would make it unambiguous?

@bzbarsky
Copy link
Author

bzbarsky commented Aug 7, 2018

I'm not sure what the state of the art is right now for wording for this sort of thing in a non-ecmaspeak context when creating an ES object. @domenic do you know where things stand with that?

If I had to make up something, I would just say to create an ArrayBuffer using the constructor from global X and then create a Uint8Array using the constructor from global X or something, since those constructors have no side-effects, this is more or less ok.

@domenic
Copy link
Member

domenic commented Aug 7, 2018

I think we've been even a bit less precise, saying "create an ArrayBuffer in realm X". The hope is to eventually formalize object creation in whatwg/webidl#135. (However that thread says "relevant", which I have an incoming comment on...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants