mirror of
https://github.com/konvajs/konva.git
synced 2025-10-15 12:34:52 +08:00
fix text correction. fix #786
This commit is contained in:
4
konva.min.js
vendored
4
konva.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -294,7 +294,7 @@ export class Text extends Shape<TextConfig> {
|
|||||||
context.fillStrokeShape(this);
|
context.fillStrokeShape(this);
|
||||||
}
|
}
|
||||||
setText(text) {
|
setText(text) {
|
||||||
var str = Util._isString(text) ? text : (text || '').toString();
|
var str = Util._isString(text) ? text : (text === null || text === undefined) ? '' : text + '';
|
||||||
this._setAttr(TEXT, str);
|
this._setAttr(TEXT, str);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@@ -15,7 +15,7 @@ suite('Text', function() {
|
|||||||
|
|
||||||
// ======================================================
|
// ======================================================
|
||||||
// TODO: what is the best UX here?
|
// TODO: what is the best UX here?
|
||||||
test.skip('check text with FALSY values', function() {
|
test('check text with FALSY values', function() {
|
||||||
var stage = addStage();
|
var stage = addStage();
|
||||||
var layer = new Konva.Layer();
|
var layer = new Konva.Layer();
|
||||||
|
|
||||||
@@ -28,6 +28,15 @@ suite('Text', function() {
|
|||||||
|
|
||||||
text.text(0);
|
text.text(0);
|
||||||
assert.equal(text.text(), '0');
|
assert.equal(text.text(), '0');
|
||||||
|
|
||||||
|
text.text(true);
|
||||||
|
assert.equal(text.text(), 'true');
|
||||||
|
|
||||||
|
text.text(false);
|
||||||
|
assert.equal(text.text(), 'false');
|
||||||
|
|
||||||
|
text.setText(undefined);
|
||||||
|
assert.equal(text.text(), '');
|
||||||
});
|
});
|
||||||
|
|
||||||
// ======================================================
|
// ======================================================
|
||||||
|
Reference in New Issue
Block a user