Skip to content

MapData events not being cleared #313

@techfg

Description

@techfg

Currently, mouseover/mouseout/touchstart & touchend events are not being cleared when clearEvents is called on MapData.

In PR #248, support for touch events was added (touchstart.mapster & touchend.mapster), however the bind was modified to add these new events to the existing mouseover.mapster & mouseout.mapster separated by a comma.

This presents issues when clearEvents is called since that code relies on the namespace .mapster to clear all events, however the expected format for bind is space-delimited vs. comma-delimited. This results in not all events being cleared when $(selector).mapster('unbind') is called leaving the events bound to orphaned elements.

A couple of ways to reproduce the issue/behavior:

  1. Using example
    1. Clone Repo
    2. Open /examples/usa.html
    3. hover over map and see expected behavior of states being "highlighted"
    4. In developer tools console, execute $("#usa_image").mapster('unbind')
    5. hover over map and you'll see the errors like the following in developer tools console:
mapdata.js:475 Uncaught TypeError: Cannot read property '20' of null
    at m.MapData.getAllDataForArea (mapdata.js:475)
    at HTMLAreaElement.mouseover (mapdata.js:146)
    at HTMLAreaElement.me.mouseover (mapdata.js:359)
    at HTMLAreaElement.dispatch (jquery.js:3256)
    at HTMLAreaElement.eventHandle (jquery.js:2875)
  1. Running tests
    1. Clone Repo
    2. Open /tests/imagemapster-test-runner.html
    3. Click "select all"
    4. Select "run tests" -> The "events" group and "tooltips" groups will fail as follows:
Starting test group "events": Failed
Starting test "Mouse Events": Failed
Test #1 assert.resolves failed : Error: timed out in test "The last test was run"
Test #1 assert.resolves failed : Error: timed out in test "The last test was run"
The test was stopped because an assertion failed.. Debugging is enabled if you start again.
1 assertions passed.

Starting test group "tooltips": Failed
Starting test "Imagemap tooltips": Failed
An error occurred in your test code: TypeError: Cannot read property '31' of null. Debugging is enabled if you start again.
1 assertions passed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions