Side navigation
#9463 closed bug (wontfix)
Opened May 30, 2011 02:15PM UTC
Closed May 30, 2011 09:06PM UTC
Last modified March 14, 2012 03:25AM UTC
attr() yields different results in 1.5.2 and 1.6.1
Reported by: | begraves@gmx.de | Owned by: | |
---|---|---|---|
Priority: | low | Milestone: | 1.next |
Component: | attributes | Version: | 1.6.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
...which breaks the statement "when updating from 1.5.2 to 1.6.1, you should not have to change any attribute code" in the blog.
Examples:
$("<textarea>").attr("type")is undefined in 1.6.1, while "textarea" is returned in 1.5.2 (which is returned by
$("<textarea>").prop("type")in 1.6.1).
The same holds for
$("<select>").attr("type")and
$("<input>").attr("type")(and maybe even more) analogously, see http://jsfiddle.net/HHgw5/ and http://jsfiddle.net/TZxmy/ .
Attachments (0)
Change History (12)
Changed May 30, 2011 09:06PM UTC by comment:1
component: | unfiled → attributes |
---|---|
priority: | undecided → low |
resolution: | → wontfix |
status: | new → closed |
Changed May 31, 2011 07:32AM UTC by comment:2
This is intended behavior for the type attribute...
Hi timmywil, thanks for your quick response. I understand your point of view, nevertheless the statement "when updating from 1.5.2 to 1.6.1, you should not have to change any attribute code" is plain wrong and should be corrected in the blog.
1.6.1 is not backwards compatible with 1.5.2, at least regarding to the attr-function.
Changed June 02, 2011 08:35AM UTC by comment:3
I have to agree completely with begraves, the statement "when updating from 1.5.2 to 1.6.1, you should not have to change any attribute code" is incorrect.
Please consider reopening this issue.
Changed June 02, 2011 01:43PM UTC by comment:4
I understand the confusion, but technically the statement is still valid. This is not attribute code we're talking about in this ticket.
Changed June 02, 2011 03:03PM UTC by comment:5
Replying to [comment:4 timmywil]:
I understand the confusion, but technically the statement is still valid. This is not attribute code we're talking about in this ticket.
I certainly don't want this comment thread to go round in circles, so I will finish by saying that regardless of whether this is technically attribute code or not, I believe that it is a breaking change introduced between 1.5.2 and 1.6.1 and should either be fixed or documented as such.
Changed June 02, 2011 08:48PM UTC by comment:6
Replying to [comment:4 timmywil]:
I understand the confusion, but technically the statement is still valid.
Ok, I give a longer citation from http://blog.jquery.it/2011/05/12/jquery-1-6-1-released/
When updating from 1.5.2 to 1.6.1, you should not have to change any attribute code. [...] However, as previously stated, jQuery 1.6.1 will allow you to use .attr() just as it was used before in all situations.
I think you have to agree that this statement is not correct. ;-)
Changed June 04, 2011 08:35PM UTC by comment:7
Another change that's not backward-compatible is that .attr('id') on something that has no id used to return "", but in jQuery 1.6+ it now returns undefined. Unfortunately some code (specifically the Uniform plugin) tests for the existence of id by checking $el.attr != "" (which now is broken). It might be worth a warning in the docs.
Changed June 04, 2011 08:39PM UTC by comment:8
I suggest getting in touch with the author of Uniform and let them know that their plugin needs to be updated
Changed June 04, 2011 09:10PM UTC by comment:9
It would be more than nice either to publish a complete list of backward incompatibilities for 1.6.1 or (better) to fix these incompatibilities in 1.6.2.
Changed June 04, 2011 09:21PM UTC by comment:10
The latter would just bring us back to the old "attr" - that timmywil worked _very_ hard to rewrite... so... non-starter. The former exists here: http://blog.jquery.com/2011/05/12/jquery-1-6-1-released/
Changed June 05, 2011 07:58AM UTC by comment:11
Replying to [comment:10 rwaldron]:
The latter would just bring us back to the old "attr" - that timmywil worked _very_ hard to rewrite... so... non-starter. The former exists here: http://blog.jquery.com/2011/05/12/jquery-1-6-1-released/
...containing the incorrect statement
>... jQuery 1.6.1 will allow you to use .attr() just as it was used before in all situations.
as stated above. John Resigs blog entry suggests that 1.6.1 (in contrast to 1.6) is backwards compatible with 1.5.2 which it is not. IMO this should be corrected or better/clearly documented.
But as yeurch said I don't want this to go round in circles too, so this was my last comment in this thread.
Changed June 05, 2011 04:01PM UTC by comment:12
In an effort to better explain the changes to attr() and the new prop() functionality, @dmethvin and I put these jsfiddle's together:
http://jsfiddle.net/rwaldron/BNcty/
Hope this adds some clarity
Thanks for taking the time to contribute to the jQuery project!
This is intended behavior for the type attribute as it allows you differentiate between the actual attribute and the property. Nevertheless, the most common use cases consist of setting the type attribute on a disconnected node and possibly retrieving it later. For instance, http://jsfiddle.net/timmywil/At4Hh/