This project is archived and is in readonly mode.

#329 ✓resolved
adamnfish

clone empty href issue

Reported by adamnfish | August 23rd, 2008 @ 03:51 PM | in 2.0 (closed)

Cloning an a tag fails to copy the href attribute if it is empty. An empty href is perfectly valid, and is used as shorthand for pointing to the current page. Indeed, accessing the property directly for an empty href will return the current location. Unfortunately the attributes 'NamedNodeMap' (as Firebug puts it) sees the href value for what it is, because the 'nodeValue' itself is empty.

The problem, is that while an empty href is valid, an href that doesn't exist is not. After cloning, a link with an empty href won't appear underlined and the CSS definitions that apply to the tag do not function.

The following change would do the trick: mootools-1.2-core line 1533 (Element::clone)

                var attribute = this.attributes[j], key = attribute.nodeName.toLowerCase();
                if (Browser.Engine.trident && (/input/i).test(this.tagName) && (/width|height/).test(key)) continue;

-- var value = (key == 'style' && this.style) ? this.style.cssText : attribute.nodeValue; ++ var value = (key == 'href' ? this.href : ((key == 'style' && this.style) ? this.style.cssText : attribute.nodeValue));

                if (!$chk(value) || key == 'uid' || (key == 'id' && !keepid)) continue;
                if (value != 'inherit' && ['string', 'number'].contains($type(value))) attributes[key] = value;

Comments and changes to this ticket

  • adamnfish

    adamnfish August 23rd, 2008 @ 03:54 PM

    Sorry about the formatting. Let's try this.

    Line 1535 old: var value = (key == 'style' && this.style) ? this.style.cssText : attribute.nodeValue; patched: var value = (key == 'href' ? this.href : ((key == 'style' && this.style) ? this.style.cssText : attribute.nodeValue));

  • Tom Occhino

    Tom Occhino August 31st, 2008 @ 07:29 PM

    • State changed from “new” to “resolved”

    fixed with new Element.clone

Create your profile

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

Shared Ticket Bins

People watching this ticket

Pages