Bug 12267

Summary: getElementById broken for <use>
Product: WebKit Reporter: Kyle Rove <kyle.rove>
Component: SVGAssignee: Nikolas Zimmermann <zimmermann>
Status: RESOLVED DUPLICATE    
Severity: Normal CC: jay
Priority: P2    
Version: 420+   
Hardware: Mac   
OS: OS X 10.4   
URL: http://www.sensoryoutput.com/external/freshview_week.svg
Attachments:
Description Flags
<use> breaks scripting
none
works if <use> not in script none

Description Kyle Rove 2007-01-14 11:18:12 PST
Summary: This SVG document has JavaScript to show more information when the mouse is over a data point, manipulating the visibility property of specific elements in the SVG document. This script works in Adobe SVG plugin and Firefox 2.

Steps to reproduce: Go to http://www.sensoryoutput.com/external/freshview_week.svg and hover cursor over a data point.

Expected results: Box with text about data node should appear.

Actual results: No box with text about data node appears.

To my knowledge, this has never worked in the SVG implementation of WebKit.
Comment 1 Eric Seidel (no email) 2007-01-14 21:05:47 PST
It's getting a null value here:

  tooltip.setAttributeNS(null,"transform","translate("+(parseInt(label.getAttributeNS(null,"x"))-40)+","+(parseInt(label.getAttributeNS(null,"y"))-23)+")")

in graph.js

Not sure why yet.
Comment 2 Eric Seidel (no email) 2007-01-14 21:17:17 PST
It turns out that:
cible.getAttribute("id")

returns "undefined"

Not sure why yet.
Comment 3 Eric Seidel (no email) 2007-01-14 23:18:36 PST
It looks like this is actually a problem with <use>.  Changing title accordingly.
Comment 4 Nikolas Zimmermann 2007-02-02 11:17:25 PST
(In reply to comment #3)
> It looks like this is actually a problem with <use>.  Changing title
> accordingly.
> 

Hmm it also doesn't work in Opera/Batik.
Opera silently fails, Batik displays "Can not convert to null value".
WebKit says "(event handler):Value undefined (result of expression cible.getAttribute) is not object.".

Please provide a reduced testcase, what's really going on there.

Greetings,
Niko
Comment 5 Kyle Rove 2007-02-03 07:30:57 PST
This now works in ToT.
Comment 6 jay 2007-02-06 02:29:57 PST
Created attachment 12963 [details]
<use> breaks scripting
Comment 7 jay 2007-02-06 02:31:46 PST
Created attachment 12964 [details]
works if <use> not in script
Comment 8 jay 2007-02-06 02:36:04 PST
#6 reduced testcase: demonstrates that including <use> breaks scripting
all 3 boxes visible, they should be hidden.

#7 reduced testcase: as #6 but excluding reference to <use> works
2 boxes hidden, third <use> box wasn't scripted to be hidden
Comment 9 jay 2007-02-06 02:46:06 PST
suggest changing Summary to: getElementById broken for <use> 
and removing Keywords: NeedsReduction

awaiting editbugs
Comment 10 jay 2007-02-06 02:50:48 PST
suggest changing Summary to: getElementById broken for <use> 
and removing Keywords: NeedsReduction

awaiting editbugs
Comment 11 Nikolas Zimmermann 2007-02-28 08:41:32 PST
Okay, I finally found out what's going on here.
The freshview_week.svg is broken and relies on bugs in the other SVG implementations.

graph.js expects the "cible" to be of type SVGUseElement, though the SVG spec clearly says that the events should be dispatched to the corresponding SVGElementInstance and NOT the SVGUseElement.

Easy fix to get it working in Safari:
function path_show(evt) {
  cible = evt.target.correspondingUseElement
...
instead of "cible = evt.target"

So this is definately a "won't fix" bug.
Though the reduction in #6 / #7 highlights a different bug, keeping this bug open.

Niko
Comment 12 jay 2007-02-28 11:44:01 PST
#11

Nikolas, should I open a separate bug?
ie for #6 & #7
Comment 13 Nikolas Zimmermann 2007-03-01 03:00:07 PST
(In reply to comment #12)
> #11
> 
> Nikolas, should I open a separate bug?
> ie for #6 & #7
> 

Hey Jay,

i don't think that's needed. I plan to open a master bug anyway which should fix all currently reported <use> problems. I'll mark this bug and others (12926, 12916, 12917) as duplicates of the new master bug. Stay tuned :-)

Niko
Comment 14 Nikolas Zimmermann 2007-03-01 10:05:43 PST

*** This bug has been marked as a duplicate of 12936 ***