Skip to content
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

We should skip the same URL #317

Merged
merged 5 commits into from May 3, 2019
Merged

We should skip the same URL #317

merged 5 commits into from May 3, 2019

Conversation

xiaohulu
Copy link
Contributor

@xiaohulu xiaohulu commented Apr 10, 2019

Type: bug

The following has been addressed in the PR:

Description:

I use Link widget to navigate, but If I click the same Link n times, I must click Back button n times to back to previous route. We should skip the same url.

@agubler
Copy link
Member

agubler commented Apr 10, 2019

@xiaohulu Thank you, do you mind adding a unit test for the change?

@agubler agubler added area: routing Routing bug Something isn't working labels Apr 10, 2019
@codecov
Copy link

codecov bot commented Apr 10, 2019

Codecov Report

Merging #317 into master will decrease coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #317      +/-   ##
==========================================
- Coverage    97.2%   97.18%   -0.02%     
==========================================
  Files          99       99              
  Lines        5365     5367       +2     
  Branches     1202     1203       +1     
==========================================
+ Hits         5215     5216       +1     
- Misses        150      151       +1
Impacted Files Coverage Δ
src/routing/history/StateHistory.ts 97.87% <100%> (-2.13%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 860910a...afb696f. Read the comment docs.

@codecov
Copy link

codecov bot commented Apr 10, 2019

Codecov Report

Merging #317 into master will increase coverage by 0.05%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #317      +/-   ##
==========================================
+ Coverage    97.2%   97.25%   +0.05%     
==========================================
  Files          99      100       +1     
  Lines        5365     5397      +32     
  Branches     1202     1213      +11     
==========================================
+ Hits         5215     5249      +34     
+ Misses        150      148       -2
Impacted Files Coverage Δ
src/routing/history/StateHistory.ts 100% <100%> (ø) ⬆️
src/shim/fetch.ts 0% <0%> (ø) ⬆️
src/shim/IntersectionObserver.ts 100% <0%> (ø) ⬆️
src/shim/WebAnimations.ts 100% <0%> (ø) ⬆️
src/shim/util/wrapper.ts 100% <0%> (ø)
src/has/has.ts 95.9% <0%> (+0.02%) ⬆️
src/widget-core/vdom.ts 98.65% <0%> (+0.04%) ⬆️
src/shim/ResizeObserver.ts 100% <0%> (+12.5%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 860910a...c3430d4. Read the comment docs.

@xiaohulu
Copy link
Contributor Author

xiaohulu commented Apr 10, 2019

I do not know how to run StateHistory unit test. 😢

I write the unit test code here, I do not know if it can pass.

it('update path, skip the same path', () => {
	const history = new StateHistory({ onChange, window: sandbox.contentWindow! });
	history.set('foo');
	history.set('bar');
	history.set('bar');
	sandbox.contentWindow!.history.back();
	assert.equal(history.current, '/foo');
	assert.equal(sandbox.contentWindow!.location.pathname, '/foo');
});

@agubler
Copy link
Member

agubler commented Apr 10, 2019

@xiaohulu Hmmm that's interesting, I seem to be able to run the tests (on mac, node: v8.9.1 and npm: 6.4.1).

Have you tried, removing and reinstalling node_modules (and removing the package-lock too)?

@@ -53,6 +53,9 @@ export class StateHistory implements HistoryInterface {
}

public set(path: string) {
if (path === this._window.location.pathname) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xiaohulu Do you think we should move the logic from _onChange that does a check against the current and previous value to set function?

const pathName = this._window.location.pathname.replace(/\/$/, '');
const value = stripBase(this._base, pathName + this._window.location.search);
if (this._current === value) {
	return;
}

@xiaohulu
Copy link
Contributor Author

@agubler What is the base in the framework, and what is its purpose, and why this._current is assign to stripBase result

@agubler
Copy link
Member

agubler commented May 3, 2019

@xiaohulu Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: routing Routing bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants