#11527 closed bug (invalid)
attr('href') returns object
Reported by: | Owned by: | Rick Waldron | |
---|---|---|---|
Priority: | blocker | Milestone: | None |
Component: | attributes | Version: | 1.7.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
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 (26)
comment:1 Changed 11 years ago by
Component: | unfiled → attributes |
---|---|
Owner: | set to [email protected]… |
Priority: | undecided → low |
Status: | new → pending |
comment:4 Changed 11 years ago by
comment:5 Changed 11 years ago by
Status: | pending → new |
---|
It doesn't work with Firefox 11 on Windows XP.
comment:7 Changed 11 years ago by
Status: | new → pending |
---|
comment:9 Changed 11 years ago by
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:11 Changed 11 years ago by
Owner: | changed from [email protected]… to Rick Waldron |
---|---|
Priority: | low → blocker |
Status: | pending → assigned |
comment:14 Changed 11 years ago by
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 11 years ago by
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:17 Changed 11 years ago by
Left a comment on the gist for anyone interested in the actual fix in TinyMCE's punch.
comment:18 Changed 11 years ago by
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:20 Changed 11 years ago by
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 11 years ago by
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:24 Changed 11 years ago by
Resolution: | → invalid |
---|---|
Status: | assigned → closed |
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
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.