getBBox() does not work when SVGLoad event is fired

RESOLVED DUPLICATE of bug 293581

Status

()

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

People

(Reporter: Peter Thompson, Unassigned)

Tracking

Trunk
x86
Linux
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

12 years ago
User-Agent:       Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705)
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv: 1.8b2) Gecko/20050523 Firefox/1.0+

The file in the expected results area can be used to duplicate the problem.  
When you load the file in IE/ASVG3 and Squiggle, the 'click here' text is 
blue.  When you load the file in Firefox/Moz, the 'click here' text is red and 
there is an exception shown in the JavaScript console indicating that the 
getBBox() call in the onload event handler caused an NS_ERROR_FAILURE.

Here is some text from SVG 1.1 about the SVGLoad event:

  The event is triggered at the point at which the user agent has fully
  parsed the element and its descendants and is ready to act
  appropriately upon that element, such as being ready to render the
  element to the target device.

getBBox() works.  You can check that by clicking on the 'click here' text in 
any of the three SVG viewers mentioned above (the text changes to the x value 
of the bounding box).  getBBox() just doesn't work in the SVGLoad event handler.


Reproducible: Always



Expected Results:  
'click here' text should be blue, and no exception.

<?xml version='1.0'?>
<svg xmlns='http://www.w3.org/2000/svg' width="500" height="400" onload="init
(evt)">
<defs>
<script>
<![CDATA[
function init(evt)
{
  var svgDoc = evt.target.ownerDocument;
  var element = svgDoc.getElementById('t1');
  element.setAttribute('fill', 'red');
  var bbox = element.getBBox();
  element.setAttribute('fill', 'blue');
}
function onClick(evt)
{
  var element = evt.target;
  bbox = element.getBBox();
  element.firstChild.nodeValue = "bbox.x = " + bbox.x;
}
]]>
</script>
</defs>
<g onclick="onClick(evt)" fill="green" font-size="18">
  <text id="t1" x="20" y="100">click here</text>
</g>
</svg>

Comment 1

12 years ago
That's a duplicate of 293581.
indeed, duping

*** This bug has been marked as a duplicate of 293581 ***
Status: UNCONFIRMED → RESOLVED
Last Resolved: 12 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.