Closed Bug 373252 Opened 17 years ago Closed 17 years ago

getComputedTextLength() returns 0 from SVG onload handler

Categories

(Core :: SVG, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 293581

People

(Reporter: duncan.loveday, Unassigned)

Details

Attachments

(2 files)

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

<text element>.getComputedTextLength() for a non-empty <text element> returns 0 when called from an SVG onload event handler. <text element>.getComputedTextLength() on the same <text element> returns valid data when called from an HTML onload handler or from mouse event handlers called after the load process has completed.

Reproducible: Always

Steps to Reproduce:
1. Place the attached test.html and test.svg files in a temporary directory
2. Open the attached test.html file in Firefox
3.
Actual Results:  
The alert messages displayed are
"loadSVG()"
"textLen=0"
"loadHTML()"
"textLen=99"

Expected Results:  
The alert messages expected are
"loadSVG()"
"textLen=99"
"loadHTML()"
"textLen=99"

This bug (if indeed it is a bug) can be worked around by using the SVG onload event handler to save a reference to the SVG document and calling the remainder of the code from the HTML onload handler, or by parsing the SVG content programatically (with DOMParser.parseFromString()) and adding the root element to the HTML document directly so that the root element can be obtained without the use of an SVG onload handler.

The same result is observed when including the SVG content via an <EMBED> tag instead of <OBJECT>.
Attached file test HTML source
Attached image test SVG source
Same issue as bug 293581 with the same workarounds.
Thanks Robert, I've marked this as a duplicate.
Status: UNCONFIRMED → RESOLVED
Closed: 17 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: