From 541a543cd977ccef74842921df994ce111eaaf38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=8B=E9=93=84=E8=BF=90?= Date: Thu, 13 Oct 2016 12:30:39 +0800 Subject: [PATCH] Fix click event not bound for router-link (fix #707) (#708) * Fix click event not bound for router-link (fix #707) Fix click event not bound for `` when tag is not `` and doesn't have child `` * add e2e test --- examples/basic/app.js | 1 + src/components/link.js | 3 +++ test/e2e/specs/basic.js | 5 +++++ 3 files changed, 9 insertions(+) diff --git a/examples/basic/app.js b/examples/basic/app.js index 1744a41cc..1242bf98b 100644 --- a/examples/basic/app.js +++ b/examples/basic/app.js @@ -34,6 +34,7 @@ new Vue({
  • /
  • /foo
  • /bar
  • + /bar diff --git a/src/components/link.js b/src/components/link.js index 0fdfd8e4e..1b312f17c 100644 --- a/src/components/link.js +++ b/src/components/link.js @@ -64,6 +64,9 @@ export default { aData.on = on const aAttrs = aData.attrs || (aData.attrs = {}) aAttrs.href = href + } else { + // doesn't have
    child, apply listener to self + data.on = on } } diff --git a/test/e2e/specs/basic.js b/test/e2e/specs/basic.js index 6dfcf5372..bfe53d538 100644 --- a/test/e2e/specs/basic.js +++ b/test/e2e/specs/basic.js @@ -3,6 +3,7 @@ module.exports = { browser .url('http://localhost:8080/basic/') .waitForElementVisible('#app', 1000) + .assert.count('li', 4) .assert.count('li a', 3) // assert correct href with base .assert.attributeContains('li:nth-child(1) a', 'href', '/basic/') @@ -22,6 +23,10 @@ module.exports = { .assert.urlEquals('http://localhost:8080/basic/') .assert.containsText('.view', 'home') + .click('li:nth-child(4)') + .assert.urlEquals('http://localhost:8080/basic/bar') + .assert.containsText('.view', 'bar') + // check initial visit .url('http://localhost:8080/basic/foo') .waitForElementVisible('#app', 1000)