Update router.js

This commit is contained in:
Sébastien Chopin 2018-03-01 15:59:56 +01:00 committed by Pooya Parsa
parent 5f55bf76bd
commit a89a0f7ca9

View File

@ -56,8 +56,6 @@ const scrollBehavior = function (to, from, savedPosition) {
if (to.hash) { if (to.hash) {
let hash = to.hash let hash = to.hash
// CSS.escape() is not supported with IE and Edge. // CSS.escape() is not supported with IE and Edge.
// But we can use the following polyfill to solve this problem.
// https://github.com/mathiasbynens/CSS.escape
if (typeof window.CSS !== 'undefined' && typeof window.CSS.escape !== 'undefined') { if (typeof window.CSS !== 'undefined' && typeof window.CSS.escape !== 'undefined') {
hash = '#' + window.CSS.escape(hash.substr(1)) hash = '#' + window.CSS.escape(hash.substr(1))
} }
@ -67,7 +65,7 @@ const scrollBehavior = function (to, from, savedPosition) {
position = { selector: hash } position = { selector: hash }
} }
} catch (e) { } catch (e) {
console.warn('failed to save the scroll position. possibly this problem can be solved using a polyfill for CSS.escape().') console.warn('Failed to save scroll position. Please add CSS.escape() polyfill (https://github.com/mathiasbynens/CSS.escape).')
} }
} }
resolve(position) resolve(position)