W3C home > Mailing lists > Public > whatwg@whatwg.org > August 2008

[whatwg] hashchange only dispatched in history traversal

From: Ian Hickson <ian@hixie.ch>
Date: Thu, 21 Aug 2008 23:09:26 +0000 (UTC)
Message-ID: <Pine.LNX.4.62.0808212304270.19930@hixie.dreamhostps.com>
On Thu, 21 Aug 2008, Garrett Smith wrote:
> 
> HTML 5 expands "hashchange" to any element. Any element, such as div
> or pre? How can you know if an element supports "hashchange" or not?

I'm not sure what you mean. In HTML5, all event handler _attributes_ can 
be placed on any element, but that doesn't mean that the event will be 
fired by the UA at any element. The spec only fires the event at the body 
element.


> "hashchange" seems closely related to the Location interface, so it 
> would seem to make sense to have "hashchange" implemented for objects 
> that implement Location.
> 
> Has this been considered?

Yes, but the benefit of being able to do <body onhashchange=""> outweighs 
the logicalness of dispatching events to the Location object.


> >> I'm not sure what that has to do with the body element.
> >
> > Nothing especially, except that that is where the event is fired, so 
> > that you can do <body onhashchange="...">.
> 
>  "fires at the body element"  sounds as if the event is firing itself, 
> at the body. Instead, say the EventTarget fires the event. For example: 
> "The window fires the hashchange event."

I disagree with your interpretation of the terminology, but that's not 
just editorial so it's not a big deal.


> Body event handler attributes cascading to window is unclear and creates 
> ambiguity as to what the event is being attached to.
> 
> <body onmousedown="alert(this)">
> 
> alerts "window" in Firefox 3. The mousedown event fires anywhere, not 
> just on the body. This creates ambiguity. So it is a practice that 
> should be avoided in attempt to be cross browser. Has this problem been 
> considered?

Yeah, this is an open issue. I'm hoping that the DOM Events spec handles 
it.


> 1) add a note about bubbling. hashchange events bubble

Per the spec, it doesnt.


> 2) replace the "fires at the body element" with "the EventTarget fires 
> the event"

I disagree with this interpretation of the terminology.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
Received on Thursday, 21 August 2008 16:09:26 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:04 UTC