You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add Window.postMessage override that takes a dictionary #3799
It makes it so that you can more consistently do X.postMessage(data, transfer_opt, options_opt) throughout the platform. Currently there are 7 postMessage APIs, and, infuriatingly, all of them except Window conform to this pattern.
It provides a nice safe default targetOrigin of "/", as opposed to the "*" I see recommended in lots of copy-and-paste-prone tutorials.
window.postMessage(data, [t], { targetOrigin: "https://example.com/" }) is much more understandable to the reader than window.postMessage(data, "https://example.com/", [t]).
(I realize some folks might not find the implementation cost of this change in and of itself compelling, and might need to first be convinced of the value and design choices in https://github.com/dtapuska/useractivation. That's fine too. But with my editor and web developer hats on, I really want this change, independent of any future options we add to this dictionary.)
Providing a consistent API is fairly compelling to me. I do wonder if requiring the transfer argument forever will turn out to be a mistake. That makes more sense as part of a dictionary to me.
with transfer being part of the options dictionary?
The previous comment from @smaug---- seemed to be in favor of making transfer part of the dictionary since it is optional and often empty. However, if we do so, then Window's postMessage is no longer consistent with other postMessage APIs, is it? It seemed like some people wanted that.
Personally, I do not believe that the consistency argument alone would be worth the trouble to implement this. I get that switching to a dictionary would be good if we added more options. However, we are currently not adding any options, are we? My preference would be to hold off on making a switch to dictionary until we actually need it (because we're adding options). It is unclear to me what those options will be (all other postMessage APIs do not require any options).
Activity
dtapuska commentedon Jul 5, 2018
Related issue is #1983
Add postMessage override that provides WindowPostMessageOptions.
domenic commentedon Jul 10, 2018
Folks, what do you think?
https://github.com/dtapuska/useractivation gives one motivation (see also #1983), wanting to add a new option to postMessage(). However, I'd argue that even without that motivation, this is a good idea for the platform and for web developers:
X.postMessage(data, transfer_opt, options_opt)throughout the platform. Currently there are 7 postMessage APIs, and, infuriatingly, all of them except Window conform to this pattern.window.postMessage(data, [t], { targetOrigin: "https://example.com/" })is much more understandable to the reader thanwindow.postMessage(data, "https://example.com/", [t])./ccing @smaug---- as I know he's been looking at https://github.com/dtapuska/useractivation. Then @travisleithead and @hober for Edge and Safari?
(I realize some folks might not find the implementation cost of this change in and of itself compelling, and might need to first be convinced of the value and design choices in https://github.com/dtapuska/useractivation. That's fine too. But with my editor and web developer hats on, I really want this change, independent of any future options we add to this dictionary.)
Add postMessage override that provides WindowPostMessageOptions.
dtapuska commentedon Jul 19, 2018
@smaug---- @travisleithead @hober Any thoughts on this proposal?
rniwa commentedon Jul 19, 2018
@cdumez
smaug---- commentedon Jul 20, 2018
So far I haven't seen good reasoning why to change the old API.
annevk commentedon Jul 23, 2018
Providing a consistent API is fairly compelling to me. I do wonder if requiring the transfer argument forever will turn out to be a mistake. That makes more sense as part of a dictionary to me.
smaug---- commentedon Jul 23, 2018
ok, fine, consistency would be good, and I agree transfer as a part of dictionary would be better, since it is often empty.
Add postMessage override that provides WindowPostMessageOptions.
dtapuska commentedon Jul 25, 2018
@annevk @smaug---- how does the latest revision look?
annevk commentedon Jul 26, 2018
@dtapuska I haven't reviewed in detail, but that looks okay to me. I was worried that sequence and dictionary would not be https://heycam.github.io/webidl/#dfn-distinguishable but it seems they are so the other
postMessage()methods could be similarly overloaded.cdumez commentedon Jul 26, 2018
So is the latest proposal:
or
with
transferbeing part of theoptionsdictionary?The previous comment from @smaug---- seemed to be in favor of making
transferpart of the dictionary since it is optional and often empty. However, if we do so, then Window's postMessage is no longer consistent with other postMessage APIs, is it? It seemed like some people wanted that.Personally, I do not believe that the consistency argument alone would be worth the trouble to implement this. I get that switching to a dictionary would be good if we added more options. However, we are currently not adding any options, are we? My preference would be to hold off on making a switch to dictionary until we actually need it (because we're adding options). It is unclear to me what those options will be (all other postMessage APIs do not require any options).
25 remaining items
travisleithead commentedon Sep 26, 2018
Late reply, but I support this--also glad to see transfer included in the dictionary as param 2.
Add postMessage overloads that provide PostMessageOptions.
Add postMessage overloads that provide PostMessageOptions.
Add postMessage overrides that take options
Add postMessage overrides that take options
Bug 1479041 [wpt PR 12212] - Move the transfer object into WindowPost…
Bug 1479041 [wpt PR 12212] - Move the transfer object into WindowPost…
Bug 1482237 [wpt PR 12385] - Add a PostMessageOptions API to workers …
Bug 1482237 [wpt PR 12385] - Add a PostMessageOptions API to workers …
Bug 1479041 [wpt PR 12212] - Move the transfer object into WindowPost…
Bug 1482237 [wpt PR 12385] - Add a PostMessageOptions API to workers …
Implement PostMessageOptions for postMessage
Add postMessage overrides that take options