Closed Bug 835048 Opened 11 years ago Closed 11 years ago

Figure out if SVGElement.ownerSVGElement should throw

Categories

(Core :: SVG, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla26

People

(Reporter: Ms2ger, Assigned: longsonr)

References

Details

(Keywords: dev-doc-needed)

Attachments

(2 files)

The spec (<https://svgwg.org/svg2-draft/types.html#__svg__SVGElement__ownerSVGElement>) says:

ownerSVGElement (readonly SVGSVGElement)
    The nearest ancestor ‘svg’ element. Null if the given element is the outermost svg element.

Our implementation has:

1138   // If we didn't find anything and we're not the outermost SVG element,
1139   // we've got an invalid structure
1140   if (!ownerSVGElement && Tag() != nsGkAtoms::svg) {
1141     rv.Throw(NS_ERROR_FAILURE);
1142   }

which doesn't seem to make sense to me.
It throws if you write <g xmlns="xmlns="http://www.w3.org/2000/svg"><rect id="r"></g> which is not a valid svg file as the root element is not <svg>.

Since the specification doesn't say to throw and returning null is reasonable I think we should do that.
Attached patch patchSplinter Review
Assignee: nobody → longsonr
Attachment #785522 - Flags: review?(jwatt)
What do Chrome and IE do?
Attached image testcase
Firefox throws and displays an error in the console
IE 9 prints null
Opera prints null

Dunno about Chrome.
Flags: needinfo?(jwatt)
null in Chrome too.
Comment on attachment 785522 [details] [diff] [review]
patch

Okay, sounds like we should definitely do this then. Thanks!
Attachment #785522 - Flags: review?(jwatt) → review+
Flags: needinfo?(jwatt)
Can you change:

  return GetCtx();

to:

  return GetCtx(); // this may return nullptr
Keywords: dev-doc-needed
https://hg.mozilla.org/mozilla-central/rev/bd5a82670cf9
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla26
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: