@@ -745,22 +745,18 @@ module.exports = NavigationContext;
745745var invariant = _dereq_ ( 'react/lib/invariant' ) ;
746746var canUseDOM = _dereq_ ( 'react/lib/ExecutionEnvironment' ) . canUseDOM ;
747747var getWindowScrollPosition = _dereq_ ( '../utils/getWindowScrollPosition' ) ;
748- var Path = _dereq_ ( '../utils/Path' ) ;
749748
750749function shouldUpdateScroll ( state , prevState ) {
751- if ( ! prevState ) {
750+ if ( ! prevState )
752751 return true ;
753- }
754752
755- var path = state . path ;
753+ // Don't update scroll position when only the query has changed.
754+ if ( state . pathname === prevState . pathname )
755+ return false ;
756+
756757 var routes = state . routes ;
757- var prevPath = prevState . path ;
758758 var prevRoutes = prevState . routes ;
759759
760- if ( Path . withoutQuery ( path ) === Path . withoutQuery ( prevPath ) ) {
761- return false ;
762- }
763-
764760 var sharedAncestorRoutes = routes . filter ( function ( route ) {
765761 return prevRoutes . indexOf ( route ) !== - 1 ;
766762 } ) ;
@@ -814,9 +810,8 @@ var Scrolling = {
814810 } ,
815811
816812 _updateScroll : function ( prevState ) {
817- if ( ! shouldUpdateScroll ( this . state , prevState ) ) {
813+ if ( ! shouldUpdateScroll ( this . state , prevState ) )
818814 return ;
819- }
820815
821816 var scrollBehavior = this . getScrollBehavior ( ) ;
822817
@@ -831,7 +826,7 @@ var Scrolling = {
831826
832827module . exports = Scrolling ;
833828
834- } , { "../utils/Path" : 21 , "../utils/ getWindowScrollPosition" :28 , "react/lib/ExecutionEnvironment" :37 , "react/lib/invariant" :41 } ] , 18 :[ function ( _dereq_ , module , exports ) {
829+ } , { "../utils/getWindowScrollPosition" :28 , "react/lib/ExecutionEnvironment" :37 , "react/lib/invariant" :41 } ] , 18 :[ function ( _dereq_ , module , exports ) {
835830var React = ( typeof window !== "undefined" ? window . React : typeof global !== "undefined" ? global . React : null ) ;
836831
837832/**
@@ -857,6 +852,7 @@ var State = {
857852 contextTypes : {
858853 getCurrentPath : React . PropTypes . func . isRequired ,
859854 getCurrentRoutes : React . PropTypes . func . isRequired ,
855+ getCurrentPathname : React . PropTypes . func . isRequired ,
860856 getCurrentParams : React . PropTypes . func . isRequired ,
861857 getCurrentQuery : React . PropTypes . func . isRequired ,
862858 isActive : React . PropTypes . func . isRequired
@@ -876,6 +872,13 @@ var State = {
876872 return this . context . getCurrentRoutes ( ) ;
877873 } ,
878874
875+ /**
876+ * Returns the current URL path without the query string.
877+ */
878+ getPathname : function ( ) {
879+ return this . context . getCurrentPathname ( ) ;
880+ } ,
881+
879882 /**
880883 * Returns an object of the URL params that are currently active.
881884 */
@@ -948,6 +951,13 @@ var StateContext = {
948951 return this . state . routes . slice ( 0 ) ;
949952 } ,
950953
954+ /**
955+ * Returns the current URL path without the query string.
956+ */
957+ getCurrentPathname : function ( ) {
958+ return this . state . pathname ;
959+ } ,
960+
951961 /**
952962 * Returns a read-only object of the currently active URL parameters.
953963 */
@@ -977,6 +987,7 @@ var StateContext = {
977987 childContextTypes : {
978988 getCurrentPath : React . PropTypes . func . isRequired ,
979989 getCurrentRoutes : React . PropTypes . func . isRequired ,
990+ getCurrentPathname : React . PropTypes . func . isRequired ,
980991 getCurrentParams : React . PropTypes . func . isRequired ,
981992 getCurrentQuery : React . PropTypes . func . isRequired ,
982993 isActive : React . PropTypes . func . isRequired
@@ -986,6 +997,7 @@ var StateContext = {
986997 return {
987998 getCurrentPath : this . getCurrentPath ,
988999 getCurrentRoutes : this . getCurrentRoutes ,
1000+ getCurrentPathname : this . getCurrentPathname ,
9891001 getCurrentParams : this . getCurrentParams ,
9901002 getCurrentQuery : this . getCurrentQuery ,
9911003 isActive : this . isActive
@@ -1605,11 +1617,11 @@ function createRouter(options) {
16051617 } ,
16061618
16071619 /**
1608- * Performs a match of the given path against this router and returns an object with
1609- * the { path, routes, params, query } that match. Returns null if no match can be made.
1620+ * Performs a match of the given pathname against this router and returns an object
1621+ * with the { routes, params } that match. Returns null if no match can be made.
16101622 */
1611- match : function ( path ) {
1612- return findMatch ( Path . withoutQuery ( path ) , routes , this . defaultRoute , this . notFoundRoute ) || null ;
1623+ match : function ( pathname ) {
1624+ return findMatch ( pathname , routes , this . defaultRoute , this . notFoundRoute ) || null ;
16131625 } ,
16141626
16151627 /**
@@ -1630,19 +1642,21 @@ function createRouter(options) {
16301642 */
16311643 dispatch : function ( path , action , callback ) {
16321644 if ( pendingTransition ) {
1633- pendingTransition . abort ( new Cancellation ( ) ) ;
1645+ pendingTransition . abort ( new Cancellation ) ;
16341646 pendingTransition = null ;
16351647 }
16361648
16371649 var prevPath = state . path ;
16381650 if ( prevPath === path )
16391651 return ; // Nothing to do!
16401652
1641- if ( prevPath && action !== LocationActions . REPLACE ) {
1653+ // Record the scroll position as early as possible to
1654+ // get it before browsers try update it automatically.
1655+ if ( prevPath && action !== LocationActions . REPLACE )
16421656 this . recordScrollPosition ( prevPath ) ;
1643- }
16441657
1645- var match = this . match ( path ) ;
1658+ var pathname = Path . withoutQuery ( path ) ;
1659+ var match = this . match ( pathname ) ;
16461660
16471661 warning (
16481662 match != null ,
@@ -1687,6 +1701,7 @@ function createRouter(options) {
16871701
16881702 nextState . path = path ;
16891703 nextState . action = action ;
1704+ nextState . pathname = pathname ;
16901705 nextState . routes = nextRoutes ;
16911706 nextState . params = nextParams ;
16921707 nextState . query = nextQuery ;
@@ -2691,7 +2706,7 @@ var emptyFunction = _dereq_("./emptyFunction");
26912706var warning = emptyFunction ;
26922707
26932708if ( "production" !== "production" ) {
2694- warning = function ( condition , format ) { for ( var args = [ ] , $__0 = 2 , $__1 = arguments . length ; $__0 < $__1 ; $__0 ++ ) args . push ( arguments [ $__0 ] ) ;
2709+ warning = function ( condition , format ) { var args = Array . prototype . slice . call ( arguments , 2 ) ;
26952710 if ( format === undefined ) {
26962711 throw new Error (
26972712 '`warning(condition, format, ...args)` requires a warning ' +
0 commit comments