mirror of
https://github.com/konvajs/konva.git
synced 2025-10-15 12:34:52 +08:00
find("Label") bug fixed. close #905
This commit is contained in:
@@ -1397,7 +1397,7 @@
|
||||
}
|
||||
},
|
||||
_get: function(selector) {
|
||||
return this.nodeType === selector ? [this] : [];
|
||||
return this.className === selector || this.nodeType === selector ? [this] : [];
|
||||
},
|
||||
_off: function(type, name) {
|
||||
var evtListeners = this.eventListeners[type],
|
||||
|
@@ -99,9 +99,6 @@
|
||||
hasStroke: function() {
|
||||
return !!(this.stroke() || this.strokeRed() || this.strokeGreen() || this.strokeBlue());
|
||||
},
|
||||
_get: function(selector) {
|
||||
return this.className === selector || this.nodeType === selector ? [this] : [];
|
||||
},
|
||||
/**
|
||||
* determines if point is in the shape, regardless if other shapes are on top of it. Note: because
|
||||
* this method clears a temporary canvas and then redraws the shape, it performs very poorly if executed many times
|
||||
|
@@ -58,8 +58,8 @@
|
||||
____init: function(config) {
|
||||
var that = this;
|
||||
|
||||
this.className = LABEL;
|
||||
Kinetic.Group.call(this, config);
|
||||
this.className = LABEL;
|
||||
|
||||
this.on('add.kinetic', function(evt) {
|
||||
that._addListeners(evt.child);
|
||||
|
@@ -80,4 +80,31 @@ suite('Label', function() {
|
||||
layer.add(label);
|
||||
stage.add(layer);
|
||||
});
|
||||
|
||||
test('find label class', function() {
|
||||
var stage = addStage();
|
||||
var layer = new Kinetic.Layer();
|
||||
|
||||
var label = new Kinetic.Label({
|
||||
x: 100,
|
||||
y: 100,
|
||||
});
|
||||
|
||||
// add a tag to the label
|
||||
label.add(new Kinetic.Tag({
|
||||
fill: '#bbb'
|
||||
}));
|
||||
|
||||
// add text to the label
|
||||
label.add(new Kinetic.Text({
|
||||
text: 'Test Label',
|
||||
fill: 'green'
|
||||
}));
|
||||
|
||||
layer.add(label);
|
||||
stage.add(layer);
|
||||
|
||||
assert.equal(stage.find('Label')[0], label);
|
||||
});
|
||||
|
||||
});
|
Reference in New Issue
Block a user