Re: [XBL] Accessing flattened tree parents of a shadow tree

Hi Ian.

Cameron McCormack:
> > For example, the SVGElement interface has a property ownerSVGElement, 
> > which simply returns the closest ancestor svg element.

Ian Hickson:
> How about:
> 
>                get ownerSVGElement() {
>                    var owner = this.boundElement.parentNode;
>                    while (owner && !(owner instanceof SVGSVGElement))
>                      owner = owner.parentNode;
>                    return owner;
>                }

This won’t work if the svg:svg ancestor element is more than one shadow
scope away.  For example:

  <binding element="ex|one">
    <template>
      <ex:two/>
    </template>
  </binding>
  <binding element="ex|two">
    <template>
      …
    </template>
    <implementation>
      ({
         get ownerSVGElement() {
    var owner = this.boundElement.parentNode;
    while (owner && !(owner instanceof SVGSVGElement))
      owner = owner.parentNode;
    return owner;
         }
      })
    </implementation>
  </binding>

  <svg:svg>
    <ex:two id="x"/>
    <script>
      alert(document.getElementById('x').ownerSVGElement);
    </script>
  </svg:svg>

which won’t be an uncommon case, would alert "null".

> > there is no way for the ownerSVGElement getter to traverse up the 
> > flattened tree to find the svg element to return.
> 
> Why would it go up the flattened tree? SVG just says its the nearest 
> parent 'svg' node. (Though it doesn't say what should happen if there 
> isn't one.)

It would go up the flattened tree because that is what makes the most
sense from the point of view of the rendered tree of SVG elements.

> > The SVG WG requests that a feature that allows script to traverse up the 
> > flattened tree be added.
> 
> Unfortunately, I've received exactly the opposite request -- namely to 
> ensure data hiding and prevent navigation of the flattened tree -- so I 
> wouldn't be able to address both requests. I have marked your request as 
> being a potential formal objection.

I certainly can understand disallowing access to the shadow tree from
the bound element, as that does break the encapsulation.  Since the
binding can get out one level (by using this.boundElement), it should be
able to get out arbitrary levels to allow the functionality we are
requesting.

Thanks,

Cameron
-for the SVG WG

-- 
Cameron McCormack, http://mcc.id.au/
 xmpp:heycam@jabber.org  ▪  ICQ 26955922  ▪  MSN cam@mcc.id.au

Received on Wednesday, 14 February 2007 02:19:01 UTC