Closed Bug 1169645 Opened 6 years ago Closed 6 years ago

getAttribute() returns null for attributes containing upper case characters in attribute name


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

38 Branch
Not set





(Reporter: jrscott, Unassigned)




(Keywords: testcase)


(1 file)

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.81 Safari/537.36

Steps to reproduce:

<input type='text' Choices='abc' maxlength='1' id='foo'>

function Validate(){
var choices = document.getElementById('foo').getAttribute('Choices');

Actual results:

choices returns null.  When I changed the attribute name to all lower case, I got the expected results.  Using $("#foo").attr("Choices") in jQuery I get the same return as document.getElementById('foo').

Expected results:

The variable choices should have returned 'abc'.   (From what I can tell trying to research this problem, it is occurring everywhere and websites utilizing JavaScript are breaking everywhere.)
Severity: normal → critical
OS: Unspecified → Windows
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0

Works for me.

Have you actually tested just the code you posted, without anything else on the page? If yes, please test in a brand new profile.
Severity: critical → normal
Component: Untriaged → DOM: Core & HTML
Keywords: testcase
OS: Windows → All
Product: Firefox → Core
Hardware: Unspecified → All
See Also: → 1165851
I did not, in fact, test the exact code I posted when I created the issue report.  That was code simplified from the actual code I had a problem with.  I just created a simple test that should have failed and did not.  It definitely happens in my "real" code that would not be at all convenient to share since it depends on a lot of other moving parts.

Others have reported the same symptoms however, so I ask you not to close this issue just yet.  I will look through my production code and try to find out what else happens to trigger the behavior I have reported and try to create a test case that fails so you can find this.  Give me a couple of hours.
Ok, I see what happened in the real code.  I used createAttribute() and setNamedAttribute() (code was written 8 years ago).  That function has been deprecated, but should still function properly and still needs fixing.  I will attach a test case to show you what is actually occurring.
John, thanks for hunting that down.  This is the same as bug 1165851, then.  Per the spec for createAttribute what you're doing should in fact not work (because createAttribute creates the attribute with that case, but getAttribute lower-cases its argument before doing case-sensitive compares), but it sounds like the spec needs changing...
Blocks: 1075702
Closed: 6 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 1165851
You need to log in before you can comment on or make changes to this bug.