[whatwg] Preventing nested click() calls
Ian Hickson
ian at hixie.ch
Tue Dec 16 15:32:29 PST 2008
On Mon, 10 Mar 2008, Antti Koivisto wrote:
>
> WebKit, Firefox and IE all implement a protection mechanism against re-
> entering click() on the same element:
>
> <input type="checkbox" onclick="this.click()">
>
> WebKit (and based on testing Firefox) make click() a no-op when invoked
> as a result of a click event generated by calling click() on the same
> element. For IE this seems to be true even for user generated click
> events.
On Fri, 14 Mar 2008, Erik Arvidsson wrote:
>
> To me it just seems wrong to prevent this. This is in theory no
> different than a recursive call and just like recursion it can end up in
> an infinite loop. Having a limit seems OK since most JavaScript engines
> already have a limit on the size of the call stack.
On Fri, 14 Mar 2008, Antti Koivisto wrote:
>
> In practice all browsers already treat click() as a special case.
> Removing the nesting protection completely (and relying on js stack
> limits) would break web sites so it is not an option. The only question
> is whether the limit should be 1 or some other number. Matching the
> existing implementations and disallowing nesting seems like a right
> thing to do here.
On Fri, 14 Mar 2008, Geoffrey Garen wrote:
>
> You're right, it is no different *in theory*. It is, however, different
> in practice. If we allow click() to re-enter itself, popular websites
> stop working.
On Mon, 17 Mar 2008, Antti Koivisto wrote:
>
> Hixie asked for a concrete example of page that breaks if click() limit
> is removed so here is one:
>
> 1. Go to http://forums.whirlpool.net.au/
> 2. Under Whirlpool (righthand side) go to 'Feedback Forum'
> 3. Click on any Forum
> 4. Click reply to this post (righthand) side
> 5. Login (you need to create an account)
> 6. Click 'Show quoted' box
>
> Without click() protection the last step hangs the browser (at least
> until javascript time limit kicks in). Script is sufficiently complex
> and slow to execute that it won't hit javascript stack limit. I tried
> having a minimum nesting limit that passes Acid3 (10 iterations) and
> that too produces a noticeable ~1s pause. On mobile class hardware that
> would be a complete hang.
I've added the reentrancy block to HTML5.
Cheers,
--
Ian Hickson U+1047E )\._.,--....,'``. fL
http://ln.hixie.ch/ U+263A /, _.. \ _\ ;`._ ,.
Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.'
More information about the whatwg
mailing list