Bug Tracker

Opened 10 years ago

Closed 10 years ago

Last modified 8 years ago

#10891 closed bug (wontfix)

object not support "toLowerCase" property or method

Reported by: [email protected] Owned by: [email protected]
Priority: low Milestone: None
Component: core Version: 1.7.1
Keywords: nodeName Cc:
Blocked by: Blocking:

Description (last modified by dmethvin)

we got a runtime error using Microsoft IE 9.0.8112.16421, jquery-1.7.1.js line 5188: if ( elem.nodeName.toLowerCase() === cur ) {

the error message is: Error: object not support "toLowerCase" property or method.

in IE 9 debug watch windows, we found that elem is a DispHTMLFormElement object , and elem.nodeName is DispHTMLInputElement but orignal, we use (jquery-1.3.2.js + IE 9.0.8112.16421) and run without errors.

Change History (20)

comment:1 Changed 10 years ago by sindresorhus

Thanks for taking the time to contribute to the jQuery project! Please provide a complete reduced test case on jsFiddle to help us assess your ticket.

Additionally, be sure to test against the jQuery Edge version to ensure the issue still exists. To get you started, use this boilerplate: http://jsfiddle.net/FrKyN/ Open the link and click to "Fork" (in the top menu) to get started.

comment:2 Changed 10 years ago by sindresorhus

Owner: set to [email protected]
Status: newpending

comment:3 Changed 10 years ago by [email protected]

Status: pendingnew

I have found an alternative soluction for this issue. change the DOCTYPE will work. the original DOCTYPE only work with jquery-1.3.2.js is: <!DOCTYPE HTML PUBLIC "-W3CDTD HTML 4.0 TransitionalEN">

and these two work all time: <!DOCTYPE HTML PUBLIC "-W3CDTD HTML 4.01EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE html>

comment:4 Changed 10 years ago by [email protected]

the complete code has saved on jsFiddle at: http://jsfiddle.net/vGhR2/1/

comment:5 Changed 10 years ago by [email protected]

and jsFiddle auto-generate page start with: <!DOCTYPE html> which makes it running without error.

comment:6 Changed 10 years ago by sindresorhus

Component: unfiledcore
Keywords: nodeName added
Priority: undecidedlow
Status: newopen

Simplified testcase
Reproducible in IE7 and all other IE quirks.

You've encountered this problem because one of your HTML tags is: <input name="nodeName">

You should avoid using properties or methods of a form in the name attribute.

Old discussion.

As you can see in the discussion, it isn't practical for jQuery to guard against all these methods.

In my opinion this is a wontfix, but will let a core member decide it's fate.

It should at least be documented somewhere.

comment:7 Changed 10 years ago by [email protected]

there is no document tell us that we cannot use <input name="nodeName">, and no document says we cannot use <input value="id">, or <input value="input">, or <input value="value">. Why jquery-1.3.2.js can work but juery-1.7.1.js cannot? I think this is a version compatibility issue. And there is also no document says that jQuery not support <!DOCTYPE HTML PUBLIC "-W3CDTD HTML 4.0 TransitionalEN">. Maybe the document should suggest we use <!DOCTYPE html> in the beginning of pages. Sorry for my poor English.

comment:8 Changed 10 years ago by [email protected]

I find the root cause for this issue. for doctype of TransitionalEN in IE9, there is a strange DOM: document.forms[0].nodeName will be the <input> DOM object with name ="nodeName" . So, I suggest, if jQuery don't want to support doctype of TransitionalEN, just write it in document. Or, just change code at line 5188 in jquery-1.7.1.js from: if ( elem.nodeName.toLowerCase() === cur ) { to if (typeof elem.nodeName === "string" && elem.nodeName.toLowerCase() === cur ) {

this will work.

comment:9 Changed 10 years ago by [email protected]

I too just got bit by this bug. We have an internal webapp that uses a Java Content Repository. "Node Name" is a common way to refer to objects in the repository, so we have several forms that have hidden inputs with id= or name="nodeName". I just spent the last 4 hours trying to figure out why jQuery was complaining when I was trying to bind a submit handler to the form.

I just now figured out it was because the form had a hidden input named "nodeName".

comment:10 Changed 10 years ago by Rick Waldron

Resolution: wontfix
Status: openclosed

It's not jQuery's problem that some rogue Java development package is bad at picking names.

comment:11 Changed 10 years ago by [email protected]

Is there any document said we cannot use input name="nodeName"? javascript document ? No! jquery document ? No!

comment:12 Changed 10 years ago by [email protected]

Change elem.nodeName.toLowerCase()to elem.nodeName.toString().toLowerCase() will resolve this problem at line number 1899.

comment:13 Changed 10 years ago by [email protected]

I have used uncompress jquery file. Change string in Jquery file.

comment:14 Changed 9 years ago by [email protected]

Did exactly the same. I'm not using any "Java" lib or anything I'm just getting this error straight out in Firefox with jQuery 1.7.2. I changed all references a.nodeName.toLowerCase() to a.nodeName.toString().toLowerCase() and everything is working as expected.

comment:15 Changed 9 years ago by dmethvin

there is no document tell us that we cannot use <input name="nodeName">, and no document says we cannot use <input value="id">, or <input value="input">, or <input value="value">.

http://kangax.github.com/domlint/

comment:16 Changed 9 years ago by dmethvin

Description: modified (diff)

comment:17 Changed 9 years ago by Estigy

Just to add my 10 cent: I encountered the same bug just now, using jQuery v1.8.2.

BUT: I don't have any element of id or name "nodeName" anywhere in my code.

Switching back to v1.7.2 got me rid of the problem.

comment:19 Changed 8 years ago by dmethvin

#14667 is a duplicate of this ticket.

comment:20 Changed 8 years ago by [email protected]

I just lost half an hour tracking this down, jquery 2.1.0, called input name "nodeName".

I recommend adding a check for this condition and raising an error like "You cannot use reserved words" instead of this non-descriptive error that comes up.

Note: See TracTickets for help on using tickets.