The default bug view has changed. See this FAQ.

getComputedTextLength() returns 0 from SVG onload handler

RESOLVED DUPLICATE of bug 293581

Status

()

Core
SVG
RESOLVED DUPLICATE of bug 293581
10 years ago
10 years ago

People

(Reporter: Duncan Loveday, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments)

(Reporter)

Description

10 years ago
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>.
(Reporter)

Comment 1

10 years ago
Created attachment 257886 [details]
test HTML source
(Reporter)

Comment 2

10 years ago
Created attachment 257887 [details]
test SVG source

Comment 3

10 years ago
Same issue as bug 293581 with the same workarounds.
(Reporter)

Comment 4

10 years ago
Thanks Robert, I've marked this as a duplicate.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 10 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 293581
You need to log in before you can comment on or make changes to this bug.