From 2a9e135fb09497208baf603b52f7a4f94e6f978e Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Sat, 1 Oct 2016 13:21:18 +0200 Subject: [PATCH 1/5] Update clear methd --- src/static_canvas.class.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/static_canvas.class.js b/src/static_canvas.class.js index b87cd9fbc54..1e515b544c3 100644 --- a/src/static_canvas.class.js +++ b/src/static_canvas.class.js @@ -807,6 +807,10 @@ */ clear: function () { this._objects.length = 0; + this.backgroundImage = null; + this.overlayImage = null; + this.backgroundColor = ''; + this.overlayColor = '' this.clearContext(this.contextContainer); this.fire('canvas:cleared'); this.renderAll(); From 915c08d6f3602d91e89e7949444707d350b010d3 Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Sat, 1 Oct 2016 13:37:00 +0200 Subject: [PATCH 2/5] Update canvas_static.js --- test/unit/canvas_static.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/test/unit/canvas_static.js b/test/unit/canvas_static.js index 4d16a445bd7..6081903694a 100644 --- a/test/unit/canvas_static.js +++ b/test/unit/canvas_static.js @@ -434,9 +434,18 @@ test('clear', function() { ok(typeof canvas.clear == 'function'); - + var bg = new fabric.Rect({ width: 10, height: 20 }), + canvas.backgroundColor = '#FF0000'; + canvas.overlayColor = '#FF0000'; + canvas.backgroundImage = bg; + canvas.overlayImage = bg; equal(canvas.clear(), canvas, 'should be chainable'); - equal(canvas.getObjects().length, 0); + equal(canvas.getObjects().length, 0, 'clear remove all objects'); + equal(canvas.backgroundColor, '', 'clear remove background color'); + equal(canvas.overlaydColor, '', 'clear remove overlay color'); + equal(canvas.backgroundImage, null, 'clear remove bg image'); + equal(canvas.overlayImage, null, 'clear remove overlay image'); + }); test('renderAll', function() { From 7dd2ae44d4d18f39b2dd33161872a73a677bf38c Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Sat, 1 Oct 2016 13:49:01 +0200 Subject: [PATCH 3/5] Update canvas_static.js --- test/unit/canvas_static.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/canvas_static.js b/test/unit/canvas_static.js index 6081903694a..edec93a6d49 100644 --- a/test/unit/canvas_static.js +++ b/test/unit/canvas_static.js @@ -434,7 +434,7 @@ test('clear', function() { ok(typeof canvas.clear == 'function'); - var bg = new fabric.Rect({ width: 10, height: 20 }), + var bg = new fabric.Rect({ width: 10, height: 20 }); canvas.backgroundColor = '#FF0000'; canvas.overlayColor = '#FF0000'; canvas.backgroundImage = bg; From 61123bc49f7958983aa4130c9e7b123ab171e207 Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Sat, 1 Oct 2016 14:07:51 +0200 Subject: [PATCH 4/5] Update canvas_static.js --- test/unit/canvas_static.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/canvas_static.js b/test/unit/canvas_static.js index edec93a6d49..8e53cfe7d20 100644 --- a/test/unit/canvas_static.js +++ b/test/unit/canvas_static.js @@ -442,7 +442,7 @@ equal(canvas.clear(), canvas, 'should be chainable'); equal(canvas.getObjects().length, 0, 'clear remove all objects'); equal(canvas.backgroundColor, '', 'clear remove background color'); - equal(canvas.overlaydColor, '', 'clear remove overlay color'); + equal(canvas.overlayColor, '', 'clear remove overlay color'); equal(canvas.backgroundImage, null, 'clear remove bg image'); equal(canvas.overlayImage, null, 'clear remove overlay image'); From 76218d03373c9a547f374bba0a4d96e58becd754 Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Sat, 1 Oct 2016 14:16:43 +0200 Subject: [PATCH 5/5] Update canvas_static.js --- test/unit/canvas_static.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/unit/canvas_static.js b/test/unit/canvas_static.js index 8e53cfe7d20..a7cf82ac031 100644 --- a/test/unit/canvas_static.js +++ b/test/unit/canvas_static.js @@ -445,7 +445,6 @@ equal(canvas.overlayColor, '', 'clear remove overlay color'); equal(canvas.backgroundImage, null, 'clear remove bg image'); equal(canvas.overlayImage, null, 'clear remove overlay image'); - }); test('renderAll', function() {