Oh gosh, that is a neverending story. I don't want to know how many hours I spent to figure that behavior correctly. As you mentioned, it behaves differently, so there actually is no "correct". However I'm not that much aware of the W3C spec about this particular instance (if there actuall is one?), but for know, you have to create some logic to have things fired in the correct order. It's pretty disgusting tho.