Skip to content

Make it easy to synthesize objects typically created by the UA? #51

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

Closed
RByers opened this issue Mar 4, 2017 · 7 comments
Closed

Make it easy to synthesize objects typically created by the UA? #51

RByers opened this issue Mar 4, 2017 · 7 comments
Assignees

Comments

@RByers
Copy link

RByers commented Mar 4, 2017

Often the 99% use case for an API involves the UA generating objects of a particular type (eg. MouseEvent). IMHO it's important to also support the 1% case where subject objects are created by script and are (mostly) indistinguishable from the UA-generated ones.

For example, a library/component designed just for MouseEvent could be driven via another component that consumes TouchEvents by synthesizing fake MouseEvent instances. Also this is often necessary to enable good unit testing of components.

Should the design principles say something about this?

@RByers
Copy link
Author

RByers commented Mar 4, 2017

Here's an example where @domenic says:

Having objects be constructed magically by the platform should be reserved for truly special cases. One example use case is mocking libraries.

@domenic
Copy link
Member

domenic commented Mar 4, 2017

I can take this. I have been dispensing opinions around constructors for a long time, and having it written down somewhere would be great. It's a bit subtle sometimes---see e.g. w3c/wot-scripting-api#3 where I came to the conclusion that there was too much UA magic for constructors to make sense---so this will be an interesting entry to write.

@domenic domenic self-assigned this Mar 4, 2017
@RByers
Copy link
Author

RByers commented Mar 4, 2017

Great, looking forward to gleaning your wisdom!

@torgo
Copy link
Member

torgo commented Jul 26, 2017

@domenic you assigned yourself on this. Are you planning to submit a PR?

@domenic
Copy link
Member

domenic commented Jul 26, 2017

Somehow this fell off my to-do list. Let me bump it back up.

@dbaron
Copy link
Member

dbaron commented Apr 6, 2018

Should this be merged with #44?

@dbaron
Copy link
Member

dbaron commented Apr 6, 2018

Oh, except there's a PR for this in #80. :-)

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

No branches or pull requests

5 participants