find("Label") bug fixed. close #905

This commit is contained in:
Лаврёнов Антон
2014-04-25 19:17:12 +08:00
parent 2439040316
commit 70d7b127c0
4 changed files with 30 additions and 6 deletions

View File

@@ -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],

View File

@@ -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

View File

@@ -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);

View File

@@ -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);
});
});