#10891 closed bug (wontfix)
object not support "toLowerCase" property or method
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | low | Milestone: | None |
Component: | core | Version: | 1.7.1 |
Keywords: | nodeName | Cc: | |
Blocked by: | Blocking: |
Description (last modified by )
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 12 years ago by
comment:2 Changed 12 years ago by
Owner: | set to jacklondon.chen@… |
---|---|
Status: | new → pending |
comment:3 Changed 11 years ago by
Status: | pending → new |
---|
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 11 years ago by
the complete code has saved on jsFiddle at: http://jsfiddle.net/vGhR2/1/
comment:5 Changed 11 years ago by
and jsFiddle auto-generate page start with: <!DOCTYPE html> which makes it running without error.
comment:6 Changed 11 years ago by
Component: | unfiled → core |
---|---|
Keywords: | nodeName added |
Priority: | undecided → low |
Status: | new → open |
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.
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 11 years ago by
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 11 years ago by
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 11 years ago by
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 11 years ago by
Resolution: | → wontfix |
---|---|
Status: | open → closed |
It's not jQuery's problem that some rogue Java development package is bad at picking names.
comment:11 Changed 11 years ago by
Is there any document said we cannot use input name="nodeName"? javascript document ? No! jquery document ? No!
comment:12 Changed 11 years ago by
Change elem.nodeName.toLowerCase()to elem.nodeName.toString().toLowerCase() will resolve this problem at line number 1899.
comment:13 Changed 11 years ago by
I have used uncompress jquery file. Change string in Jquery file.
comment:14 Changed 11 years ago by
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 11 years ago by
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">.
comment:16 Changed 11 years ago by
Description: | modified (diff) |
---|
comment:17 Changed 11 years ago by
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:20 Changed 9 years ago by
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.
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.