Skip to content

Commit 2b0f996

Browse files
author
David Morse
committed
fix(gridster): Add additiona error checking on widgets removal
…when remove_widget is called with an empty element we need to abandon the action early to avoid exceptions
1 parent 4936ef8 commit 2b0f996

6 files changed

+21
-7
lines changed

dist/jquery.gridster.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! gridster.js - v0.6.10 - 2015-06-08
1+
/*! gridster.js - v0.6.10 - 2015-06-25
22
* https://dsmorse.github.io/gridster.js/
33
* Copyright (c) 2015 ducksboard; Licensed MIT */
44

@@ -1946,6 +1946,10 @@
19461946
*/
19471947
fn.remove_widget = function (el, silent, callback) {
19481948
var $el = el instanceof $ ? el : $(el);
1949+
if ($el.length === 0) {
1950+
//there is nothing to remove, so we can't remove it
1951+
return this;
1952+
}
19491953
var wgd = $el.coords().grid;
19501954
if (wgd === undefined) {
19511955
//there is no grid, so we can't remove it

dist/jquery.gridster.min.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/jquery.gridster.min.js

+3-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/jquery.gridster.with-extras.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! gridster.js - v0.6.10 - 2015-06-08
1+
/*! gridster.js - v0.6.10 - 2015-06-25
22
* https://dsmorse.github.io/gridster.js/
33
* Copyright (c) 2015 ducksboard; Licensed MIT */
44

@@ -1946,6 +1946,10 @@
19461946
*/
19471947
fn.remove_widget = function (el, silent, callback) {
19481948
var $el = el instanceof $ ? el : $(el);
1949+
if ($el.length === 0) {
1950+
//there is nothing to remove, so we can't remove it
1951+
return this;
1952+
}
19491953
var wgd = $el.coords().grid;
19501954
if (wgd === undefined) {
19511955
//there is no grid, so we can't remove it

dist/jquery.gridster.with-extras.min.js

+3-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/jquery.gridster.js

+4
Original file line numberDiff line numberDiff line change
@@ -1048,6 +1048,10 @@
10481048
*/
10491049
fn.remove_widget = function (el, silent, callback) {
10501050
var $el = el instanceof $ ? el : $(el);
1051+
if ($el.length === 0) {
1052+
//there is nothing to remove, so we can't remove it
1053+
return this;
1054+
}
10511055
var wgd = $el.coords().grid;
10521056
if (wgd === undefined) {
10531057
//there is no grid, so we can't remove it

0 commit comments

Comments
 (0)