Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-8958

CommandProxy functions for multiple plugins get clobbered if same function name is used

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.6.3
    • None
    • cordova-windows
    • None
    • windows

    Description

      Project: https://github.com/ashwinde/cordova/tree/master/TestMerges
      Cordova version: 3.6.4
      I have added 2 plugins - InAppBrowser and TestPlugin to this cordova project on Windows.

      Each plugin define a close() and show() functions i.e. functions with same names.
      Each plugin.xml defines the commandProxy with merges=""

      Run the sample.
      InAppBrowser window will be opened to display google.com
      Click on "x" close button on the inappbrowser window.
      You will notice that the TestPlugin.close() method is invoked rather than IAB.close().

      The problem is that both plugins use merges="" for defining their own command proxies. since both plugins use the same function names i.e. close() and show(), cordova.js will clobber the close() and show() function for the IAB command proxy with the TestPlugin command proxy.

      That is a common pattern that is being used by all cordova plugins on Windows. So, it may manifest itself when 2 plugins use the same function name (yet in a different namespace)

      A better way to do this would be to use merges = "unique string" to define the command proxy for a plugin. This would guarantee that functions dont get clobbered inadvertently.

      Or fix cordova.js so that this clobbering does not occur

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              ashwinde Ashwin Desai
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: