* [html5] add _triggered on event when evtName is click

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

Branch: refs/heads/0.16-dev
Commit: aeb55f304c2f05bc6e9f8f24047aeff1a12f4f60
Parents: 31411dd
Author: erha19 <faterr...@gmail.com>
Authored: Mon Aug 28 23:33:09 2017 +0800
Committer: erha19 <faterr...@gmail.com>
Committed: Mon Aug 28 23:33:09 2017 +0800

----------------------------------------------------------------------
 examples/vue/showcase/a-node-click.vue |  6 +++---
 html5/render/vue/env/event-manager.js  | 15 +++++++++++----
 2 files changed, 14 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/aeb55f30/examples/vue/showcase/a-node-click.vue
----------------------------------------------------------------------
diff --git a/examples/vue/showcase/a-node-click.vue 
b/examples/vue/showcase/a-node-click.vue
index bf4d5a4..26d5282 100644
--- a/examples/vue/showcase/a-node-click.vue
+++ b/examples/vue/showcase/a-node-click.vue
@@ -1,9 +1,9 @@
 <template>
   <list class="list">
     <cell class="cell" @click="clickCell">
-      <xlink style="width: 400px;height: 400px;background-color: yellow;" 
:href = "url">
-        <div class="ct" @click="click">
-          <text >CLICK ME</text>
+      <xlink style="width: 400px;height: 400px;background-color: yellow;" 
target="_blank" :href = "url">
+        <div class="ct"  @click="click">
+          <text>CLICK ME</text>
         </div>
       </xlink>
     </cell>

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/aeb55f30/html5/render/vue/env/event-manager.js
----------------------------------------------------------------------
diff --git a/html5/render/vue/env/event-manager.js 
b/html5/render/vue/env/event-manager.js
index c19a649..243daa0 100644
--- a/html5/render/vue/env/event-manager.js
+++ b/html5/render/vue/env/event-manager.js
@@ -82,9 +82,9 @@ function _init (doc) {
   _inited = true
   const _sp = supportsPassive()
   events.forEach(function (evt) {
-    const option = needPassive.indexOf(evt) > -1 && _sp
-      ? { passive: true }
-      : false
+    const option = evt === 'click' 
+      ? true : needPassive.indexOf(evt) > -1 && _sp
+      ? { passive: true } : false
     doc.addEventListener(evt, function (e) {
       const el = e.target
       let vm = el.__vue__
@@ -94,6 +94,8 @@ function _init (doc) {
        * take full control of redirection of <a> element.
        */
       if (evtName === 'click') {
+        // use '_triggered' to control bubbles event.
+        e._triggered = { target: vm.$el }
         e.preventDefault()
         return
       }
@@ -134,7 +136,12 @@ function _init (doc) {
           const target = elm.getAttribute('target')
           disposed = true
           if (target !== '_blank') {
-            location.href = href
+            if (!!href) {
+              location.href = href
+            }
+            else {
+              console.warn('[weex-vue-render] If you want to use the A tag 
jump, set the href attribute')
+            }
           }
           else {
             // do nothing.

Reply via email to