Skip to main content

Bug Tracker

Side navigation

#3917 closed bug (wontfix)

Opened January 19, 2009 07:40PM UTC

Closed March 17, 2009 10:12PM UTC

Last modified July 23, 2009 12:07PM UTC

input maxLength property/attribute is not consistent

Reported by: webbower Owned by:
Priority: minor Milestone: 1.3.1
Component: core Version: 1.3
Keywords: attr input maxLength Cc:
Blocked by: Blocking:
Description

The example I found was trying to get the "maxlength" attribute from a text input element and if it was not set, the function returned "-1" instead of undefined like the documentation says. My Firebug helped me discover the actual result. I'm not sure if the bug exists when trying to get other attributes or if it also returns "-1" for other attributes that aren't set.

Mac OS X 10.5.6

Firefox 3.0.5

Firebug 1.2.1

Attachments (1)
  • test-3917.html (0.6 KB) - added by dmethvin January 20, 2009 12:20AM UTC.

    maxLength property vs. attribute

Change History (4)

Changed January 20, 2009 12:23AM UTC by dmethvin comment:1

keywords: → attr input maxLength
summary: $(el).attr(name) does not return undefined if attritbute is not set in some casesinput maxLength property/attribute is not consistent

This isn't consistent across browsers, or even across property vs. attribute. However, the behavior has not changed since 1.2.6. I've attached a test case. In FF3, the maxLength property is -1 and the maxLength attribute is null. In Ie the property is 2147483647 and the attribute is null. jQuery returns the property value in preference to the attribute, and the property value is defined.

Changed February 27, 2009 06:55PM UTC by Phrogz comment:2

This seems a duplicate of ticket #3468.

Changed March 17, 2009 10:12PM UTC by brandon comment:3

resolution: → wontfix
status: newclosed

Unfortunately we can't have it both ways. IE immediately converts the attribute to a property/expando and using the setAttribute/removeAttribute/getAttribute apis no long work.

Not sure we can normalize this without a large impact on performance.

Changed March 17, 2009 10:35PM UTC by webbower comment:4

If you can't fix the bug, then I'd recommend correcting the Docs to reflect the actual behavior.