mirror of
https://github.com/konvajs/konva.git
synced 2025-04-29 02:48:20 +08:00
fill, stroke, and strokeWidth values of undefined, null, '', or 0 are now correctly handled
This commit is contained in:
parent
9f6381aef3
commit
c661cff85a
15
dist/kinetic-core.js
vendored
15
dist/kinetic-core.js
vendored
@ -2301,17 +2301,18 @@ Kinetic.Shape.prototype = {
|
||||
fillStroke: function() {
|
||||
var context = this.getContext();
|
||||
|
||||
if(this.attrs.fill !== undefined) {
|
||||
/*
|
||||
* expect that fill, stroke, and strokeWidth could be
|
||||
* undfined, '', null, or 0. Use !!
|
||||
*/
|
||||
if(!!this.attrs.fill) {
|
||||
context.fillStyle = this.attrs.fill;
|
||||
context.fill();
|
||||
}
|
||||
|
||||
var hasStroke = this.attrs.stroke !== undefined;
|
||||
var hasStrokeWidth = this.attrs.strokeWidth !== undefined && this.attrs.strokeWidth !== 0;
|
||||
|
||||
if(hasStroke || hasStrokeWidth) {
|
||||
var stroke = hasStroke ? this.attrs.stroke : 'black';
|
||||
var strokeWidth = hasStrokeWidth ? this.attrs.strokeWidth : 2;
|
||||
if(!!this.attrs.stroke || !!this.attrs.strokeWidth) {
|
||||
var stroke = !!this.attrs.stroke ? this.attrs.stroke : 'black';
|
||||
var strokeWidth = !!this.attrs.strokeWidth ? this.attrs.strokeWidth : 2;
|
||||
|
||||
context.lineWidth = strokeWidth;
|
||||
context.strokeStyle = stroke;
|
||||
|
4
dist/kinetic-core.min.js
vendored
4
dist/kinetic-core.min.js
vendored
File diff suppressed because one or more lines are too long
15
src/Shape.js
15
src/Shape.js
@ -59,17 +59,18 @@ Kinetic.Shape.prototype = {
|
||||
fillStroke: function() {
|
||||
var context = this.getContext();
|
||||
|
||||
if(this.attrs.fill !== undefined) {
|
||||
/*
|
||||
* expect that fill, stroke, and strokeWidth could be
|
||||
* undfined, '', null, or 0. Use !!
|
||||
*/
|
||||
if(!!this.attrs.fill) {
|
||||
context.fillStyle = this.attrs.fill;
|
||||
context.fill();
|
||||
}
|
||||
|
||||
var hasStroke = this.attrs.stroke !== undefined;
|
||||
var hasStrokeWidth = this.attrs.strokeWidth !== undefined && this.attrs.strokeWidth !== 0;
|
||||
|
||||
if(hasStroke || hasStrokeWidth) {
|
||||
var stroke = hasStroke ? this.attrs.stroke : 'black';
|
||||
var strokeWidth = hasStrokeWidth ? this.attrs.strokeWidth : 2;
|
||||
if(!!this.attrs.stroke || !!this.attrs.strokeWidth) {
|
||||
var stroke = !!this.attrs.stroke ? this.attrs.stroke : 'black';
|
||||
var strokeWidth = !!this.attrs.strokeWidth ? this.attrs.strokeWidth : 2;
|
||||
|
||||
context.lineWidth = strokeWidth;
|
||||
context.strokeStyle = stroke;
|
||||
|
Loading…
Reference in New Issue
Block a user