Initially reported for the device motion plugin, the same problem exists for the device orientation plugin.
The plugin's plugin.xml defines a general <js-module> with the name compass. It defines another <js-module> for the browser platform (that merges with the general module) with the same name. Modules with the same name are not allowed, so Cordova throws an exception at runtime when trying to define the browser version of the module.
Since the only difference in the browser version of the module is to fake up deviceorientation events, I've deleted the browser version and added that logic to the general module, with the following change: rather than starting a new event timer every time watchHeading() is called (which could happen multiple times resulting in multiple superfluous timers), we have a single event timer going as long as there are active watchers.
Initially reported for the
device motion
plugin, the same problem exists for thedevice orientation
plugin.The plugin's
plugin.xml
defines a general<js-module>
with the namecompass
. It defines another<js-module>
for thebrowser
platform (that merges with the general module) with the same name. Modules with the same name are not allowed, so Cordova throws an exception at runtime when trying to define the browser version of the module.Since the only difference in the browser version of the module is to fake up
deviceorientation
events, I've deleted the browser version and added that logic to the general module, with the following change: rather than starting a new event timer every timewatchHeading()
is called (which could happen multiple times resulting in multiple superfluous timers), we have a single event timer going as long as there are active watchers.