This project is archived and is in readonly mode.

#266 ✓resolved
ByScripts

element.get('href') doen't return correct value

Reported by ByScripts | July 26th, 2008 @ 09:59 AM | in 1.2.1

Assuming these 2 elements :

<a id="anchor" href="myPic.png">MyPic</a>
<img id="image" src="myPic.png" />

And this javascrit part :

$('image').get('src'); // returns myPic.png
$('anchor').get('href'); // returns /dir/subdir/myPic.png

I think the .get() method should return the exact content of attribute, as defined in code, and not the full relative path.

Comments and changes to this ticket

  • Jan Kassens

    Jan Kassens July 26th, 2008 @ 10:59 AM

    • State changed from “new” to “open”
    • Assigned user cleared.

    confirmed but not sure how to fix, because some browsers (all?) report an absolute path.

    The current spec also doesnt work in all domain settings.

  • Tom Occhino

    Tom Occhino July 28th, 2008 @ 05:18 AM

    • Milestone changed from 2.0 to 1.2.1
    • Assigned user set to “Jan Kassens”

    working fix:

    Element.Properties.href = {get: function(){
    	return (!this.href) ? null : this.getAttribute('href', 2);
    }};
    

    the 2 in getAttribute is the internet explorer IFlag. the parameter is ignored in all other browsers which return the correct value for getAttribute (eg, the value exactly as it was written in the dom) Tested in ie6, 7, ff2, 3, safari 3, opera 9+...

    http://msdn.microsoft.com/en-us/... for more information about the iflag

    as soon as i learn how to use git, ill just merge patches like this in...

  • Jan Kassens

    Jan Kassens July 28th, 2008 @ 09:41 AM

    • State changed from “open” to “resolved”

    a simple remove of Element.Properties.href worked as well.

    Thanks guys.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins

Pages