Apache Cordova
  1. Apache Cordova
  2. CB-683

Pause and resume events are fired without event parameter

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.6.1, 1.7.0
    • Fix Version/s: 1.8.0
    • Component/s: CordovaJS
    • Labels:
      None
    • Environment:

      Samsung Galaxy S plus (GT-I9001), HTC Desire (htc_bravo), iPhone

      Description

      The pause and resume events do not pass an event object to the event handlers. This event parameter is not optional according to W3C DOM specification (http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-registration) and expected by for instance jquery.

        Activity

        Hide
        Wouter added a comment -

        Sample file to reproduce this issue.

        Show
        Wouter added a comment - Sample file to reproduce this issue.
        Hide
        Wouter added a comment -

        Using jquery to bind the event:
        $(document).bind('pause', handler);
        will cause an exception on Android since jquery will internally request properties of the event parameter.
        On iOS there will be no exception since iOS supplies a window.event property which jQuery uses when no event parameter is present.

        A workaround is not to use jquery but simply:
        document.addEventListener('pause', handler, false);
        The event handler should not be expecting an event parameter in this case, for both Android and iOS.

        Show
        Wouter added a comment - Using jquery to bind the event: $(document).bind('pause', handler); will cause an exception on Android since jquery will internally request properties of the event parameter. On iOS there will be no exception since iOS supplies a window.event property which jQuery uses when no event parameter is present. A workaround is not to use jquery but simply: document.addEventListener('pause', handler, false); The event handler should not be expecting an event parameter in this case, for both Android and iOS.
        Hide
        Filip Maj added a comment -

        Will fix in 1.8. This is not a native platform issue but rather a cordova-js issue.

        Show
        Filip Maj added a comment - Will fix in 1.8. This is not a native platform issue but rather a cordova-js issue.
        Hide
        Filip Maj added a comment -

        For Android, as of commit 6a628f, this is fixed.

        For iOS, as of commit 0a4dbf, this is fixed.

        Also, looks like WP7 had this issue. As of commit 9c1c36 in the JS, this is fixed too.

        Show
        Filip Maj added a comment - For Android, as of commit 6a628f , this is fixed. For iOS, as of commit 0a4dbf , this is fixed. Also, looks like WP7 had this issue. As of commit 9c1c36 in the JS , this is fixed too.
        Hide
        Wouter added a comment -

        Wow, quick fix, thank you.

        I noticed that the same issue also applies to the deviceready event, does your fix solve that one as well?

        Show
        Wouter added a comment - Wow, quick fix, thank you. I noticed that the same issue also applies to the deviceready event, does your fix solve that one as well?
        Hide
        Filip Maj added a comment -

        Good catch! As of commit 55e46c, it does!

        Show
        Filip Maj added a comment - Good catch! As of commit 55e46c , it does!

          People

          • Assignee:
            Filip Maj
            Reporter:
            Wouter
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development