"use" elements added via Javascript are not drawn

RESOLVED INVALID

Status

()

Core
SVG
RESOLVED INVALID
12 years ago
12 years ago

People

(Reporter: Kyle Bresin, Unassigned)

Tracking

Trunk
x86
Windows XP
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments)

(Reporter)

Description

12 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1


Adding a "use" element (referencing a def in the same page) via javascript gets added to the DOM properly, but does not get drawn.

Will add an example.



Reproducible: Always




The javascript I used:

            function init() {
                var newUse  = document.createElementNS(svgNS, "use");
                newUse.setAttributeNS(svgNS, "id", "box2");
                newUse.setAttributeNS(svgNS, "xlink:href", "#greenBox");
                newUse.setAttributeNS(svgNS, "transform", "translate(100,100)");

                var svgRoot = document.getElementById('svg-root');
                svgRoot.appendChild(newUse);
}
(Reporter)

Comment 1

12 years ago
Created attachment 252780 [details]
adding a use element via javascript
(Reporter)

Comment 2

12 years ago
Created attachment 252782 [details]
Use this example instead.

The previous example had an artifact from "Save As".

Interestingly, in it it showed the added "use" element using "a0:href" instead of the "xlink:href" which firebug shows me...

Which might be the problem.
(Reporter)

Comment 3

12 years ago
Tor set me straight in IRC, my javascript code for setting the xlink attribute was wrong, should have been:

newUse.setAttributeNS("http://www.w3.org/1999/xlink", "href", "#greenBox");

instead.

Works now. =)
Status: UNCONFIRMED → RESOLVED
Last Resolved: 12 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.