Re: DOM traversal ambiguity question

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 UTC