11/**
2- * vue-router v2.6 .0
2+ * vue-router v2.7 .0
33 * (c) 2017 Evan You
44 * @license MIT
55 */
@@ -19,6 +19,10 @@ function warn (condition, message) {
1919 }
2020}
2121
22+ function isError ( err ) {
23+ return Object . prototype . toString . call ( err ) . indexOf ( 'Error' ) > - 1
24+ }
25+
2226var View = {
2327 name : 'router-view' ,
2428 functional : true ,
@@ -520,7 +524,7 @@ function install (Vue) {
520524
521525 var strats = Vue . config . optionMergeStrategies ;
522526 // use the same hook merging strategy for route hooks
523- strats . beforeRouteEnter = strats . beforeRouteLeave = strats . created ;
527+ strats . beforeRouteEnter = strats . beforeRouteLeave = strats . beforeRouteUpdate = strats . created ;
524528}
525529
526530/* */
@@ -1660,6 +1664,107 @@ function runQueue (queue, fn, cb) {
16601664
16611665/* */
16621666
1667+ function resolveAsyncComponents ( matched ) {
1668+ return function ( to , from , next ) {
1669+ var hasAsync = false ;
1670+ var pending = 0 ;
1671+ var error = null ;
1672+
1673+ flatMapComponents ( matched , function ( def , _ , match , key ) {
1674+ // if it's a function and doesn't have cid attached,
1675+ // assume it's an async component resolve function.
1676+ // we are not using Vue's default async resolving mechanism because
1677+ // we want to halt the navigation until the incoming component has been
1678+ // resolved.
1679+ if ( typeof def === 'function' && def . cid === undefined ) {
1680+ hasAsync = true ;
1681+ pending ++ ;
1682+
1683+ var resolve = once ( function ( resolvedDef ) {
1684+ if ( resolvedDef . __esModule && resolvedDef . default ) {
1685+ resolvedDef = resolvedDef . default ;
1686+ }
1687+ // save resolved on async factory in case it's used elsewhere
1688+ def . resolved = typeof resolvedDef === 'function'
1689+ ? resolvedDef
1690+ : _Vue . extend ( resolvedDef ) ;
1691+ match . components [ key ] = resolvedDef ;
1692+ pending -- ;
1693+ if ( pending <= 0 ) {
1694+ next ( ) ;
1695+ }
1696+ } ) ;
1697+
1698+ var reject = once ( function ( reason ) {
1699+ var msg = "Failed to resolve async component " + key + ": " + reason ;
1700+ process . env . NODE_ENV !== 'production' && warn ( false , msg ) ;
1701+ if ( ! error ) {
1702+ error = isError ( reason )
1703+ ? reason
1704+ : new Error ( msg ) ;
1705+ next ( error ) ;
1706+ }
1707+ } ) ;
1708+
1709+ var res ;
1710+ try {
1711+ res = def ( resolve , reject ) ;
1712+ } catch ( e ) {
1713+ reject ( e ) ;
1714+ }
1715+ if ( res ) {
1716+ if ( typeof res . then === 'function' ) {
1717+ res . then ( resolve , reject ) ;
1718+ } else {
1719+ // new syntax in Vue 2.3
1720+ var comp = res . component ;
1721+ if ( comp && typeof comp . then === 'function' ) {
1722+ comp . then ( resolve , reject ) ;
1723+ }
1724+ }
1725+ }
1726+ }
1727+ } ) ;
1728+
1729+ if ( ! hasAsync ) { next ( ) ; }
1730+ }
1731+ }
1732+
1733+ function flatMapComponents (
1734+ matched ,
1735+ fn
1736+ ) {
1737+ return flatten ( matched . map ( function ( m ) {
1738+ return Object . keys ( m . components ) . map ( function ( key ) { return fn (
1739+ m . components [ key ] ,
1740+ m . instances [ key ] ,
1741+ m , key
1742+ ) ; } )
1743+ } ) )
1744+ }
1745+
1746+ function flatten ( arr ) {
1747+ return Array . prototype . concat . apply ( [ ] , arr )
1748+ }
1749+
1750+ // in Webpack 2, require.ensure now also returns a Promise
1751+ // so the resolve/reject functions may get called an extra time
1752+ // if the user uses an arrow function shorthand that happens to
1753+ // return that Promise.
1754+ function once ( fn ) {
1755+ var called = false ;
1756+ return function ( ) {
1757+ var args = [ ] , len = arguments . length ;
1758+ while ( len -- ) args [ len ] = arguments [ len ] ;
1759+
1760+ if ( called ) { return }
1761+ called = true ;
1762+ return fn . apply ( this , args )
1763+ }
1764+ }
1765+
1766+ /* */
1767+
16631768var History = function History ( router , base ) {
16641769 this . router = router ;
16651770 this . base = normalizeBase ( base ) ;
@@ -1955,106 +2060,6 @@ function poll (
19552060 }
19562061}
19572062
1958- function resolveAsyncComponents ( matched ) {
1959- return function ( to , from , next ) {
1960- var hasAsync = false ;
1961- var pending = 0 ;
1962- var error = null ;
1963-
1964- flatMapComponents ( matched , function ( def , _ , match , key ) {
1965- // if it's a function and doesn't have cid attached,
1966- // assume it's an async component resolve function.
1967- // we are not using Vue's default async resolving mechanism because
1968- // we want to halt the navigation until the incoming component has been
1969- // resolved.
1970- if ( typeof def === 'function' && def . cid === undefined ) {
1971- hasAsync = true ;
1972- pending ++ ;
1973-
1974- var resolve = once ( function ( resolvedDef ) {
1975- // save resolved on async factory in case it's used elsewhere
1976- def . resolved = typeof resolvedDef === 'function'
1977- ? resolvedDef
1978- : _Vue . extend ( resolvedDef ) ;
1979- match . components [ key ] = resolvedDef ;
1980- pending -- ;
1981- if ( pending <= 0 ) {
1982- next ( ) ;
1983- }
1984- } ) ;
1985-
1986- var reject = once ( function ( reason ) {
1987- var msg = "Failed to resolve async component " + key + ": " + reason ;
1988- process . env . NODE_ENV !== 'production' && warn ( false , msg ) ;
1989- if ( ! error ) {
1990- error = isError ( reason )
1991- ? reason
1992- : new Error ( msg ) ;
1993- next ( error ) ;
1994- }
1995- } ) ;
1996-
1997- var res ;
1998- try {
1999- res = def ( resolve , reject ) ;
2000- } catch ( e ) {
2001- reject ( e ) ;
2002- }
2003- if ( res ) {
2004- if ( typeof res . then === 'function' ) {
2005- res . then ( resolve , reject ) ;
2006- } else {
2007- // new syntax in Vue 2.3
2008- var comp = res . component ;
2009- if ( comp && typeof comp . then === 'function' ) {
2010- comp . then ( resolve , reject ) ;
2011- }
2012- }
2013- }
2014- }
2015- } ) ;
2016-
2017- if ( ! hasAsync ) { next ( ) ; }
2018- }
2019- }
2020-
2021- function flatMapComponents (
2022- matched ,
2023- fn
2024- ) {
2025- return flatten ( matched . map ( function ( m ) {
2026- return Object . keys ( m . components ) . map ( function ( key ) { return fn (
2027- m . components [ key ] ,
2028- m . instances [ key ] ,
2029- m , key
2030- ) ; } )
2031- } ) )
2032- }
2033-
2034- function flatten ( arr ) {
2035- return Array . prototype . concat . apply ( [ ] , arr )
2036- }
2037-
2038- // in Webpack 2, require.ensure now also returns a Promise
2039- // so the resolve/reject functions may get called an extra time
2040- // if the user uses an arrow function shorthand that happens to
2041- // return that Promise.
2042- function once ( fn ) {
2043- var called = false ;
2044- return function ( ) {
2045- var args = [ ] , len = arguments . length ;
2046- while ( len -- ) args [ len ] = arguments [ len ] ;
2047-
2048- if ( called ) { return }
2049- called = true ;
2050- return fn . apply ( this , args )
2051- }
2052- }
2053-
2054- function isError ( err ) {
2055- return Object . prototype . toString . call ( err ) . indexOf ( 'Error' ) > - 1
2056- }
2057-
20582063/* */
20592064
20602065
@@ -2493,7 +2498,7 @@ function createHref (base, fullPath, mode) {
24932498}
24942499
24952500VueRouter . install = install ;
2496- VueRouter . version = '2.6 .0' ;
2501+ VueRouter . version = '2.7 .0' ;
24972502
24982503if ( inBrowser && window . Vue ) {
24992504 window . Vue . use ( VueRouter ) ;
0 commit comments