maphilight icon indicating copy to clipboard operation
maphilight copied to clipboard

Throws an error when used in XHTML context (using Firefox 37), stop working

Open herbalite opened this issue 10 years ago • 0 comments

When using maphilight with a page served with

application/xhtml+xml;

then Firefox will throw an exception at the line a.innerHTML = '<v:shape id="vml_flag1" adj="1" />';

I've fixed this by extending the has_VML function using an exception. Also changed b.adj == "object" to b.adj === "object" to shut up Netbeans from naging about the comparison. But this is not strictly needed to avoid Netscape throwing an error.

has_VML = (function() {
        try {
            var a = document.createElement('div');
            a.innerHTML = '<v:shape id="vml_flag1" adj="1" />';
            var b = a.firstChild;
            b.style.behavior = "url(#default#VML)";
            return b ? typeof b.adj === "object": true;
        }
        catch (err)
        {
            return false;
        }
    })();

Of course, once MSIE 9 is history, the VML part of this plugin could be dropped entirely.

herbalite avatar Apr 09 '15 23:04 herbalite