W3C home > Mailing lists > Public > public-html@w3.org > January 2009

Re: DOM traversal ambiguity question

From: Ian Hickson <ian@hixie.ch>
Date: Wed, 14 Jan 2009 02:45:34 +0000 (UTC)
To: Ory Segal <orysegal@gmail.com>
Cc: public-html@w3.org
Message-ID: <Pine.LNX.4.62.0901140243090.7181@hixie.dreamhostps.com>

On Thu, 14 Aug 2008, Ory Segal wrote:
>
> [...] a child document, child_frame.html, which includes the following 
> HTML:
> 
> [...]
>         <script>
>             if(parent.someObject) { do_something(); }
>         </script>
> 
> [...] Things get a bit weird when the parent document, includes another 
> element with the same name such as the JavaScript object - for example - 
> here's an alternate parent document:
> 
> <html>
>     <head>
>         <script>
>             var someObject = true;
>         </script>
>     </head>
>     <body>
>         <iframe name="someObject"></iframe>
>         <iframe src="child_frame.html"></iframe>
>     </body>
> </html>
> 
> In this scenario, when the child tries to access parent.someObject - 
> there is an ambiguity. The browser cannot know, if the child is 
> referring to the other child element with the same name, or if the child 
> is trying to access the JavaScript object. (both are accessed through 
> the DOM in the same manner)

HTML5 now defines exactly what should happen here, so which the ambiguity 
does exist in terms of this being very confusing code, at least browsers 
now have an unambiguous definition of what is the correct behaviour.

HTH,
-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
Received on Wednesday, 14 January 2009 02:46:12 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 9 May 2012 00:16:28 GMT