You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by so...@apache.org on 2017/06/16 04:06:04 UTC

[11/20] incubator-weex git commit: * [html5] fix watching appear on composing component.

* [html5] fix watching appear on composing component.


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

Branch: refs/heads/0.14-dev
Commit: 4513ef340098e2fb573bed7c5c4234b246992327
Parents: e31783a
Author: MrRaindrop <te...@gmail.com>
Authored: Fri Jun 9 11:09:54 2017 +0800
Committer: MrRaindrop <te...@gmail.com>
Committed: Fri Jun 9 11:09:54 2017 +0800

----------------------------------------------------------------------
 html5/render/vue/utils/component.js | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/4513ef34/html5/render/vue/utils/component.js
----------------------------------------------------------------------
diff --git a/html5/render/vue/utils/component.js b/html5/render/vue/utils/component.js
index 409d98a..94c6a63 100644
--- a/html5/render/vue/utils/component.js
+++ b/html5/render/vue/utils/component.js
@@ -94,13 +94,22 @@ function triggerEvent (elm, handlers, isShow, dir) {
 }
 
 /**
- * get all event listeners. including v-on binding and ons in config.
+ * get all event listeners. including bound handlers in all parent vnodes.
  */
 export function getEventHandlers (context) {
-  const parentListeners = context.$options && context.$options._parentListeners
-  const dataOn = context.$vnode && context.$vnode.data && context.$vnode.data.on
-  const on = extend({}, parentListeners, dataOn)
-  return on
+  let vnode = context.$vnode
+  const handlers = {}
+  const attachedVnodes = []
+  while (vnode) {
+    attachedVnodes.push(vnode)
+    vnode = vnode.parent
+  }
+  attachedVnodes.forEach(function (vnode) {
+    const parentListeners = vnode.componentOptions && vnode.componentOptions.listeners
+    const dataOn = vnode.data && vnode.data.on
+    extend(handlers, parentListeners, dataOn)
+  })
+  return handlers
 }
 
 /**