On Apr 26, 2008, at 3:07 PM, Jeff Walden wrote:
Maciej Stachowiak wrote:
If anything this event should dispatch to the window, not the
document, since that is what gets the postMessage call. But posting
to the document and bubbling to the window seems ok too.
The event currently doesn't bubble to accommodate <event-source>:
http://lists.whatwg.org/htdig.cgi/commit-watchers-whatwg.org/2008/000436.html
So right now, either you use a bubbling listener (capturing works
too, although the web may end up dictating that that's a bug that
won't be fixt) on the document or a capturing listener (ugh) on
window or you don't get it. I'm not entirely sure why the event
doesn't bubble for postMessage; it seems like a postMessage event
doesn't necessarily have to do the same thing as an <event-source>
event, but maybe there's precedent here that I don't know.
As far as I can tell the event is dispatched at the document only
because Opera's original implementation had postMessage on
document. I sort of prefer dispatching to the window as well, but
that change would have to be made ASAP to make Firefox 3. It's a
one-line change (+30ish for addEventListener calls in tests, also
easy to do), as is the bubbling change, but it's extraordinarily
late for us to make these changes (async cuts it very, very fine as-
is), and nobody would be happy if the spec converged on something
that Firefox 3 didn't actually implement.
I hope this can be addressed soon, and I feel your pain. But in Safari
3.1 we actually dropped postMessage at the last minute because of too
many spec changes, and the spec changed in major ways after Opera
actually shipped their implementation, so it's not like changes here
are unprecedented and certainly Firefox is not being singled out.
(On the substance, I think dispatching to the window would be better
based on your comments.)
Cheers,
Maciej