Bug Tracker

Modify

Ticket #7994 (closed bug: wontfix)

Opened 3 years ago

Last modified 2 years ago

.attr('href', ...) may change the text part.

Reported by: anonymous Owned by:
Priority: low Milestone: 1.next
Component: attributes Version: 1.4.4
Keywords: Cc:
Blocking: Blocked by:

Description

On IE8, I have element <a href=" http://testurl">test@test</a> and use .attr('href', ' http://testurl2') to change the href. But the text part (test@test) is changed to  http://testurl2 too.

The repro is at:  http://jsfiddle.net/7x3RV/2/

Change History

comment:1 Changed 3 years ago by rwaldron

  • Priority changed from undecided to low
  • Component changed from unfiled to attributes

comment:2 Changed 3 years ago by rwaldron

  • Status changed from new to open

comment:3 Changed 3 years ago by jitter

comment:4 Changed 3 years ago by danheberden

Well a fix would add, imo, too much overhead. As jitter's second link mentions (though i put in a check for the @ before bothering with replacing crap)

var $a = $(this), // assuming your link element in a click handler or whatever
       old = $a.html();
$a.attr('href', '//whaver'); // set the href
if ( old.match( /@/ ) ) { // or indexOf , whatever
    $a.html( old );
}

comment:5 Changed 3 years ago by jitter

  • Status changed from open to closed
  • Resolution set to wontfix

Given that there is a workaround for this but the workaround is impractical to get into jQuery core I close this one.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.