Last Tuesday I blogged about event delegation on the iPhone and concluded that the click event, contrary to all others, is not delegated upward unless you also give the element the user clicks on an onclick event handler (which may be empty).
Turns out this is not the whole story.
First Miller Medeiros published a test page where event delegation does work, although not at the document level. It turns out that the click event bubbles up fine, but for some reason stops before reaching the
<body> element. Thus it never arrives at the document.
That confuses me mightily. In my first piece I theorised that the Safari team had disabled event delegation because of memory issues, but with Miller’s additional material it becomes clear that this theory cannot be true. If memory were the issue, why allow event bubbling within the
So my nice theory is wrong. But I still have no clue why the bubbling stops just below the
Then Jimmy Byrum published a test page that is exactly the same as my original one, except that he added
cursor: pointer to the clickable div. Lo and behold: the div is clickable and the event bubbles up absolutely fine.
Occasionally you encounter browser bugs that just defy any rational explanation. This is one of those times.
I’m around at the following conferences:
Comments are closed.