Closed Bug 299724 Opened 19 years ago Closed 19 years ago

[JS] string.link(string) uses old string value

Categories

(Firefox :: General, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: yahikootje, Unassigned)

References

()

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511 Firefox/1.0.4
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511 Firefox/1.0.4

I discovered some weird behaviour with the "link" method on a string object.
You can try it at http://yahiko.serenitec.be/link.html but it comes down to this :

var txt = "Supercalifragi- listicexpialidocious";
txt = txt.substr( 0,3 );
document.form_1.field.value = txt.link( txt );

First we take the first 3 characters from the txt variable, being "Sup", and
then we try to make a link from this using the "link" method. 

Instead of giving us 
	<a href="Sup">Sup</a>
it gives
	<a href="Supercalifragi- listicexpialidocious">Sup</a>

So it seems to be using the old value of txt.
Has also been tested on linux (Gentoo & Firefox 1.04)

By doing an alert(txt) before the txt.link(txt) , this problem didn't occur,
which is even stranger of course.

Reproducible: Always

Steps to Reproduce:
1. Click on the "test" button
2.
3.

Actual Results:  
<a href="Supercalifragi- listicexpialidocious">Sup</a>

Expected Results:  
<a href="Sup">Sup</a>
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.7.8) Gecko/20050511
Firefox/1.0.4

I see the same behaviour in the test case as the reporter.

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8b2) Gecko/20050703
Firefox/1.0+ ID:2005070313

WFM - test case gives <a href="Sup">Sup</a>

Reporter this appears to be fixed in current trunk builds:
ftp://ftp.mozilla.org/pub/mozilla.org/mozilla/nightly/latest-trunk/
WFM Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8b5) Gecko/20051015
Firefox/1.4.1 as well.
Status: UNCONFIRMED → RESOLVED
Closed: 19 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.