Bug 28976 - element.hasAttribute() fails to return true for nodes imported from XML documents
Summary: element.hasAttribute() fails to return true for nodes imported from XML docum...
Status: RESOLVED CONFIGURATION CHANGED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL: http://www.robodesign.ro/coding/0063/
Keywords: HasReduction
Depends on:
Blocks:
 
Reported: 2009-09-04 09:59 PDT by Mihai Sucan
Modified: 2022-08-02 09:57 PDT (History)
7 users (show)

See Also:


Attachments
Test case (836 bytes, text/html)
2009-09-08 13:26 PDT, Sam Weinig
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mihai Sucan 2009-09-04 09:59:14 PDT
The element.hasAttribute() fails to return true for imported nodes when the attribute includes upper case characters.

Steps to reproduce:

1. Have two DOM documents, say DocA and DocB.
2. Import from DocA into DocB an element node which has at least one child element node.
3. Retrieve a reference to one of the child element nodes you imported.
4. Try element.hasAttribute('someAttributeWithUpperCase').

Expected result: the element.hasAttribute() method must return true if the attribute is set for the element node.

Actual result: the element.hasAttribute() method returns false, even if the attribute is set for the said element node. What is more curious is that the element.getAttribute('someAttributeWithUpperCase') method works fine, and the attribute value is properly returned.

It should be noted that if the attribute has no upper case letter, then the hasAttribute() method works as expected. Additionally, the importNode() step is crucial to exposing the bug. If you try hasAttribute() with pre-existing document elements which have attributes with upper case names, it all works fine.

The URL points to a minimal test case which loads an XHTML document with XMLHttpRequest and imports the element node into the main document, and then tries the element.hasAttribute() method. The test case fails in Webkit (tested with Google Chrome 2 on Windows, Safari 4 on Windows, Chromium 4 development daily build on Linux). The test case does not fail in Opera 9.6, Opera 10, Firefox 3.0, Firefox 3.5 and Konqueror 4.1.
Comment 1 Alexey Proskuryakov 2009-09-07 22:22:47 PDT
Case sensitivity behavior is implemented differently for getAttribute() on one hand, and hasAttribute()/setAttribute()/removeAttribute()/getAttributeNode() on another. Which behavior is "right" may be subject to discussion, but having it different seems clearly wrong.
Comment 2 Alexey Proskuryakov 2009-09-08 12:03:18 PDT
See also: bug 20247 comment 10.
Comment 3 Sam Weinig 2009-09-08 13:26:08 PDT
Created attachment 39208 [details]
Test case
Comment 4 Lucas Forschler 2019-02-06 09:02:45 PST
Mass moving XML DOM bugs to the "DOM" Component.
Comment 5 Ahmad Saleem 2022-08-02 04:59:00 PDT
All browsers (Chrome Canary 106, Firefox Nightly 105 and Safari 15.6 on macOS 12.5) are showing "FAILED!" and I am not sure on Web-Spec so appreciate if someone can mark this bug accordingly. Thanks!
Comment 6 Ryosuke Niwa 2022-08-02 09:17:54 PDT
This is config changed now that Firefox's behavior is aligned with WebKit's.

imported.hasAttributeNS(null, 'camelCase') returns true.