Skip to content

Commit 1284e1e

Browse files
author
zhangxinxu
committed
fixed selector error problem
fixed selector error problem, by using a more accurate regular expression
1 parent 20066dc commit 1284e1e

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

ReadMe.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
mobilebone.js
22
=============
3-
单页切换骨架。适用于移动web APP, Hybird混合APP, Phonegap开发, 无兼容要求单页PC应用等。官方网站:<a href="http://www.mobilebone.org">http://www.mobilebone.org</a>
3+
单页切换骨架。适用于移动web APP, Hybrid混合APP, Phonegap开发, 无兼容要求单页PC应用等。官方网站:<a href="http://www.mobilebone.org">http://www.mobilebone.org</a>
44

55
实例、测试和文档
66
------------------
@@ -23,7 +23,7 @@ mobilebone.js
2323
-------------
2424
类原生APP的过场体验,适用于这些场景:<br>
2525
1. Phonegap等类似跨移动开发平台,其静态页面都是index.html, 单页面,因此,需要跟原生一样的过场体验。<br>
26-
2. Hybird app开发,原生APP内嵌web APP, 为了两者体验一致,不至于交互太唐突,也需要无刷新过场效果。<br>
26+
2. Hybrid app开发,原生APP内嵌web APP, 为了两者体验一致,不至于交互太唐突,也需要无刷新过场效果。<br>
2727
3. 就算是纯粹的移动web APP, 使用无刷新模式也不失为一种不错的选型策略。<br>
2828
4. 对兼容性没有要求的单页PC应用,如类PowerPoint web文档,单页翻屏web站点等。
2929

@@ -77,7 +77,7 @@ MIT许可
7777

7878
mobilebone.js
7979
=============
80-
Single Page Switching bone for mobile web APP, Hybird APP, Phonegap, ...
80+
Single Page Switching bone for mobile web APP, Hybrid APP, Phonegap, ...
8181

8282
<pre>git clone git://github.com/zhangxinxu/mobilebone.git</pre>
8383

@@ -103,7 +103,7 @@ Why need this?
103103
-----------------
104104
Interaction experience is good enough to compare with the native APP. <br>
105105
1. Phonegap that to native APP is a single index.html, We need the same switch effects as native.<br>
106-
2. Hybird app, as you know, mixed web-app and native-app. So, it' better that they have some switching experience.<br>
106+
2. Hybrid app, as you know, mixed web-app and native-app. So, it' better that they have some switching experience.<br>
107107
3. Even no refresh interaction is not something bad for mobile APP.
108108

109109
How to use?

src/mobilebone.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
var array = [];
2828
var slice = array.slice;
2929

30-
// Is it a simple selector, from jQuery
31-
var isSimple = /^.[^:#\[\.,]*$/
30+
// Is it a id selector
31+
var isSimple = /^#?\w+(?:[\-_]\w+)*$/i;
3232

3333
// Is it suppory history API
3434
var supportHistory = "pushState" in history && "replaceState" in history;
@@ -42,7 +42,7 @@
4242
*
4343
* @type string
4444
**/
45-
Mobilebone.VERSION = '2.4.4';
45+
Mobilebone.VERSION = '2.4.5';
4646

4747
/**
4848
* Whether catch attribute of href from element with tag 'a'
@@ -393,7 +393,6 @@
393393
// reset to popable state
394394
history.popstate = true;
395395
}, 17);
396-
console.log(store);
397396
}
398397
};
399398

@@ -876,14 +875,17 @@
876875
Mobilebone.jsonHandle = function(json) {
877876
return '<p style="text-align:center;">Dear master, if you see me, show that JSON parsing function is undefined!</p>';
878877
},
879-
878+
880879
/**
881880
* Initialization. Load page according to location.hash. And bind link-catch events.
882881
**/
883882
Mobilebone.init = function() {
884883
if (hasInited == true) return 'Don\'t repeat initialization!';
885884

886885
var hash = location.hash.replace("#&", "#"), ele_in = null;
886+
887+
console.log(hash);
888+
887889
if (hash == "" || hash == "#") {
888890
this.transition(document.querySelector("." + this.classPage));
889891
} else if (isSimple.test(hash) == true && (ele_in = document.querySelector(hash)) && ele_in.classList.contains(this.classPage)) { // 'ele_in' must be a page element
@@ -1152,7 +1154,7 @@
11521154
}
11531155

11541156
if (!page_in) {
1155-
if(isSimple.test(hash) == false || (/&/.test(hash) == true)) {
1157+
if(isSimple.test(hash) == false) {
11561158
// as a url
11571159
Mobilebone.ajax({
11581160
url: hash,

0 commit comments

Comments
 (0)