cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Wirtz (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CB-2526) Cordova messes with global "navigator", renders navigator.getGamepads() useless
Date Fri, 22 Feb 2013 18:34:13 GMT

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

Daniel Wirtz commented on CB-2526:
----------------------------------

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

Mime
View raw message