Skip to content

Commit bf5126b

Browse files
committedJul 17, 2020
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
1 parent 4ce04af commit bf5126b

File tree

3 files changed

+1
-10
lines changed

3 files changed

+1
-10
lines changed
 

‎CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ project adheres to [Semantic Versioning](http://semver.org/).
2424
* Fix compile errors with cairo
2525
* Fix Image#complete if the image failed to load.
2626
* Upgrade node-pre-gyp to v0.15.0 to use latest version of needle to fix error when downloading prebuilds.
27+
* 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.)
2728

2829
2.6.1
2930
==================

‎src/CanvasRenderingContext2d.cc

-6
Original file line numberDiff line numberDiff line change
@@ -1844,9 +1844,6 @@ NAN_SETTER(Context2d::SetFillStyle) {
18441844
context->_fillStyle.Reset(value);
18451845
Pattern *pattern = Nan::ObjectWrap::Unwrap<Pattern>(obj);
18461846
context->state->fillPattern = pattern->pattern();
1847-
} else {
1848-
// TODO this is non-standard
1849-
Nan::ThrowTypeError("Gradient or Pattern expected");
18501847
}
18511848
}
18521849
}
@@ -1890,9 +1887,6 @@ NAN_SETTER(Context2d::SetStrokeStyle) {
18901887
context->_strokeStyle.Reset(value);
18911888
Pattern *pattern = Nan::ObjectWrap::Unwrap<Pattern>(obj);
18921889
context->state->strokePattern = pattern->pattern();
1893-
} else {
1894-
// TODO this is non-standard
1895-
return Nan::ThrowTypeError("Gradient or Pattern expected");
18961890
}
18971891
}
18981892
}

‎test/canvas.test.js

-4
Original file line numberDiff line numberDiff line change
@@ -1766,10 +1766,6 @@ describe('Canvas', function () {
17661766
else
17671767
assert.strictEqual(byte, 255);
17681768
});
1769-
1770-
assert.throws(function () {
1771-
ctx.fillStyle = Object.create(null);
1772-
});
17731769
});
17741770

17751771
});

0 commit comments

Comments
 (0)
Please sign in to comment.