1
1
/*!
2
- * vue-router v0.5.1
2
+ * vue-router v0.5.2
3
3
* (c) 2015 Evan You
4
4
* Released under the MIT License.
5
5
*/
@@ -96,7 +96,7 @@ return /******/ (function(modules) { // webpackBootstrap
96
96
// auto install
97
97
/* istanbul ignore if */
98
98
if ( typeof window !== 'undefined' && window . Vue ) {
99
- _router2 [ 'default' ] . install ( window . Vue ) ;
99
+ window . Vue . use ( _router2 [ 'default' ] ) ;
100
100
}
101
101
102
102
exports [ 'default' ] = _router2 [ 'default' ] ;
@@ -1044,6 +1044,7 @@ return /******/ (function(modules) { // webpackBootstrap
1044
1044
this . _previousTransition = null ;
1045
1045
this . _notFoundHandler = null ;
1046
1046
this . _beforeEachHook = null ;
1047
+ this . _afterEachHook = null ;
1047
1048
1048
1049
// feature detection
1049
1050
this . _hasPushState = typeof window !== 'undefined' && window . history && window . history . pushState ;
@@ -1336,13 +1337,14 @@ return /******/ (function(modules) { // webpackBootstrap
1336
1337
_createClass ( HTML5History , [ {
1337
1338
key : 'start' ,
1338
1339
value : function start ( ) {
1339
- var self = this ;
1340
+ var _this = this ;
1341
+
1340
1342
this . listener = function ( e ) {
1341
1343
var url = decodeURI ( location . pathname + location . search ) ;
1342
- if ( this . root ) {
1343
- url = url . replace ( this . rootRE , '' ) ;
1344
+ if ( _this . root ) {
1345
+ url = url . replace ( _this . rootRE , '' ) ;
1344
1346
}
1345
- self . onChange ( url , e && e . state , location . hash ) ;
1347
+ _this . onChange ( url , e && e . state , location . hash ) ;
1346
1348
} ;
1347
1349
window . addEventListener ( 'popstate' , this . listener ) ;
1348
1350
this . listener ( ) ;
@@ -1472,6 +1474,16 @@ return /******/ (function(modules) { // webpackBootstrap
1472
1474
this . _beforeEachHook = fn ;
1473
1475
} ;
1474
1476
1477
+ /**
1478
+ * Set global after hook.
1479
+ *
1480
+ * @param {Function } fn
1481
+ */
1482
+
1483
+ Router . prototype . afterEach = function ( fn ) {
1484
+ this . _afterEachHook = fn ;
1485
+ } ;
1486
+
1475
1487
/**
1476
1488
* Navigate to a given path.
1477
1489
* The path is assumed to be already decoded, and will
@@ -1743,6 +1755,13 @@ return /******/ (function(modules) { // webpackBootstrap
1743
1755
child . $route = route ;
1744
1756
} ) ;
1745
1757
}
1758
+ // call global after hook
1759
+ if ( this . _afterEachHook ) {
1760
+ this . _afterEachHook . call ( null , {
1761
+ to : transition . to ,
1762
+ from : transition . from
1763
+ } ) ;
1764
+ }
1746
1765
} ;
1747
1766
1748
1767
/**
@@ -1805,20 +1824,20 @@ return /******/ (function(modules) { // webpackBootstrap
1805
1824
* @param {Router } router
1806
1825
*/
1807
1826
1808
- 'use strict' ;
1809
-
1810
- var _classCallCheck = __webpack_require__ ( 7 ) [ 'default' ] ;
1827
+ "use strict" ;
1811
1828
1812
- var _Object$defineProperty = __webpack_require__ ( 10 ) [ ' default' ] ;
1829
+ var _classCallCheck = __webpack_require__ ( 7 ) [ " default" ] ;
1813
1830
1814
- Object . defineProperty ( exports , ' __esModule' , {
1831
+ Object . defineProperty ( exports , " __esModule" , {
1815
1832
value : true
1816
1833
} ) ;
1817
1834
1818
1835
var Route = function Route ( path , router ) {
1819
1836
_classCallCheck ( this , Route ) ;
1820
1837
1821
1838
this . path = path ;
1839
+ this . router = router ;
1840
+
1822
1841
var matched = router . _recognizer . recognize ( path ) ;
1823
1842
1824
1843
this . query = matched ? matched . queryParams : { } ;
@@ -1833,20 +1852,11 @@ return /******/ (function(modules) { // webpackBootstrap
1833
1852
} , { } ) : { } ;
1834
1853
1835
1854
// private stuff
1836
- this . _aborted = false ;
1837
- def ( this , '_matched' , matched || router . _notFoundHandler ) ;
1838
- def ( this , '_router' , router ) ;
1855
+ this . _matched = matched || router . _notFoundHandler ;
1839
1856
} ;
1840
1857
1841
- exports [ 'default' ] = Route ;
1842
-
1843
- function def ( obj , key , val ) {
1844
- _Object$defineProperty ( obj , key , {
1845
- value : val ,
1846
- enumerable : false
1847
- } ) ;
1848
- }
1849
- module . exports = exports [ 'default' ] ;
1858
+ exports [ "default" ] = Route ;
1859
+ module . exports = exports [ "default" ] ;
1850
1860
1851
1861
/***/ } ,
1852
1862
/* 18 */
@@ -2397,7 +2407,7 @@ return /******/ (function(modules) { // webpackBootstrap
2397
2407
// all we need to do here is registering this view
2398
2408
// in the router. actual component switching will be
2399
2409
// managed by the pipeline.
2400
- var router = this . router = route . _router ;
2410
+ var router = this . router = route . router ;
2401
2411
router . _views . unshift ( this ) ;
2402
2412
2403
2413
// note the views are in reverse order.
@@ -2454,7 +2464,7 @@ return /******/ (function(modules) { // webpackBootstrap
2454
2464
( 0 , _util . warn ) ( 'v-link can only be used inside a ' + 'router-enabled app.' ) ;
2455
2465
return ;
2456
2466
}
2457
- var router = vm . $route . _router ;
2467
+ var router = vm . $route . router ;
2458
2468
this . handler = function ( e ) {
2459
2469
if ( e . button === 0 ) {
2460
2470
e . preventDefault ( ) ;
@@ -2474,7 +2484,7 @@ return /******/ (function(modules) { // webpackBootstrap
2474
2484
updateClasses : function updateClasses ( path ) {
2475
2485
var el = this . el ;
2476
2486
var dest = this . destination ;
2477
- var router = this . vm . $route . _router ;
2487
+ var router = this . vm . $route . router ;
2478
2488
var activeClass = router . _linkActiveClass ;
2479
2489
var exactClass = activeClass + '-exact' ;
2480
2490
if ( path . indexOf ( dest ) === 0 && path !== '/' ) {
@@ -2493,7 +2503,7 @@ return /******/ (function(modules) { // webpackBootstrap
2493
2503
this . destination = path ;
2494
2504
this . updateClasses ( this . vm . $route . path ) ;
2495
2505
path = path || '' ;
2496
- var router = this . vm . $route . _router ;
2506
+ var router = this . vm . $route . router ;
2497
2507
var isAbsolute = path . charAt ( 0 ) === '/' ;
2498
2508
// do not format non-hash relative paths
2499
2509
var href = router . mode === 'hash' || isAbsolute ? router . history . formatPath ( path ) : path ;
@@ -2533,7 +2543,7 @@ return /******/ (function(modules) { // webpackBootstrap
2533
2543
Vue . prototype . $addChild = function ( opts , Ctor ) {
2534
2544
2535
2545
var route = this . $route ;
2536
- var router = route && route . _router ;
2546
+ var router = route && route . router ;
2537
2547
2538
2548
// inject meta
2539
2549
if ( router ) {
0 commit comments