Bug Tracker

Opened 8 years ago

Closed 7 years ago

Last modified 7 years ago

#11527 closed bug (invalid)

attr('href') returns object

Reported by: info@… 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

http://jsfiddle.net/VZLsH/1/

Change History (26)

comment:1 Changed 8 years ago by sindresorhus

Component: unfiledattributes
Owner: set to info@…
Priority: undecidedlow
Status: newpending

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.

comment:3 Changed 8 years ago by sindresorhus

#11516 is a duplicate of this ticket.

comment:4 Changed 8 years ago by Rick Waldron

In support of @sindresorhus

Chrome...

http://gyazo.com/828bf2ed411b3aa03f9ad0129a0e0587.png

IE8... http://gyazo.com/0394a3326d3a5b0636c50d783cad3f93.png

I can post more if nec

comment:5 Changed 8 years ago by info@…

Status: pendingnew

It doesn't work with Firefox 11 on Windows XP.

comment:6 Changed 8 years ago by Rick Waldron

Works there as well:

http://gyazo.com/c98bf91d4b281549ae541397edd7d4fc.png

comment:7 Changed 8 years ago by Rick Waldron

Status: newpending

comment:8 Changed 8 years ago by sindresorhus

#11529 is a duplicate of this ticket.

comment:9 Changed 8 years 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 8 years ago by Rick Waldron

@info@…

When you created the jsfiddle - did the bug reproduce?

comment:11 Changed 8 years ago by Rick Waldron

Owner: changed from info@… to Rick Waldron
Priority: lowblocker
Status: pendingassigned

comment:12 Changed 8 years ago by Rick Waldron

#11512 is a duplicate of this ticket.

comment:13 Changed 8 years ago by Rick Waldron

#11519 is a duplicate of this ticket.

comment:14 Changed 8 years 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 8 years 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 8 years ago by ajpiano

#11531 is a duplicate of this ticket.

comment:17 Changed 8 years ago by gnarf

Left a comment on the gist for anyone interested in the actual fix in TinyMCE's punch.

comment:18 Changed 8 years 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 8 years ago by Rick Waldron

Awesome!

comment:20 Changed 8 years 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 8 years 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 8 years ago by sindresorhus

#11562 is a duplicate of this ticket.

comment:23 Changed 8 years ago by Rick Waldron

#11572 is a duplicate of this ticket.

comment:24 Changed 7 years ago by dmethvin

Resolution: invalid
Status: assignedclosed

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 7 years ago by dmethvin

#11615 is a duplicate of this ticket.

comment:26 Changed 7 years ago by mikesherov

#11665 is a duplicate of this ticket.

comment:27 Changed 7 years ago by Rick Waldron

#11683 is a duplicate of this ticket.

Note: See TracTickets for help on using tickets.