Bug Tracker

Opened 7 years ago

Closed 7 years ago

Last modified 5 years ago

#10891 closed bug (wontfix)

object not support "toLowerCase" property or method

Reported by: jacklondon.chen@… Owned by: jacklondon.chen@…
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 7 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 7 years ago by sindresorhus

Owner: set to jacklondon.chen@…
Status: newpending

comment:3 Changed 7 years ago by jacklondon.chen@…

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 7 years ago by jacklondon.chen@…

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

comment:5 Changed 7 years ago by jacklondon.chen@…

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

comment:6 Changed 7 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 7 years ago by jacklondon.chen@…

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 7 years ago by jacklondon.chen@…

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 7 years ago by john@…

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 7 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 7 years ago by jacklondon.chen@…

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

comment:12 Changed 7 years ago by deepaksinghkushwah@…

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

comment:13 Changed 7 years ago by deepaksinghkushwah@…

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

comment:14 Changed 7 years ago by mike_jq@…

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 7 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 7 years ago by dmethvin

Description: modified (diff)

comment:17 Changed 6 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 5 years ago by dmethvin

#14667 is a duplicate of this ticket.

comment:20 Changed 5 years ago by mst@…

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.