-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Repair stencil-route-prompt (ask user for confirmation before navigation) #121
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,7 +49,10 @@ const createBrowserHistory = (win: Window, props: CreateBrowserHistoryOptions = | |
const scrollHistory = createScrollHistory(win); | ||
|
||
const forceRefresh = (props.forceRefresh != null) ? props.forceRefresh : false; | ||
const getUserConfirmation = (props.getUserConfirmation != null) ? props.getUserConfirmation : getConfirmation; | ||
const getUserConfirmation = | ||
props.getUserConfirmation != null | ||
? props.getUserConfirmation | ||
: getConfirmation.bind(undefined, win); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure |
||
const keyLength = (props.keyLength != null) ? props.keyLength : 6; | ||
const basename = props.basename ? stripTrailingSlash(addLeadingSlash(props.basename)) : ''; | ||
|
||
|
@@ -83,11 +86,9 @@ const createBrowserHistory = (win: Window, props: CreateBrowserHistoryOptions = | |
return createLocation(path, state, key || createKey(keyLength)); | ||
}; | ||
|
||
|
||
const transitionManager = createTransitionManager(); | ||
|
||
const setState = (nextState?: NextState) => { | ||
|
||
// Capture location for the view before changing history. | ||
scrollHistory.capture(history.location.key); | ||
|
||
|
@@ -103,7 +104,7 @@ const createBrowserHistory = (win: Window, props: CreateBrowserHistoryOptions = | |
); | ||
}; | ||
|
||
const handlePopState = (event: any) => { | ||
const handlePopState = (event: PopStateEvent) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Misc. clean up discovered while reading through code. Seemed like a specific type would be better. |
||
// Ignore extraneous popstate events in WebKit. | ||
if (!isExtraneousPopstateEvent(globalNavigator, event)) { | ||
handlePop(getDOMLocation(event.state)); | ||
|
@@ -114,7 +115,6 @@ const createBrowserHistory = (win: Window, props: CreateBrowserHistoryOptions = | |
handlePop(getDOMLocation(getHistoryState())); | ||
}; | ||
|
||
|
||
const handlePop = (location: LocationSegments) => { | ||
if (forceNextPop) { | ||
forceNextPop = false; | ||
|
@@ -263,7 +263,6 @@ const createBrowserHistory = (win: Window, props: CreateBrowserHistoryOptions = | |
const goBack = () => go(-1); | ||
const goForward = () => go(1); | ||
|
||
|
||
const checkDOMListeners = (delta: number) => { | ||
listenerCount += delta; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,7 +52,7 @@ const createHashHistory = (win: Window, props: CreateHashHistoryOptions = {}) => | |
const keyLength = (props.keyLength != null) ? props.keyLength : 6; | ||
|
||
const { | ||
getUserConfirmation = getConfirmation, | ||
getUserConfirmation = getConfirmation.bind(undefined, win), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure |
||
hashType = 'slash' | ||
} = props; | ||
const basename = props.basename ? stripTrailingSlash(addLeadingSlash(props.basename)) : ''; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tried to simplify the logic here a little while being more earnest about the parameter types.