Repository: incubator-weex
Updated Branches:
  refs/heads/master af6531238 -> e9bcc4578


* [jsfm] amend arguments of component hook


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/e9bcc457
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/e9bcc457
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/e9bcc457

Branch: refs/heads/master
Commit: e9bcc4578dff7431b3b066072ba17df79f2364d9
Parents: af65312
Author: Hanks <[email protected]>
Authored: Tue Feb 6 19:28:21 2018 +0800
Committer: Hanks <[email protected]>
Committed: Tue Feb 6 19:28:21 2018 +0800

----------------------------------------------------------------------
 runtime/bridge/CallbackManager.js | 8 +++-----
 runtime/bridge/receiver.js        | 4 ++--
 2 files changed, 5 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/e9bcc457/runtime/bridge/CallbackManager.js
----------------------------------------------------------------------
diff --git a/runtime/bridge/CallbackManager.js 
b/runtime/bridge/CallbackManager.js
index 70bd729..04d339c 100644
--- a/runtime/bridge/CallbackManager.js
+++ b/runtime/bridge/CallbackManager.js
@@ -17,8 +17,6 @@
  * under the License.
  */
 
-import { decodePrimitive } from './normalize'
-
 function getHookKey (componentId, type, hookName) {
   return `${type}@${hookName}#${componentId}`
 }
@@ -55,7 +53,7 @@ export default class CallbackManager {
     }
     this.hooks[key] = hookFunction
   }
-  triggerHook (componentId, type, hookName, options = {}) {
+  triggerHook (componentId, type, hookName, args) {
     // TODO: validate arguments
     const key = getHookKey(componentId, type, hookName)
     const hookFunction = this.hooks[key]
@@ -65,7 +63,7 @@ export default class CallbackManager {
     }
     let result = null
     try {
-      result = hookFunction.apply(null, options.args || [])
+      result = hookFunction.apply(null, args || [])
     }
     catch (e) {
       console.error(`[JS Framework] Failed to execute the hook function on 
"${key}".`)
@@ -78,7 +76,7 @@ export default class CallbackManager {
       delete this.callbacks[callbackId]
     }
     if (typeof callback === 'function') {
-      return callback(decodePrimitive(data))
+      return callback(data)
     }
     return new Error(`invalid callback id "${callbackId}"`)
   }

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/e9bcc457/runtime/bridge/receiver.js
----------------------------------------------------------------------
diff --git a/runtime/bridge/receiver.js b/runtime/bridge/receiver.js
index e6dea06..ecf6fa1 100644
--- a/runtime/bridge/receiver.js
+++ b/runtime/bridge/receiver.js
@@ -31,14 +31,14 @@ function callback (document, callbackId, data, ifKeepAlive) 
{
   return document.taskCenter.callback(callbackId, data, ifKeepAlive)
 }
 
-function componentHook (document, componentId, type, hook, options) {
+function componentHook (document, componentId, type, hook, args) {
   if (!document || !document.taskCenter) {
     console.error(`[JS Framework] Can't find "document" or "taskCenter".`)
     return null
   }
   let result = null
   try {
-    result = document.taskCenter.triggerHook(componentId, type, hook, options)
+    result = document.taskCenter.triggerHook(componentId, type, hook, args)
   }
   catch (e) {
     console.error(`[JS Framework] Failed to trigger the "${type}@${hook}" hook 
on ${componentId}.`)

Reply via email to