Ticket #11527 (closed bug: invalid)
attr('href') returns object
| Reported by: | info@… | Owned by: | rwaldron |
|---|---|---|---|
| Priority: | blocker | Milestone: | None |
| Component: | attributes | Version: | 1.7.2 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
jQuery 1.7.1
aTag.attr('href') return the URL of aTag
aTag.prop('href') return the full URL of aTag
jQuery 1.7.2
aTag.attr('href') return aTag
aTag.prop('href') return the full URL of aTag
Example
Change History
comment:1 Changed 14 months ago by sindresorhus
- Owner set to info@…
- Priority changed from undecided to low
- Status changed from new to pending
- Component changed from unfiled to attributes
comment:5 Changed 14 months ago by info@…
- Status changed from pending to new
It doesn't work with Firefox 11 on Windows XP.
comment:9 Changed 14 months ago by mikesherov
Just tossing this out there randomly: might compatibility view have something to do with this? Whenever I encounter an IE that's sometimes reproducible (maybe), I make sure I check with compatibility view on and compatibility view off.
Maybe it's just noise I'm adding, but it's worth a shot
comment:10 Changed 14 months ago by rwaldron
@info@…
When you created the jsfiddle - did the bug reproduce?
comment:11 Changed 14 months ago by rwaldron
- Owner changed from info@… to rwaldron
- Priority changed from low to blocker
- Status changed from pending to assigned
comment:12 Changed 14 months ago by rwaldron
#11512 is a duplicate of this ticket.
comment:13 Changed 14 months ago by rwaldron
#11519 is a duplicate of this ticket.
comment:14 Changed 14 months ago by ajpiano
I have a feeling this might be TinyMCE. Given both the nature of the several reports we've gotten, and also because of the fact that TinyMCE is a widely used WYSIWYG editor with a jQuery adapter that duckpunches attr. Take a look at line 215 of this gist https://gist.github.com/92a2c3631be1d35bb5e2, which is the beautified version of the minified jQuery plugin they ship in their zip file.
comment:15 Changed 14 months ago by ajpiano
For anyone reading this's reference, research earlier today by mikesherov yielded this fiddle: http://jsfiddle.net/7u7cN/2/ which demonstrated that plugins that are redefining .attr and then calling it later on with .call would created unexpected results for people using attr in chains between 1.7.1 and 1.7.2. I believe rwaldron and davemethvin have come up with a path forward here that I'll leave it to them to document
comment:16 Changed 14 months ago by ajpiano
#11531 is a duplicate of this ticket.
comment:17 Changed 14 months ago by gnarf
Left a comment on the gist for anyone interested in the actual fix in TinyMCE's punch.
comment:18 Changed 14 months ago by fj@…
Checkout "Version 3.5b3" @ http://www.tinymce.com/develop/changelog/index.php?type=tinymce "Fixed bug where the jQuery plugin would break the attr method of jQuery 1.7.2.".
comment:19 Changed 14 months ago by rwaldron
Awesome!
comment:20 Changed 14 months ago by anonymous
jQuery.fn.attr looks at arguments.length regardless of whether the last argument was undefined, so if you make a function that passes all of it's arguments to .attr, it would fail.
comment:21 Changed 14 months ago by dmethvin
Yes, so if you want .attr() to act as a getter, pass it *one* string argument representing the attribute to be retrieved. That is the way it is documented. It was never documented to act as a getter when undefined was passed as a second argument. Behavior for that case is not specified, and may change from version to version as it did here.
comment:22 Changed 14 months ago by sindresorhus
#11562 is a duplicate of this ticket.
comment:23 Changed 14 months ago by rwaldron
#11572 is a duplicate of this ticket.
comment:24 Changed 13 months ago by dmethvin
- Status changed from assigned to closed
- Resolution set to invalid
Turns out TinyMCE broke this before in #7284, and as before they have fixed it again in Version 3.5b3. Lurkers and Google searchers, please update your TinyMCE and hope they don't break it a third time. http://www.tinymce.com/download/download.php
comment:25 Changed 13 months ago by dmethvin
#11615 is a duplicate of this ticket.
comment:26 Changed 13 months ago by mikesherov
#11665 is a duplicate of this ticket.
comment:27 Changed 13 months ago by rwaldron
#11683 is a duplicate of this ticket.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.




Can you please state the browser and version you're experiencing this in?
I've tried the testcase in IE6-9, Firefox 36, 11, Chrome, Opera 11.62 with jQuery 1.7.1 and 1.7.2 and I couldn't reproduce the described issue.
Duplicate of #11516, but keeping this, since it's the only one with testcase.