Skip to content

Commit c967664

Browse files
committed
small fix merlin destroy and cleanup in push state
1 parent c28e57f commit c967664

File tree

2 files changed

+3
-15
lines changed

2 files changed

+3
-15
lines changed

lib/Merlin2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ define(['jquery', 'NIseed'], function($) {
290290
},
291291
destroy: function() {
292292
$.each(internal.controls, function(k, control) {
293-
if (handlers[k]) {
293+
if (control && handlers[k]) {
294294
if (typeof control === 'string') {
295295
control = $(control);
296296
}

lib/PushstateHelper.js

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -87,34 +87,22 @@ define(['jquery'], function($) {
8787
handlers = {
8888
doc_click: function(e, d) {
8989
var $t, _href, _data;
90+
e.preventDefault();
9091
$t = $(this);
9192
_href = $t.attr('HREF');
92-
if(!_href){
93-
return;
94-
}
9593
_data = $t.data();
9694
if($t.hasClass('js-use-pushstate')){
97-
if(e.ctrlKey){
98-
return;
99-
}
100-
e.preventDefault();
101-
e.stopPropagation();
10295
e.stopImmediatePropagation();
10396
if(o.use_hash){
10497
window.location.hash = _href;
105-
fn.statechange(_href, _data);
10698
} else {
10799
history.pushState(null, null, _href);
108-
fn.statechange(_href, _data);
109100
}
101+
fn.statechange(_href, _data);
110102
} else if($t.hasClass('js-simulate-pushstate')) {
111-
e.preventDefault();
112-
e.stopPropagation();
113103
e.stopImmediatePropagation();
114104
fn.statechange(_href, _data);
115105
} else if($t.hasClass('js-do-popstate')) {
116-
e.preventDefault();
117-
e.stopPropagation();
118106
e.stopImmediatePropagation();
119107
history.back();
120108
}

0 commit comments

Comments
 (0)