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

SDK: better support for SPA routing #467

Merged
merged 6 commits into from
Aug 4, 2020

Conversation

mquentin
Copy link
Contributor

Motivation

Given
startViewCollection
When
on window.location.hash changes
Then
check if the views are different.
If the hash fragment has changed and that it is not an Anchor nav, then the views are different.

Changes

PART 1

  • ✨ add a trackHash function
  • ✨ modify areDifferentViews to handle hash changes

PART 2

  • ✨ add a noAnchorNavHashChange check in the trackHash function that check if there is an equivalent id on one of the HTML elements

Testing

PART 1
✅ hash changes tests have been added both for pushStates and window.location.hash window.location.hash
Test with the Vue router without mode: 'history':

const router = new VueRouter({ routes })

PART 2
✅ test added that check if the hashchange is related to an Anchor nav

)

* add hash tracking

* ✅ add hash change tests

* introduce renewViewOnChange

* add better management and comments of the areViewDifferent hash part

* set async tests for hashchanges

* reset window.location.hash of previous tests

* skip tesst using Promise for IE

* replace jasmine promise with callback process

* remove anchor check on this PR

* ✅ and implem reviews
@mquentin mquentin requested a review from a team as a code owner July 28, 2020 12:41
…m:DataDog/browser-sdk into maxime.quentin/betterSupportForSPArouting
@codecov-commenter
Copy link

codecov-commenter commented Jul 28, 2020

Codecov Report

Merging #467 into master will increase coverage by 0.15%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #467      +/-   ##
==========================================
+ Coverage   87.60%   87.75%   +0.15%     
==========================================
  Files          32       32              
  Lines        2025     2034       +9     
  Branches      409      411       +2     
==========================================
+ Hits         1774     1785      +11     
+ Misses        251      249       -2     
Impacted Files Coverage Δ
packages/rum/src/viewCollection.ts 96.29% <100.00%> (+0.33%) ⬆️
packages/rum/src/performanceCollection.ts 67.21% <0.00%> (+1.63%) ⬆️
packages/rum/src/parentContexts.ts 100.00% <0.00%> (+1.78%) ⬆️

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 21a24c6...414eac1. Read the comment docs.

mquentin and others added 4 commits July 30, 2020 18:08
…or tags changes (#466)

* add hash tracking

* ✅ add hash change tests

* introduce renewViewOnChange

* add better management and comments of the areViewDifferent hash part

* set async tests for hashchanges

* reset window.location.hash of previous tests

* skip tesst using Promise for IE

* replace jasmine promise with callback process

* remove anchor check on this PR

* add anchor nav filter

* patch tslint error

* ✅ and implem reviews

* implement reviews regarding func naming and hash cleaning

* simplify mockGetElementById

* add e2e tests

* simply anchor filter out proccess

* implement reviews

* unit test the hash change acknowledgement after an anchor nav

* fix typo

* fix typo v2
@bcaudan bcaudan merged commit eaeced6 into master Aug 4, 2020
@bcaudan bcaudan deleted the maxime.quentin/betterSupportForSPArouting branch August 4, 2020 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants