|
1 | 1 | /*!
|
2 |
| - * vue-router v0.6.0 |
| 2 | + * vue-router v0.6.1 |
3 | 3 | * (c) 2015 Evan You
|
4 | 4 | * Released under the MIT License.
|
5 | 5 | */
|
@@ -2417,7 +2417,11 @@ return /******/ (function(modules) { // webpackBootstrap
|
2417 | 2417 | exports['default'] = function (Vue) {
|
2418 | 2418 |
|
2419 | 2419 | 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; |
2421 | 2425 | // <router-view> extends the internal component directive
|
2422 | 2426 | var viewDef = _.extend({}, componentDef);
|
2423 | 2427 |
|
@@ -2525,11 +2529,30 @@ return /******/ (function(modules) { // webpackBootstrap
|
2525 | 2529 | }
|
2526 | 2530 | var router = vm.$route.router;
|
2527 | 2531 | 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'"> |
2529 | 2541 | e.preventDefault();
|
2530 | 2542 | if (_this.destination != null) {
|
2531 | 2543 | router.go(_this.destination);
|
2532 | 2544 | }
|
| 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 | + } |
2533 | 2556 | }
|
2534 | 2557 | };
|
2535 | 2558 | this.el.addEventListener('click', this.handler);
|
@@ -2578,6 +2601,10 @@ return /******/ (function(modules) { // webpackBootstrap
|
2578 | 2601 | this.unwatch && this.unwatch();
|
2579 | 2602 | }
|
2580 | 2603 | });
|
| 2604 | + |
| 2605 | + function sameOrigin(link) { |
| 2606 | + return link.protocol === location.protocol && link.hostname === location.hostname && link.port === location.port; |
| 2607 | + } |
2581 | 2608 | };
|
2582 | 2609 |
|
2583 | 2610 | module.exports = exports['default'];
|
|
0 commit comments