Bug Tracker

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#13073 closed bug (duplicate)

Selector containing 'value' attribute causes deprecation warning

Reported by: wet Owned by:
Priority: undecided Milestone: None
Component: unfiled Version:
Keywords: Cc:
Blocked by: Blocking:

Description

Steps to reproduce:

  1. Use jQuery 1.9-b1 and jQuery Migrate v1.0.0pre - 2012-12-17
  2. Create a document containing <option> elements
  3. Select some of these elements by their 'value' attribute

Result:

jQuery Migrate logs this console message:

JQMIGRATE: property-based jQuery.fn.attr('value') is deprecated

There's no occurence of jQuery.fn.attr in the userland code. It looks like jQuery uses jQuery.fn.attr internally to resolve the attribute selector.

Test case:

http://jsfiddle.net/e2rgj/

Change History (6)

comment:1 Changed 7 years ago by dmethvin

Perhaps we can narrow the scope of this warning. Pre-1.9, in some situations we'd incorrectly use the property (the current value including stuff the user just typed in there) rather than the attribute (essentially, "what the HTML said").

Since your selector is $('body').find('option[value!=""]') there's no practical difference with an option between the property and the attribute. For input[type=text], textarea, and probably a few others can have the values diverge.

comment:2 Changed 7 years ago by dmethvin

@gibson042 or @timmywil, thoughts?

comment:3 Changed 7 years ago by gibson042

We could put together a whitelist and make the https://github.com/jquery/jquery-migrate/blob/master/src/attributes.js#L36 warning conditional.

comment:4 Changed 7 years ago by dmethvin

Resolution: duplicate
Status: newclosed

comment:5 Changed 7 years ago by dmethvin

Closed in the jquery-migrate plugin, but this warning could still appear for a selector such as input[type=text][value=42] since the semantics of that selector have changed from looking at the property to looking at the value. I don't think that is a bad thing.

comment:6 Changed 7 years ago by timmywil

I like the warning.

Note: See TracTickets for help on using tickets.