Skip to content

Commit

Permalink
Merge pull request #1 from elbunuelo/CREATE-478-type-error-cannot-rea…
Browse files Browse the repository at this point in the history
…d-properties-null-reading-save

Implement Fabric PR fabricjs#7885
  • Loading branch information
k1w1 authored Dec 27, 2022
2 parents fc920f3 + 2da6618 commit b1a04a9
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 23 deletions.
30 changes: 19 additions & 11 deletions dist/fabric.js
Original file line number Diff line number Diff line change
Expand Up @@ -11716,6 +11716,10 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @lends fab
},

renderTopLayer: function(ctx) {
if (!ctx) {
return;
}

ctx.save();
if (this.isDrawingMode && this._isCurrentlyDrawing) {
this.freeDrawingBrush && this.freeDrawingBrush._render();
Expand Down Expand Up @@ -12484,21 +12488,24 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @lends fab
* @chainable
*/
dispose: function () {
var wrapper = this.wrapperEl;
var wrapperEl = this.wrapperEl,
lowerCanvasEl = this.lowerCanvasEl,
upperCanvasEl = this.upperCanvasEl,
cacheCanvasEl = this.cacheCanvasEl;
this.removeListeners();
wrapper.removeChild(this.upperCanvasEl);
wrapper.removeChild(this.lowerCanvasEl);
this.callSuper('dispose');
wrapperEl.removeChild(upperCanvasEl);
wrapperEl.removeChild(lowerCanvasEl);
this.contextCache = null;
this.contextTop = null;
['upperCanvasEl', 'cacheCanvasEl'].forEach((function(element) {
fabric.util.cleanUpJsdomNode(this[element]);
this[element] = undefined;
}).bind(this));
if (wrapper.parentNode) {
wrapper.parentNode.replaceChild(this.lowerCanvasEl, this.wrapperEl);
fabric.util.cleanUpJsdomNode(upperCanvasEl);
this.upperCanvasEl = undefined;
fabric.util.cleanUpJsdomNode(cacheCanvasEl);
this.cacheCanvasEl = undefined;
if (wrapperEl.parentNode) {
wrapperEl.parentNode.replaceChild(lowerCanvasEl, wrapperEl);
}
delete this.wrapperEl;
fabric.StaticCanvas.prototype.dispose.call(this);
return this;
},

Expand Down Expand Up @@ -13750,6 +13757,7 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @lends fab
selectionX2Y2 = new fabric.Point(max(x1, x2), max(y1, y2)),
allowIntersect,
isClick = x1 === x2 && y1 === y2;

// we iterate reverse order to collect top first in case of click.
for (var i = this._objects.length; i--; ) {
currentObject = this._objects[i];
Expand Down Expand Up @@ -20495,7 +20503,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
newGroup.set(options);
var firstIndex = null
objects.forEach(function(object) {
// We record the *lowest* index of object in the group. We can't use
// We record the *lowest* index of object in the group. We can't use
// the highest index because in the case of dependent objects, removing
// one from the collection might also trigger removal of others
// changing all of the higher indexes.
Expand Down
2 changes: 1 addition & 1 deletion dist/fabric.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@aha-app/fabric",
"description": "Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.",
"homepage": "http://fabricjs.com/",
"version": "4.6.0-aha-3",
"version": "4.6.0-aha-4",
"author": "Juriy Zaytsev <kangax@gmail.com>",
"contributors": [
{
Expand Down
27 changes: 17 additions & 10 deletions src/canvas.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,10 @@
},

renderTopLayer: function(ctx) {
if (!ctx) {
return;
}

ctx.save();
if (this.isDrawingMode && this._isCurrentlyDrawing) {
this.freeDrawingBrush && this.freeDrawingBrush._render();
Expand Down Expand Up @@ -1199,21 +1203,24 @@
* @chainable
*/
dispose: function () {
var wrapper = this.wrapperEl;
var wrapperEl = this.wrapperEl,
lowerCanvasEl = this.lowerCanvasEl,
upperCanvasEl = this.upperCanvasEl,
cacheCanvasEl = this.cacheCanvasEl;
this.removeListeners();
wrapper.removeChild(this.upperCanvasEl);
wrapper.removeChild(this.lowerCanvasEl);
this.callSuper('dispose');
wrapperEl.removeChild(upperCanvasEl);
wrapperEl.removeChild(lowerCanvasEl);
this.contextCache = null;
this.contextTop = null;
['upperCanvasEl', 'cacheCanvasEl'].forEach((function(element) {
fabric.util.cleanUpJsdomNode(this[element]);
this[element] = undefined;
}).bind(this));
if (wrapper.parentNode) {
wrapper.parentNode.replaceChild(this.lowerCanvasEl, this.wrapperEl);
fabric.util.cleanUpJsdomNode(upperCanvasEl);
this.upperCanvasEl = undefined;
fabric.util.cleanUpJsdomNode(cacheCanvasEl);
this.cacheCanvasEl = undefined;
if (wrapperEl.parentNode) {
wrapperEl.parentNode.replaceChild(lowerCanvasEl, wrapperEl);
}
delete this.wrapperEl;
fabric.StaticCanvas.prototype.dispose.call(this);
return this;
},

Expand Down

0 comments on commit b1a04a9

Please sign in to comment.