Bug 149180 - Element.getAttributeNS() should return null if the attribute does not exist
Summary: Element.getAttributeNS() should return null if the attribute does not exist
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar, WebExposed
Depends on:
Blocks:
 
Reported: 2015-09-15 13:48 PDT by Chris Dumez
Modified: 2015-09-16 09:58 PDT (History)
3 users (show)

See Also:


Attachments
Patch (26.38 KB, patch)
2015-09-15 14:15 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (26.24 KB, patch)
2015-09-15 14:37 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2015-09-15 13:48:55 PDT
Element.getAttributeNS() should return null if the attribute does not exist, similarly to what Element.getAttribute() does:
- https://dom.spec.whatwg.org/#element (both return a nullable DOMString).
- https://dom.spec.whatwg.org/#dom-element-getattributens (step 2)

Firefox and Chrome match the specification. WebKit returns an empty string for getAttributeNS() but null for getAttribute().
Comment 1 Chris Dumez 2015-09-15 13:49:33 PDT
rdar://problem/22561011
Comment 2 Chris Dumez 2015-09-15 14:15:15 PDT
Created attachment 261234 [details]
Patch
Comment 3 Ryosuke Niwa 2015-09-15 14:23:47 PDT
Comment on attachment 261234 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=261234&action=review

> Source/WebCore/dom/Element.idl:52
> +    [ObjCLegacyUnnamedParameters, TreatReturnedNullStringAs=Null] DOMString getAttributeNS([TreatNullAs=NullString,Default=Undefined] optional DOMString namespaceURI, [Default=Undefined] optional DOMString localName);

Can we split this into two lines?  It's really long now.
Comment 4 Chris Dumez 2015-09-15 14:37:50 PDT
Created attachment 261238 [details]
Patch
Comment 5 Chris Dumez 2015-09-15 14:39:14 PDT
Committed r189825: <http://trac.webkit.org/changeset/189825>
Comment 6 Darin Adler 2015-09-16 09:58:16 PDT
Comment on attachment 261234 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=261234&action=review

>> Source/WebCore/dom/Element.idl:52
>> +    [ObjCLegacyUnnamedParameters, TreatReturnedNullStringAs=Null] DOMString getAttributeNS([TreatNullAs=NullString,Default=Undefined] optional DOMString namespaceURI, [Default=Undefined] optional DOMString localName);
> 
> Can we split this into two lines?  It's really long now.

I like it better long than split.