This bug has been identified in Firefox and detailed information can be found at https://bugzilla.mozilla.org/show_bug.cgi?id=193321
The bug has shown inconsistent behavior with various reports, indicating a non-standard and browser-specific issue.
An effective workaround involves utilizing JavaScript to address the problem. However, direct influence on pseudo-selector states is limited unless operating in privileged mode (e.g., within an extension). As a result, adding or removing a class name is recommended:
<a href="#" onmousedown="this.className = '';" ondragend="this.className = 'inactive';" id="foo" >Drag me</a>
Experiment with this method using: http://jsfiddle.net/frsRS/
If operating in privileged mode, consider employing the technique utilized by Firebug's CSS Panel using inIDOMUtils.setContentState
var node = document.getElementById("foo");
var domUtil = Components.classes["@mozilla.org/inspector/dom-utils;1"].getService(Components.interfaces.inIDOMUtils);
domUtil.setContentState(node, 1);
Edit
A more advanced implementation for binding cross-browser delegates instead of inline JavaScript (demonstrative purpose only) is provided below:
function addEvent(ele, evnt, funct) {
if (ele.addEventListener) // W3C
return ele.addEventListener(evnt,funct,false);
else if (ele.attachEvent) // IE
return ele.attachEvent("on"+evnt,funct);
}
addEvent(document.body, 'mousedown', function (e) {
if(e.target.tagName == 'A') e.target.style.color = '';
});
addEvent(document.body, 'dragend', function (e) {
if(e.target.tagName == 'A') e.target.style.color = 'blue';
});
Try it here: http://jsfiddle.net/HYJCQ/
Incorporating the element's style rather than a CSS class allows flexibility for alternative approaches.
Another strategy, proposed by Supr, involves removing and re-adding elements from the DOM immediately. This can be achieved through delegation as demonstrated here:
function addEvent(ele, evnt, funct) {
if (ele.addEventListener) // W3C
return ele.addEventListener(evnt,funct,false);
else if (ele.attachEvent) // IE
return ele.attachEvent("on"+evnt,funct);
}
addEvent(document.body, 'dragend', function (e) {
if(e.target.tagName != 'A') return;
var parent = e.target.parentNode;
var sib = e.target.nextSibling;
parent.insertBefore(
parent.removeChild(e.target),
sib
);
});
Test this method here: http://jsfiddle.net/ymPfH/
Both delegate-based techniques offer improved efficiency compared to looping through elements, enabling dynamic application to any a
tags added post-load similar to jQuery's live
or on
methods.
Documentation