- From: Boris Zbarsky <bzbarsky@MIT.EDU>
- Date: Fri, 10 Jul 2009 16:01:01 -0700
- To: Andrew Fedoniouk <news@terrainformatica.com>
- CC: Philip Taylor <pjt47@cam.ac.uk>, HTML WG <public-html@w3.org>
Andrew Fedoniouk wrote: >> if(nodeType != null && nodeType != 'undefined') { >> var remNodes = atNode.getElementsByTagName(nodeType); >> } >> else { >> var remNodes = atNode.childNodes; >> } >> var nodeLim = remNodes.length; >> for(var x = 0; x<nodeLim; x++) { >> atNode.removeChild(remNodes[0]); >> } >> > I am not sure this piece will run at all. > remNodes will not be seen outside blocks where they declared: { var > remNodes = whatever } I suggest reading up on variable scoping in ECMAScript. var has function scope. In fact, the following is a perfectly valid ECMAScript construct: function foo() { alert(x); var x; } and will alert undefined. Removing the var declaration will throw an exception due to x not being defined. > But this counts as a proof that it might be some code in the wild that > rely on this. Sure is (esp. note that this is a library used by all sorts of sites). -Boris
Received on Friday, 10 July 2009 23:01:49 UTC