Skip to content

Commit 0ae4b2c

Browse files
committed
Merge pull request #76 from zhangxinxu/develop
avoid Uncaught SyntaxError of 'querySelector'
2 parents 64886a7 + 7cd36cd commit 0ae4b2c

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mobilebone",
3-
"version": "2.3.2",
3+
"version": "2.3.3",
44
"description": "Bone main for mobile web APP with a sigle page mode.",
55
"main": "src/mobilebone.js",
66
"directories": {

src/mobilebone.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
*
3939
* @type string
4040
**/
41-
Mobilebone.VERSION = '2.3.2';
41+
Mobilebone.VERSION = '2.3.3';
4242

4343
/**
4444
* Whether catch attribute of href from element with tag 'a'
@@ -1029,13 +1029,14 @@
10291029
* page change when history change
10301030
**/
10311031
window.addEventListener("popstate", function() {
1032-
console.log(history.popstate);
1032+
10331033
if (history.popstate == false) {
10341034
history.popstate = true;
10351035
return;
10361036
}
10371037

1038-
var hash = location.hash.replace("#&", "").replace("#", ""), page_in = null;
1038+
var hash = location.hash.replace("#&", "").replace(/^#/, ""), page_in = null;
1039+
10391040
if (hash == "") {
10401041
// if no hash, get first page as 'page_in'
10411042
page_in = document.querySelector("." + Mobilebone.classPage);
@@ -1045,7 +1046,7 @@
10451046
}
10461047

10471048
if (!page_in) {
1048-
if(isSimple.test(hash) == false) {
1049+
if(isSimple.test(hash) == false || (/&/.test(hash) == true)) {
10491050
// as a url
10501051
Mobilebone.ajax({
10511052
url: hash,

test/ajax-html/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
<div id="pageHome" class="page out">
1414
<ul>
1515
<li><a href="ajax-page.html" data-container="container">点击加载(缓存,若后2项已请求,则无请求)</a></li>
16-
<li><a href="ajax-page.html" data-reload>点击加载(每次都请求, 返回含page结构)</a></li>
16+
<li><a href="ajax-page.html#a=1#b=1&c=1#" data-reload>点击加载(每次都请求, 返回含page结构)</a></li>
1717
<li><a href="ajax-page.html?&&" data-formdata="?a=1">点击加载(缓存, url过滤测试)</a></li>
1818
<li><a href="ajax-page.html?a" data-reload data-formdata="?a=1">点击加载(data-formdata测试)-全覆盖loading</a></li>
19-
<li><a href="ajax-page.html?a=1&" data-reload data-formdata="&c=1" data-mask="true">点击加载(data-formdata测试)-内覆盖loading</a></li>
19+
<li><a href="ajax-page.html?a=1&#tt_fo#nt=m&tt_#daymode=1" data-reload data-formdata="&c=1" data-mask="true">点击加载(data-formdata测试)-内覆盖loading</a></li>
2020
<li><a href="ajax-page.html?a=1&b=" class="follow" data-reload data-formdata="c=1&d=1" data-mask="true">点击加载(data-formdata测试)-跟随loading</a></li>
2121
</ul>
2222
<ul>

0 commit comments

Comments
 (0)