This project is archived and is in readonly mode.

#270 ✓wontfix
Daniel Steigerwald

Internet Exolorer href bug & fix

Reported by Daniel Steigerwald | July 28th, 2008 @ 04:32 PM

http://www.hedgerwow.com/360/bug...

And fix for MooTools:

if (Browser.Engine.trident) {
    Element.Properties.href.set = function(href) {
        this.href = ' ' + href;
        return this;
    }
}

Comments and changes to this ticket

  • Daniel Steigerwald

    Daniel Steigerwald July 29th, 2008 @ 02:39 PM

    new version

    href: {
            set: function(href) {
                (href = href.trim())
                    ? this.href = (Browser.Engine.trident ? ' ' : '') + href // fix ie href bug
                    : this.removeProperty('href');                           // prevent link clickability                                      
            }
        },        
    
  • Tom Occhino

    Tom Occhino October 3rd, 2008 @ 05:12 AM

    • State changed from “new” to “resolved”

    fixed, to be merged for 1.2.1

  • Tom Occhino

    Tom Occhino October 3rd, 2008 @ 06:22 AM

    • Assigned user changed from “Valerio” to “Tom Occhino”
    • State changed from “resolved” to “invalid”
    • Milestone changed from 2.0 to 1.2.1

    i had fixed this, and then i went back on the fix for a few reasons. - when retrieving the href from the anchor, it has whitespace, and needs to be cleaned. - the IE behavior isn't that bad! if the text inside a link is a single text node containing a URI, then it should be the actual href the element is pointing to

    I know the behavior is inconsistent and could be considered a bug, but I have to say that the negative effects of the fix greatly outweigh the positives. I think this is why this topic hasn't come up over the past two years...

    Sorry Daniel!

  • Daniel Steigerwald

    Daniel Steigerwald October 3rd, 2008 @ 01:24 PM

    Tomocchino, please look and test this:

    
    var link = new Element('a', {
        text: 'http://mootools.net - click here for more',
        href: 'http://mootools.net' // and " - click here for more" will be deleted..
    }).inject(document.body);
    

    Do you think it's correct? I don't think so. Furthermore, this behavior is't supported by any other browsers, that's why I call it bug to fix.

    If you do not like href with additional whitespace, just let make a also getter for IE.

  • Daniel Steigerwald
  • Tom Occhino

    Tom Occhino October 15th, 2008 @ 03:24 PM

    • State changed from “invalid” to “open”
    • Milestone changed from 1.2.1 to 1.2.3

    Sorry Daniel, but this fix is unacceptable, because you are replacing one unexpected outcome with another. Not to mention it requires the user use a getter that no one will ever think to use, and you lose the default getter which uses getAttribute('href', 2). (see ms documentation for information about the iFlags attribute)

    A better fix would be the following:

    • store the innerHTML of the anchor before changing the href

    • change the href

    • compare the new innerHTML to the old, and restore if necessary

    If the innerHTML is no longer the same after changing the href, the content was just text, and was erroneously altered by Internet Explorer.

  • Daniel Steigerwald

    Daniel Steigerwald October 15th, 2008 @ 04:22 PM

    • Tag changed from defect, ie, patch to defect, ie

    InnerHTML sucks all the time, but I have fount two possible solutions:

    http://pastie.org/293061

    note: first is general replacement for innerHTML, but I dont thing is needed, because that bug happes only if anchor has only textnode.

  • Daniel Steigerwald
  • Daniel Steigerwald

    Daniel Steigerwald October 15th, 2008 @ 05:40 PM

    Even better fix: http://pastie.textmate.org/293125

    That one support also more textnodes, and there is also something like premature failing specs :)

  • Daniel Steigerwald
  • Thomas Aylott
  • Christoph Pojer

    Christoph Pojer September 5th, 2010 @ 01:25 AM

    • State changed from “open” to “wontfix”
    • Assigned user cleared.
    • Milestone order changed from “0” to “0”

Create your profile

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

Shared Ticket Bins

Tags

Referenced by

Pages