Skip to content

Commit

Permalink
Only add/remove from group if layer exists
Browse files Browse the repository at this point in the history
In other words, fail silently if the layer doesn't exist.
  • Loading branch information
caleb531 committed Apr 26, 2024
1 parent c41b173 commit b401254
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/jcanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,7 @@ $.fn.addLayerToGroup = function addLayerToGroup(layerId, groupName) {
layer = $canvas.getLayer(layerId);

// If layer is not already in group
if (layer.groups) {
if (layer && layer.groups) {
// Clone groups list
groups = layer.groups.slice(0);
// If layer is not already in group
Expand Down Expand Up @@ -1138,7 +1138,7 @@ $.fn.removeLayerFromGroup = function removeLayerFromGroup(layerId, groupName) {
$canvas = $($canvases[e]);
layer = $canvas.getLayer(layerId);

if (layer.groups) {
if (layer && layer.groups) {

// Find index of layer in group
index = inArray(groupName, layer.groups);
Expand Down

0 comments on commit b401254

Please sign in to comment.