Skip to main content

Bug Tracker

Side navigation

#13073 closed bug (duplicate)

Opened December 18, 2012 11:33AM UTC

Closed December 24, 2012 03:13PM UTC

Last modified December 28, 2012 04:47PM UTC

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:**

0. Use jQuery 1.9-b1 and jQuery Migrate v1.0.0pre - 2012-12-17

1. Create a document containing <option> elements

2. 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/

Attachments (0)
Change History (6)

Changed December 18, 2012 05:31PM UTC by dmethvin comment:1

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.

Changed December 21, 2012 04:13AM UTC by dmethvin comment:2

@gibson042 or @timmywil, thoughts?

Changed December 21, 2012 04:30PM UTC by gibson042 comment:3

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

Changed December 24, 2012 03:13PM UTC by dmethvin comment:4

resolution: → duplicate
status: newclosed

Changed December 24, 2012 10:18PM UTC by dmethvin comment:5

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.

Changed December 28, 2012 04:47PM UTC by timmywil comment:6

I like the warning.