Skip to content

Commit f61e5ac

Browse files
authored
Merge pull request #30 from gpetrioli/master
Fixes #29 - unwrapping wrong elements
2 parents a50950d + 86abe10 commit f61e5ac

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

dist/js/jquery.magnify.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,15 @@
233233
this.destroy = function() {
234234
this.each(function() {
235235
var $this = $(this),
236-
sStyle = $this.data('originalStyle');
236+
$magnifyParent = $this.parent('.magnify'),
237+
sStyle = $this.data('originalStyle');
237238
if (sStyle) $this.attr('style', sStyle);
238239
else $this.removeAttr('style');
239-
$this.unwrap('.magnify').prevAll('.magnify-lens').remove();
240+
241+
if($magnifyParent.length) {
242+
$magnifyParent.replaceWith($this);
243+
}
244+
$this.prevAll('.magnify-lens').remove();
240245
});
241246
// Unregister event handler
242247
$(window).off('resize', refresh);

0 commit comments

Comments
 (0)