Remove check for context.setLineDash

This commit is contained in:
Maximilian Krög
2022-08-03 22:25:19 +02:00
parent 58ca0d8098
commit ef82bbd83a
4 changed files with 19 additions and 38 deletions
+2 -2
View File
@@ -39,7 +39,7 @@ import {
* @property {import("../colorlike.js").ColorLike} [strokeStyle] StrokeStyle.
* @property {number} strokeWidth StrokeWidth.
* @property {number} size Size.
* @property {Array<number>} lineDash LineDash.
* @property {Array<number>|null} lineDash LineDash.
* @property {number} lineDashOffset LineDashOffset.
* @property {CanvasLineJoin} lineJoin LineJoin.
* @property {number} miterLimit MiterLimit.
@@ -517,7 +517,7 @@ class RegularShape extends ImageStyle {
if (this.stroke_) {
context.strokeStyle = renderOptions.strokeStyle;
context.lineWidth = renderOptions.strokeWidth;
if (context.setLineDash && renderOptions.lineDash) {
if (renderOptions.lineDash) {
context.setLineDash(renderOptions.lineDash);
context.lineDashOffset = renderOptions.lineDashOffset;
}
+3 -11
View File
@@ -10,8 +10,6 @@
* @property {CanvasLineCap} [lineCap='round'] Line cap style: `butt`, `round`, or `square`.
* @property {CanvasLineJoin} [lineJoin='round'] Line join style: `bevel`, `round`, or `miter`.
* @property {Array<number>} [lineDash] Line dash pattern. Default is `null` (no dash).
* Please note that Internet Explorer 10 and lower do not support the `setLineDash` method on
* the `CanvasRenderingContext2D` and therefore this option will have no visual effect in these browsers.
* @property {number} [lineDashOffset=0] Line dash offset.
* @property {number} [miterLimit=10] Miter limit.
* @property {number} [width] Width.
@@ -46,7 +44,7 @@ class Stroke {
/**
* @private
* @type {Array<number>}
* @type {Array<number>|null}
*/
this.lineDash_ = options.lineDash !== undefined ? options.lineDash : null;
@@ -113,7 +111,7 @@ class Stroke {
/**
* Get the line dash style for the stroke.
* @return {Array<number>} Line dash.
* @return {Array<number>|null} Line dash.
* @api
*/
getLineDash() {
@@ -179,13 +177,7 @@ class Stroke {
/**
* Set the line dash.
*
* Please note that Internet Explorer 10 and lower [do not support][mdn] the
* `setLineDash` method on the `CanvasRenderingContext2D` and therefore this
* property will have no visual effect in these browsers.
*
* [mdn]: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash#Browser_compatibility
*
* @param {Array<number>} lineDash Line dash.
* @param {Array<number>|null} lineDash Line dash.
* @api
*/
setLineDash(lineDash) {