You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Daniel Wirtz (JIRA)" <ji...@apache.org> on 2013/02/22 19:36:12 UTC

[jira] [Comment Edited] (CB-2526) Cordova messes with global "navigator", renders navigator.getGamepads() useless

    [ https://issues.apache.org/jira/browse/CB-2526?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13584517#comment-13584517 ] 

Daniel Wirtz edited comment on CB-2526 at 2/22/13 6:34 PM:
-----------------------------------------------------------

Yes, will become a real problem as soon as mobile browsers start implementing the gamepad API and developers actually want to use that. Till then it will break all apps that use it and are run for debugging purposes on the desktop.

A possible fix:

        var CordovaNavigator = function() {};
        CordovaNavigator.prototype = context.navigator;
        CordovaNavigator.getGamepads = function() {
            var navigator = context.navigator;
            if (navigator.getGamepads) return navigator.getGamepads();
            if (navigator.webkitGetGamepads) return navigator.webkitGetGamepads();
            return undefined;
        }
        context.navigator = new CordovaNavigator();
                
      was (Author: dcode):
    Yes, will become a real problem as soon as mobile browsers start implementing the gamepad API and developers actually want to use that. Till then it will break all apps that use it and are run for debugging purposes on the desktop.

A possible fix:

        var CordovaNavigator = function() {};
        CordovaNavigator.prototype = context.navigator;
        CordovaNavigator.prototype.getGamepads = function() {
            var navigator = context.navigator;
            if (navigator.getGamepads) return navigator.getGamepads();
            if (navigator.webkitGetGamepads) return navigator.webkitGetGamepads();
            return undefined;
        }
        context.navigator = new CordovaNavigator();
                  
> Cordova messes with global "navigator", renders navigator.getGamepads() useless
> -------------------------------------------------------------------------------
>
>                 Key: CB-2526
>                 URL: https://issues.apache.org/jira/browse/CB-2526
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: CordovaJS
>    Affects Versions: 2.4.0
>            Reporter: Daniel Wirtz
>            Assignee: Filip Maj
>            Priority: Minor
>
> Cordova messes with the global "navigator" object and renders a call to navigator.webkitGetGamepads useless - throws Illegal Invocation Exception with Cordova, works without.
> Workaround: Keep another reference to "navigator" before loading cordova-2.X.X.js.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira