File tree Expand file tree Collapse file tree 3 files changed +18
-3
lines changed Expand file tree Collapse file tree 3 files changed +18
-3
lines changed Original file line number Diff line number Diff line change
1
+ ## HEAD
2
+
3
+ - Fix the back button on Chrome iOS
4
+
1
5
## [ v4.4.0]
2
6
> Nov 1, 2016
3
7
Original file line number Diff line number Diff line change @@ -43,3 +43,12 @@ export const supportsPopStateOnHashChange = () =>
43
43
*/
44
44
export const supportsGoWithoutReloadUsingHash = ( ) =>
45
45
window . navigator . userAgent . indexOf ( 'Firefox' ) === - 1
46
+
47
+ /**
48
+ * Returns true if a given popstate event is an extraneous WebKit event.
49
+ * Accounts for the fact that Chrome on iOS fires real popstate events
50
+ * containing undefined state when pressing the back button.
51
+ */
52
+ export const isExtraneousPopstateEvent = event =>
53
+ event . state === undefined &&
54
+ navigator . userAgent . indexOf ( 'CriOS' ) === - 1
Original file line number Diff line number Diff line change 9
9
removeEventListener ,
10
10
getConfirmation ,
11
11
supportsHistory ,
12
- supportsPopStateOnHashChange
12
+ supportsPopStateOnHashChange ,
13
+ isExtraneousPopstateEvent
13
14
} from './DOMUtils'
14
15
15
16
const PopStateEvent = 'popstate'
@@ -79,8 +80,9 @@ const createBrowserHistory = (props = {}) => {
79
80
}
80
81
81
82
const handlePopState = ( event ) => {
82
- if ( event . state === undefined )
83
- return // Ignore extraneous popstate events in WebKit.
83
+ // Ignore extraneous popstate events in WebKit.
84
+ if ( isExtraneousPopstateEvent ( event ) )
85
+ return
84
86
85
87
handlePop ( getDOMLocation ( event . state ) )
86
88
}
You can’t perform that action at this time.
0 commit comments