Loading ...
Sorry, an error occurred while loading the content.

USE elements in Safari - problems with events

Expand Messages
  • richard_smith_ons
    http://bugs.webkit.org/show_bug.cgi?id=14167 Due to the above I get evt.target.getAttributeNS not an object when trying to process the events on a USE
    Message 1 of 4 , Oct 1, 2007
    • 0 Attachment
      http://bugs.webkit.org/show_bug.cgi?id=14167

      Due to the above I get "evt.target.getAttributeNS not an object" when
      trying to process the events on a USE element (Safari 3.0.3 for
      Windows). The conclusion seems to be it's not a bug (!) Is there a
      recommended workaround?

      Thanks

      Richard
    • Erik Dahlstr√∂m
      On Mon, 01 Oct 2007 13:03:18 +0200, richard_smith_ons ... I don t think it s a bug either, if you get an SVGElementInstance object back then clearly it doesn t
      Message 2 of 4 , Oct 1, 2007
      • 0 Attachment
        On Mon, 01 Oct 2007 13:03:18 +0200, richard_smith_ons
        <Richard.M.Smith@...> wrote:

        >
        > http://bugs.webkit.org/show_bug.cgi?id=14167
        >
        > Due to the above I get "evt.target.getAttributeNS not an object" when
        > trying to process the events on a USE element (Safari 3.0.3 for
        > Windows). The conclusion seems to be it's not a bug (!)

        I don't think it's a bug either, if you get an SVGElementInstance object
        back then clearly it doesn't have an ownerDocument.
        You get the "innermost" (in lack of a better word) element that was under
        the mouse cursor, which in the supplied testcase is a rect, as the target
        of the event. Now, if you want the _current_ target instead, then just use
        evt.currentTarget instead, this will be the use element, which does have
        an ownerDocument.

        Opera shows the same behaviour as Safari on this testcase.

        > Is there a recommended workaround?

        Well, you have all of the methods and properties available on the
        SVGElementInstance interface[1] at your disposal. And you could use
        evt.currentTarget if that's what you want.

        Cheers
        /Erik

        [1] http://www.w3.org/TR/SVG11/struct.html#InterfaceSVGElementInstance

        --
        Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
      • richard_smith_ons
        Thanks Erik.
        Message 3 of 4 , Oct 1, 2007
        • 0 Attachment
          Thanks Erik.
        • Andreas Neumann
          yes - this really is a restriction on the use element. If you want to get the reference to a use element, you have to use .currentTarget and place the event
          Message 4 of 4 , Oct 1, 2007
          • 0 Attachment
            yes - this really is a restriction on the use element. If you want to
            get the reference to a use element, you have to use .currentTarget
            and place the event handler attribute on the use element directly,
            not on a parent group, as you might be used to do with regular shapes.

            All proper SVG UAs act like you describe.

            Andreas

            --- In svg-developers@yahoogroups.com, "richard_smith_ons"
            <Richard.M.Smith@...> wrote:
            >
            >
            > http://bugs.webkit.org/show_bug.cgi?id=14167
            >
            > Due to the above I get "evt.target.getAttributeNS not an object"
            when
            > trying to process the events on a USE element (Safari 3.0.3 for
            > Windows). The conclusion seems to be it's not a bug (!) Is there a
            > recommended workaround?
            >
            > Thanks
            >
            > Richard
            >
          Your message has been successfully submitted and would be delivered to recipients shortly.