"TypeError: el.className is undefined" When dragging map and release beyond browser window (only FF)

410 views
Skip to first unread message

Rohit Wagh

unread,
Apr 17, 2014, 2:54:51 AM4/17/14
to leafl...@googlegroups.com
When mouse pointer is dragged over the map and then dragged beyond the browser window and release outside the browser window, it throws the following error:

TypeError: el.className is undefined

return el.className.baseVal === undefined ? el.className : el.className.baseVal

This only occurs in Firefox (found this on Windows 7 and Firefox 28.0).

At First thought this link as solution, but tries a very simple example (no jquery) yet the error occurs. Refer this jsfiddle.

This line 996 only hits on firefox and not other browser (checked on Safari 5.1.7, chrome 33 and ie 11 on windows) on this behaviour i.e. on dragging cursor beyond browser window.

gp

unread,
Apr 22, 2014, 10:13:01 AM4/22/14
to leafl...@googlegroups.com
Hi Rohit,
 
thank you for finding this, I was investigating a similar error and I guess this is the cause. That was hard to catch – how many people are dragging out of the window? 

The problem happens when the Draggable._onUp(e) function is called:

L.DomUtil.removeClass((e.target || e.srcElement), 'leaflet-drag-target');

When dragging out of the window, the event is a `document` object, which doesn't look to have the className attribute.
Did you wrote an issue on github about this?

Giampaolo
Message has been deleted

Rohit Wagh

unread,
Apr 23, 2014, 6:51:43 AM4/23/14
to leafl...@googlegroups.com
@gp haven't logged an issue on github. thought would find some solution here itself. but looks like its is a bug and so will log on github. Will post here the link of github issue after i post the issue there...

Rohit Wagh

unread,
Apr 23, 2014, 7:05:17 AM4/23/14
to leafl...@googlegroups.com
have posted the issue on github. here is the link https://github.com/Leaflet/Leaflet/issues/2647

gp

unread,
Apr 23, 2014, 4:43:55 PM4/23/14
to leafl...@googlegroups.com
Thanks!

FYI I've fixed it temporarily by changing the _onUp() method:

if ((e.target && e.target.className) || (e.srcElement && e.srcElement.className)) {
L.DomUtil.removeClass((e.target || e.srcElement), 'leaflet-drag-target');
}

-- 
gp
Reply all
Reply to author
Forward
0 new messages