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

[whatwg] Preventing nested click() calls

From: Ian Hickson <ian@hixie.ch>
Date: Tue, 16 Dec 2008 23:32:29 +0000 (UTC)
Message-ID: <Pine.LNX.4.62.0812162326220.30225@hixie.dreamhostps.com>
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.   `._.-(,_..'--(,_..'`-.;.'
Received on Tuesday, 16 December 2008 15:32:29 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:08:46 UTC