|
23 | 23 | var array = [];
|
24 | 24 | var slice = array.slice;
|
25 | 25 |
|
| 26 | + // Is it a simple selector, from jQuery |
| 27 | + var isSimple = /^.[^:#\[\.,]*$/ |
| 28 | + |
26 | 29 | var supportHistory = "pushState" in history &&
|
27 | 30 | "replaceState" in history &&
|
28 | 31 | // When running inside a FF iframe, calling replaceState causes an error
|
|
38 | 41 | *
|
39 | 42 | * @type string
|
40 | 43 | **/
|
41 |
| - Mobilebone.VERSION = '1.1.4'; |
| 44 | + Mobilebone.VERSION = '1.1.5'; |
42 | 45 |
|
43 | 46 | /**
|
44 | 47 | * Whether bind events when dom ready
|
|
689 | 692 | var hash = location.hash.replace("#&", "#"), ele_in = null;
|
690 | 693 | if (hash == "" || hash == "#") {
|
691 | 694 | this.transition(document.querySelector("." + this.classPage));
|
692 |
| - } else if (/&/.test(hash) == false && (ele_in = document.querySelector(hash)) && ele_in.classList.contains(this.classPage)) { // 'ele_in' must be a page element |
| 695 | + } else if (isSimple.test(hash) == true && (ele_in = document.querySelector(hash)) && ele_in.classList.contains(this.classPage)) { // 'ele_in' must be a page element |
693 | 696 | this.transition(ele_in);
|
694 | 697 | } else {
|
695 | 698 | // as a ajax
|
|
845 | 848 | var hash = location.hash.replace("#&", "").replace("#", "");
|
846 | 849 | if (hash == "") return;
|
847 | 850 |
|
848 |
| - var page_in = store[hash] || document.querySelector(location.hash), page_out = document.querySelector(".in." + Mobilebone.classPage); |
| 851 | + var page_in = store[hash] || null, page_out = document.querySelector(".in." + Mobilebone.classPage); |
849 | 852 |
|
| 853 | + if (page_in == null && isSimple.test("#" + hash)) page_in = document.querySelector("#" + hash); |
850 | 854 | if (page_in && page_in == page_out) return;
|
851 |
| - |
852 | 855 |
|
853 | 856 | // hash ↔ id
|
854 | 857 | if (store[hash] && Mobilebone.pushStateEnabled) {
|
855 |
| - Mobilebone.transition(store[hash], document.querySelector(".in." + Mobilebone.classPage), Mobilebone.isBack(page_in, page_out), { |
| 858 | + Mobilebone.transition(page_in, document.querySelector(".in." + Mobilebone.classPage), Mobilebone.isBack(page_in, page_out), { |
856 | 859 | history: false
|
857 | 860 | });
|
858 | 861 | }
|
|
0 commit comments