Skip to content

Commit

Permalink
fix(fabric.Object) ISSUE-6340 infinite recursion on groups (#6416)
Browse files Browse the repository at this point in the history
  • Loading branch information
asturur authored Jun 27, 2020
1 parent 9323748 commit 8a93189
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/mixins/stateful.mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
props.forEach(function(prop) {
tmpObj[prop] = origin[prop];
});

extend(origin[destination], tmpObj, deep);
}

Expand Down Expand Up @@ -42,7 +43,8 @@
key = keys[i];
// since clipPath is in the statefull cache list and the clipPath objects
// would be iterated as an object, this would lead to possible infinite recursion
if (key === 'canvas') {
// we do not want to compare those.
if (key === 'canvas' || key === 'group') {
continue;
}
if (!_isEqual(origValue[key], currentValue[key])) {
Expand Down
8 changes: 5 additions & 3 deletions src/util/lang_object.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* this does not and cannot compete with generic utils.
* Does not clone or extend fabric.Object subclasses.
* This is mostly for internal use and has extra handling for fabricJS objects
* it skips the canvas property in deep cloning.
* it skips the canvas and group properties in deep cloning.
* @memberOf fabric.util.object
* @param {Object} destination Where to copy to
* @param {Object} source Where to copy from
Expand All @@ -28,8 +28,10 @@
}
else if (source && typeof source === 'object') {
for (var property in source) {
if (property === 'canvas') {
destination[property] = extend({ }, source[property]);
if (property === 'canvas' || property === 'group') {
// we do not want to clone this props at all.
// we want to keep the keys in the copy
destination[property] = null;
}
else if (source.hasOwnProperty(property)) {
destination[property] = extend({ }, source[property], deep);
Expand Down

0 comments on commit 8a93189

Please sign in to comment.