]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
refactor: rename createHistory and createHashHistory
authorEduardo San Martin Morote <posva13@gmail.com>
Wed, 26 Feb 2020 10:13:11 +0000 (11:13 +0100)
committerEduardo San Martin Morote <posva13@gmail.com>
Wed, 26 Feb 2020 10:13:11 +0000 (11:13 +0100)
BREAKING CHANGE: `createHistory` is now named `createWebHistory`.
`createHashHistory` is now named `createWebHashHistory`.

  Both createHistory and createHashHistory are renamed to
  better reflect that they must be used in a browser environment while
  createMemoryHistory doesn't.

13 files changed:
__tests__/guards/component-beforeRouteEnter.spec.ts
__tests__/guards/component-beforeRouteLeave.spec.ts
__tests__/guards/component-beforeRouteUpdate.spec.ts
__tests__/guards/global-after.spec.ts
__tests__/guards/global-beforeEach.spec.ts
__tests__/guards/route-beforeEnter.spec.ts
__tests__/history/html5.spec.ts
__tests__/router.spec.ts
__tests__/url-encoding.spec.ts
playground/router.ts
src/history/hash.ts
src/history/html5.ts
src/index.ts

index 616ce99eaa2c06939cb4003567dba1ad0a00f89c..cf129633ca79222789cd85a0a5b137833796bb09 100644 (file)
@@ -2,13 +2,13 @@ import { RouterOptions, createRouter as newRouter } from '../../src/router'
 import fakePromise from 'faked-promise'
 import { NAVIGATION_TYPES, createDom, noGuard } from '../utils'
 import { RouteRecord, NavigationGuard } from '../../src/types'
-import { createHistory } from '../../src'
+import { createWebHistory } from '../../src'
 
 function createRouter(
   options: Partial<RouterOptions> & { routes: RouteRecord[] }
 ) {
   return newRouter({
-    history: createHistory(),
+    history: createWebHistory(),
     ...options,
   })
 }
index 4777418df389f7f44c7a48461b2e4e590c50a230..c008f7e45519be72d6da316e71a6c26abc4d458b 100644 (file)
@@ -1,14 +1,14 @@
 import { RouterOptions, createRouter as newRouter } from '../../src/router'
 import { NAVIGATION_TYPES, createDom, noGuard } from '../utils'
 import { RouteRecord } from '../../src/types'
-import { createHistory } from '../../src'
+import { createWebHistory } from '../../src'
 
 // TODO: refactor in utils
 function createRouter(
   options: Partial<RouterOptions> & { routes: RouteRecord[] }
 ) {
   return newRouter({
-    history: createHistory(),
+    history: createWebHistory(),
     ...options,
   })
 }
index a6c89a00b4ec1c762b27ad63b9efe78d1927facd..6ffc1ba9c93836aa664479e77c9a1f976e13edec 100644 (file)
@@ -1,6 +1,6 @@
 import fakePromise from 'faked-promise'
 import { NAVIGATION_TYPES, createDom, noGuard } from '../utils'
-import { createRouter as newRouter, createHistory } from '../../src'
+import { createRouter as newRouter, createWebHistory } from '../../src'
 import { RouteRecord } from '../../src/types'
 
 function createRouter(
@@ -9,7 +9,7 @@ function createRouter(
   }
 ) {
   return newRouter({
-    history: createHistory(),
+    history: createWebHistory(),
     ...options,
   })
 }
index e98dde1d9e13bdc66d316ae4279b905fcd347199..3b6a2039487b694ea39b51f006805e5ddf316eab 100644 (file)
@@ -1,5 +1,5 @@
 import { NAVIGATION_TYPES, createDom } from '../utils'
-import { createHistory, createRouter as newRouter } from '../../src'
+import { createWebHistory, createRouter as newRouter } from '../../src'
 
 function createRouter(
   options: Partial<import('../../src/router').RouterOptions> & {
@@ -7,7 +7,7 @@ function createRouter(
   }
 ) {
   return newRouter({
-    history: createHistory(),
+    history: createWebHistory(),
     ...options,
   })
 }
index f5d8e5aefb7650651de099a64c6b3c5280b63171..58df9ed39d54305e59fece26456aacef4b55f222 100644 (file)
@@ -2,13 +2,13 @@ import { RouterOptions } from '../../src/router'
 import fakePromise from 'faked-promise'
 import { NAVIGATION_TYPES, createDom, tick, noGuard } from '../utils'
 import { RouteRecord, RouteLocation } from '../../src/types'
-import { createHistory, createRouter as newRouter } from '../../src'
+import { createWebHistory, createRouter as newRouter } from '../../src'
 
 function createRouter(
   options: Partial<RouterOptions> & { routes: RouteRecord[] }
 ) {
   return newRouter({
-    history: createHistory(),
+    history: createWebHistory(),
     ...options,
   })
 }
index 6849daa1d9ac0adea56ce4f3a1c2f52fed4a4efb..58ed89185ef35f3211815c38ff43dbc53443ffdf 100644 (file)
@@ -2,13 +2,13 @@ import { RouterOptions, createRouter as newRouter } from '../../src/router'
 import fakePromise from 'faked-promise'
 import { NAVIGATION_TYPES, createDom, noGuard, tick } from '../utils'
 import { RouteRecord } from '../../src/types'
-import { createHistory } from '../../src'
+import { createWebHistory } from '../../src'
 
 function createRouter(
   options: Partial<RouterOptions> & { routes: RouteRecord[] }
 ) {
   return newRouter({
-    history: createHistory(),
+    history: createWebHistory(),
     ...options,
   })
 }
index 7e1e1ca36468d65a4d2490b488affa1e223d9a46..641b99b0243bd4e20533abd553a67768e76f359c 100644 (file)
@@ -1,4 +1,4 @@
-import createHistory from '../../src/history/html5'
+import createWebHistory from '../../src/history/html5'
 import { createDom } from '../utils'
 
 // TODO: is it really worth testing this implementation on jest or is it
@@ -9,7 +9,7 @@ describe.skip('History HTMl5', () => {
   })
 
   it('can be instantiated', () => {
-    const history = createHistory()
+    const history = createWebHistory()
     expect(history.location).toEqual({
       fullPath: '/',
       path: '/',
index c8a896c48b5ad5be096befca82a02e4bf8ea7438..77f1d010afc6b5f8ed48ae4401b7257c29c73fb1 100644 (file)
@@ -1,5 +1,5 @@
 import fakePromise from 'faked-promise'
-import { createRouter, createMemoryHistory, createHistory } from '../src'
+import { createRouter, createMemoryHistory, createWebHistory } from '../src'
 import { NavigationCancelled } from '../src/errors'
 import { createDom, components, tick } from './utils'
 import {
@@ -310,7 +310,7 @@ describe('Router', () => {
   })
 
   it('allows base option with html5 history', async () => {
-    const history = createHistory('/app/')
+    const history = createWebHistory('/app/')
     const router = createRouter({ history, routes })
     expect(router.currentRoute.value).toEqual({
       name: undefined,
index d54c1c5d6b121a7afc37ca96ba21a5577ed4c3a1..c03f89ef27576dd110442e9247846f7c2a634f9e 100644 (file)
@@ -16,13 +16,13 @@ const routes: RouteRecord[] = [
 
 // this function is meant to easy refactor in the future as Histories are going to be
 // function-based
-function createHistory() {
+function createWebHistory() {
   const routerHistory = createMemoryHistory()
   return routerHistory
 }
 
 function createRouter() {
-  const history = createHistory()
+  const history = createWebHistory()
   const router = newRouter({ history, routes })
   return router
 }
index ef8be6dea2ae2ad2ab9b5de93539c166d3dd81f2..116a70e1c510750fe746deffef94ee6a1a173376 100644 (file)
@@ -1,4 +1,4 @@
-import { createRouter, createHistory } from '../src'
+import { createRouter, createWebHistory } from '../src'
 import Home from './views/Home.vue'
 import Nested from './views/Nested.vue'
 import User from './views/User.vue'
@@ -12,7 +12,7 @@ import { scrollWaiter } from './scrollWaiter'
 
 // const hist = new HTML5History()
 // const hist = new HashHistory()
-export const routerHistory = createHistory()
+export const routerHistory = createWebHistory()
 export const router = createRouter({
   history: routerHistory,
   routes: [
index 1c8ac40ab8d5e7fcfafff125b6b083a9e56331e2..08a6cae07403f21575d98b8839dfffaef7420cca 100644 (file)
@@ -1,7 +1,7 @@
 import { RouterHistory } from './common'
-import createHistory from './html5'
+import createWebHistory from './html5'
 
-export default function createHashHistory(base: string = ''): RouterHistory {
+export default function createWebHashHistory(base: string = ''): RouterHistory {
   // Make sure this implementation is fine in terms of encoding, specially for IE11
-  return createHistory('/#' + base)
+  return createWebHistory('/#' + base)
 }
index d80e8c12787b06df63702d68e9be83fe76b2f7d8..463005ee749f11704ce299712ab71631ca087640 100644 (file)
@@ -264,7 +264,7 @@ function useHistoryStateNavigation(base: string) {
   }
 }
 
-export default function createHistory(base: string = ''): RouterHistory {
+export default function createWebHistory(base: string = ''): RouterHistory {
   const historyNavigation = useHistoryStateNavigation(base)
   const historyListeners = useHistoryListeners(
     base,
index 719b341a2427a466cc834f957ca19c86025dc236..e5058595da93ef0e6e592e7a7a2d746612141e20 100644 (file)
@@ -1,6 +1,6 @@
-import createHistory from './history/html5'
+import createWebHistory from './history/html5'
 import createMemoryHistory from './history/memory'
-import createHashHistory from './history/hash'
+import createWebHashHistory from './history/hash'
 
 export {
   RouteLocationNormalized,
@@ -15,4 +15,4 @@ export { useRoute, useRouter } from './injectKeys'
 export { Link } from './components/Link'
 export { View } from './components/View'
 
-export { createHistory, createMemoryHistory, createHashHistory }
+export { createWebHistory, createMemoryHistory, createWebHashHistory }