Bug Tracker

Modify

Ticket #3917 (closed bug: wontfix)

Opened 4 years ago

Last modified 4 years ago

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:
Blocking: Blocked by:

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

test-3917.html Download (615 bytes) - added by dmethvin 4 years ago.
maxLength property vs. attribute

Change History

Changed 4 years ago by dmethvin

maxLength property vs. attribute

comment:1 follow-up: ↓ 2 Changed 4 years ago by dmethvin

  • Keywords attr input maxLength added
  • Summary changed from $(el).attr(name) does not return undefined if attritbute is not set in some cases to input 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.

comment:2 in reply to: ↑ 1 Changed 4 years ago by Phrogz

This seems a duplicate of ticket #3468.

comment:3 Changed 4 years ago by brandon

  • Status changed from new to closed
  • Resolution set to wontfix

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.

comment:4 Changed 4 years ago by webbower

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

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.