Bug Tracker

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#9826 closed bug (duplicate)

.css(prop, undefined) should return self for chaining

Reported by: TJ Holowaychuk Owned by:
Priority: low Milestone: None
Component: css Version: 1.6.2
Keywords: Cc:
Blocked by: Blocking:

Description

the user's intention is clearly to change the value, so returning as if it were a getter is a bug.

Change History (4)

comment:1 Changed 8 years ago by timmywil

Component: unfiledcss
Priority: undecidedlow
Resolution: duplicate
Status: newclosed

It is invalid to set any style to undefined.

comment:2 Changed 8 years ago by timmywil

Duplicate of #9427.

comment:3 Changed 8 years ago by dmethvin

So if we returned the current jQuery object, what value should we set for the CSS property? Doing nothing would be a bad idea since the user's intention was clearly to change the value, so returning without setting a value would be a bug.

comment:4 Changed 8 years ago by ajpiano

Also, this doesn't only affect .css()... It affects any method that's a getter and a setter, which behaves like a getter if it is passed two arguments and the second is undefined (a.k.a. .attr()).

Note: See TracTickets for help on using tickets.