Skip to content

Commit 37e502b

Browse files
committed
[build] 0.6.1
1 parent 83f7700 commit 37e502b

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed

dist/vue-router.js

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* vue-router v0.6.0
2+
* vue-router v0.6.1
33
* (c) 2015 Evan You
44
* Released under the MIT License.
55
*/
@@ -2417,7 +2417,11 @@ return /******/ (function(modules) { // webpackBootstrap
24172417
exports['default'] = function (Vue) {
24182418

24192419
var _ = Vue.util;
2420-
var componentDef = Vue.directive('_component');
2420+
var componentDef =
2421+
// 0.12
2422+
Vue.directive('_component') ||
2423+
// 1.0
2424+
Vue.internalDirectives.component;
24212425
// <router-view> extends the internal component directive
24222426
var viewDef = _.extend({}, componentDef);
24232427

@@ -2525,11 +2529,30 @@ return /******/ (function(modules) { // webpackBootstrap
25252529
}
25262530
var router = vm.$route.router;
25272531
this.handler = function (e) {
2528-
if (e.button === 0) {
2532+
// don't redirect with control keys
2533+
if (e.metaKey || e.ctrlKey || e.shiftKey) return;
2534+
// don't redirect when preventDefault called
2535+
if (e.defaultPrevented) return;
2536+
// don't redirect on right click
2537+
if (e.button !== 0) return;
2538+
2539+
if (_this.el.tagName === 'A') {
2540+
// v-link on <a v-link="'path'">
25292541
e.preventDefault();
25302542
if (_this.destination != null) {
25312543
router.go(_this.destination);
25322544
}
2545+
} else {
2546+
// v-link delegate on <div v-link>
2547+
var el = e.target;
2548+
while (el && el.tagName !== 'A' && el !== _this.el) {
2549+
el = el.parentNode;
2550+
}
2551+
if (!el || el.tagName !== 'A' || !el.href) return;
2552+
if (sameOrigin(el)) {
2553+
e.preventDefault();
2554+
router.go(el.pathname);
2555+
}
25332556
}
25342557
};
25352558
this.el.addEventListener('click', this.handler);
@@ -2578,6 +2601,10 @@ return /******/ (function(modules) { // webpackBootstrap
25782601
this.unwatch && this.unwatch();
25792602
}
25802603
});
2604+
2605+
function sameOrigin(link) {
2606+
return link.protocol === location.protocol && link.hostname === location.hostname && link.port === location.port;
2607+
}
25812608
};
25822609

25832610
module.exports = exports['default'];

0 commit comments

Comments
 (0)