浏览代码

Don't mutate window.location.hash when updating querystring

Matt Meshulam 8 年之前
父节点
当前提交
c20b505f0c
共有 1 个文件被更改,包括 2 次插入3 次删除
  1. 2 3
      examples/index.html

+ 2 - 3
examples/index.html

@@ -379,11 +379,10 @@
 
 			var v = filterInput.value;
 			if( v !== '' ) {
-				window.history.replaceState( {} , '', '?q=' + v );
+				window.history.replaceState( {} , '', '?q=' + v + window.location.hash );
 			} else {
-				window.history.replaceState( {} , '', window.location.pathname );
+				window.history.replaceState( {} , '', window.location.pathname + window.location.hash );
 			}
-			if( selected ) window.location.hash = selected;
 
 			var exp = new RegExp( v, 'gi' );