Closed Bug 866170 Opened 11 years ago Closed 11 years ago

xlink:href's default value is empty string, not null

Categories

(Core :: DOM: Core & HTML, defect)

20 Branch
x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: 4timmywil, Unassigned)

Details

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1489.3 Safari/537.36

Steps to reproduce:

Created/removed xlink:href attributes on an SVG element.


Actual results:

I noticed different return values across browsers for when the attribute is not present on the element. In Firefox and Opera, the default value is null, while Chrome, Safari and IE10 return empty string for empty xlink:href attributes. This makes it difficult to work with the attribute from the perspective of an SVG library.


Expected results:

From looking at the specs for DOM Level 4, DOM Level 3, and SVG, I think I've pieced together that the default value should in fact be empty string.

Test case: http://jsfiddle.net/timmywil/R8vJM/
Component: Untriaged → DOM
Product: Firefox → Core
Earlier versions of the DOM specification had this method described as returning an empty string for non-existent attributes, but it was not typically implemented this way since null makes more sense. The DOM4 specification now says this method should return null for non-existent attributes.

See http://www.w3.org/TR/dom/#dom-element-getattributens step 3
Status: UNCONFIRMED → RESOLVED
Closed: 11 years ago
Resolution: --- → INVALID
Gotcha. I think you meant step 2 though. There doesn't seem to be a step 3 in getAttributeNS. I couldn't tell if DOM4 got rid of default values. Thanks for the clarification.
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.