From bf5126b3847a02a9ea80febba22aefba88c97ee2 Mon Sep 17 00:00:00 2001 From: Zach Bjornson Date: Mon, 6 Jul 2020 18:57:07 -0700 Subject: [PATCH] bug: remove non-standard behavior > The style can be either a string containing a CSS color, or a CanvasGradient or CanvasPattern object. Invalid values are ignored --- CHANGELOG.md | 1 + src/CanvasRenderingContext2d.cc | 6 ------ test/canvas.test.js | 4 ---- 3 files changed, 1 insertion(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ab0bd3ad..10aac0d31 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ project adheres to [Semantic Versioning](http://semver.org/). * Fix compile errors with cairo * Fix Image#complete if the image failed to load. * Upgrade node-pre-gyp to v0.15.0 to use latest version of needle to fix error when downloading prebuilds. +* Don't throw if `fillStyle` or `strokeStyle` is set to an object, but that object is not a Gradient or Pattern. (This behavior was non-standard: invalid inputs are supposed to be ignored.) 2.6.1 ================== diff --git a/src/CanvasRenderingContext2d.cc b/src/CanvasRenderingContext2d.cc index 4a749b650..42f331805 100644 --- a/src/CanvasRenderingContext2d.cc +++ b/src/CanvasRenderingContext2d.cc @@ -1844,9 +1844,6 @@ NAN_SETTER(Context2d::SetFillStyle) { context->_fillStyle.Reset(value); Pattern *pattern = Nan::ObjectWrap::Unwrap(obj); context->state->fillPattern = pattern->pattern(); - } else { - // TODO this is non-standard - Nan::ThrowTypeError("Gradient or Pattern expected"); } } } @@ -1890,9 +1887,6 @@ NAN_SETTER(Context2d::SetStrokeStyle) { context->_strokeStyle.Reset(value); Pattern *pattern = Nan::ObjectWrap::Unwrap(obj); context->state->strokePattern = pattern->pattern(); - } else { - // TODO this is non-standard - return Nan::ThrowTypeError("Gradient or Pattern expected"); } } } diff --git a/test/canvas.test.js b/test/canvas.test.js index 45ff14668..b824f8da2 100644 --- a/test/canvas.test.js +++ b/test/canvas.test.js @@ -1766,10 +1766,6 @@ describe('Canvas', function () { else assert.strictEqual(byte, 255); }); - - assert.throws(function () { - ctx.fillStyle = Object.create(null); - }); }); });