Skip to content

Access of undefined property when dragging the map in IE11 #2102

@fnicollet

Description

@fnicollet

Hi,

I have just been trying leaflet-master (18 Oct 2013) in my project, which is a Windows 8 application, that is running into IE11.

Microsoft unprefixed the "MSPointerXXX" events t more standard pointerxxx events, see "MS vendor prefix removal":
http://msdn.microsoft.com/en-US/library/windows/apps/dn263112.aspx

I saw that there was a commit 14 days ago about this issue:
6e3e0d9

But when i init a simple map and click the map, it crashes. The problem is in
L.DomEvent, at this line:

if (L.Browser.pointer && type.indexOf('touch') === 0) {

here, type is undefined.

Here is the call stack:
addListener [leaflet-src.js] Line 6332
_onDown [leaflet-src.js] Line 6647
handler [leaflet-src.js] Line 6329
cb [leaflet-src.js] Line 7152

Basically, before that, it goes in the "_onDown" function from Draggable.js:
https://github.com/Leaflet/Leaflet/blob/master/src/dom/Draggable.js
Especially at this line:

L.DomEvent
            .on(document, L.Draggable.MOVE[e.type], this._onMove, this)
            .on(document, L.Draggable.END[e.type], this._onUp, this);

The "e.type" is "pointerdown" at this point, so it cannot find it in the static map defined like this:

statics: {
                START: L.Browser.touch ? ['touchstart', 'mousedown'] : ['mousedown'],
                END: {
                        mousedown: 'mouseup',
                        touchstart: 'touchend',
                        MSPointerDown: 'touchend'
                },
                MOVE: {
                        mousedown: 'mousemove',
                        touchstart: 'touchmove',
                        MSPointerDown: 'touchmove'
                }
        },

Adding "pointerdown" to both lists fixes it, from what i tested (dragging the map, dragging markers)

END: {
            mousedown: 'mouseup',
            touchstart: 'touchend',
            pointerdown: 'touchend',
            MSPointerDown: 'touchend'
        },
        MOVE: {
            mousedown: 'mousemove',
            touchstart: 'touchmove',
            pointerdown: 'touchmove',
            MSPointerDown: 'touchmove'
        }

Fabien

Metadata

Metadata

Assignees

Labels

blockerCritical issue or PR that must be resolved before the next release

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions