Merge branch 'fixMemoryLeak' of https://github.com/csantanapr/cordova-js into 3.1.x
diff --git a/VERSION b/VERSION
index 7eb4a21..fd2a018 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-3.1.0-rc1
+3.1.0
diff --git a/lib/blackberry10/platform.js b/lib/blackberry10/platform.js
index 73a322f..99f1cb1 100644
--- a/lib/blackberry10/platform.js
+++ b/lib/blackberry10/platform.js
@@ -37,18 +37,25 @@
                 addDocumentEventListener.apply(document, arguments);
                 //Trapping when users add listeners to the webworks ready event
                 //This way we can make sure not to fire the event before there is a listener
-                if (event.toLowerCase() === 'webworksready') {
+                if (type.toLowerCase() === 'webworksready') {
                     listenerRegistered = true;
                     fireWebworksReadyEvent();
                 }
             }
         };
 
+        channel.onDOMContentLoaded.subscribe(function () {
+            document.addEventListener("webworksready", function () {
+                channel.onNativeReady.fire();
+            });
+        });
+
         channel.onPluginsReady.subscribe(function () {
             webworksReady = true;
             fireWebworksReadyEvent();
         });
 
+
         //Only fire the webworks event when both webworks is ready and a listener is registered
         function fireWebworksReadyEvent() {
             var evt;
@@ -57,7 +64,6 @@
                 evt = document.createEvent('Events');
                 evt.initEvent('webworksready', true, true);
                 document.dispatchEvent(evt);
-                channel.onNativeReady.fire();
             }
         }