#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:
- Use jQuery 1.9-b1 and jQuery Migrate v1.0.0pre - 2012-12-17
- Create a document containing <option> elements
- 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:
Change History (6)
comment:1 Changed 10 years ago by
comment:3 Changed 10 years ago by
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 10 years ago by
Resolution: | → duplicate |
---|---|
Status: | new → closed |
comment:5 Changed 10 years ago by
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.
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 anoption
between the property and the attribute. Forinput[type=text]
,textarea
, and probably a few others can have the values diverge.