mirror of
https://github.com/konvajs/konva.git
synced 2025-04-05 20:48:28 +08:00
clean tests and adding docs
This commit is contained in:
parent
7a2173dd7f
commit
7f7fb652da
16
kinetic.js
16
kinetic.js
@ -4,7 +4,7 @@
|
||||
* http://www.kineticjs.com/
|
||||
* Copyright 2013, Eric Rowell
|
||||
* Licensed under the MIT or GPL Version 2 licenses.
|
||||
* Date: 2014-09-23
|
||||
* Date: 2014-09-24
|
||||
*
|
||||
* Copyright (C) 2011 - 2013 by Eric Rowell
|
||||
*
|
||||
@ -510,10 +510,15 @@ var Kinetic = {};
|
||||
},
|
||||
_addName: function(node, name) {
|
||||
if(name !== undefined) {
|
||||
if(this.names[name] === undefined) {
|
||||
this.names[name] = [];
|
||||
var names = name.split(/\W+/g);
|
||||
for(var n = 0; n < names.length; n++) {
|
||||
if (names[n]) {
|
||||
if(this.names[names[n]] === undefined) {
|
||||
this.names[names[n]] = [];
|
||||
}
|
||||
this.names[names[n]].push(node);
|
||||
}
|
||||
}
|
||||
this.names[name].push(node);
|
||||
}
|
||||
},
|
||||
_removeName: function(name, _id) {
|
||||
@ -3917,6 +3922,9 @@ var Kinetic = {};
|
||||
*
|
||||
* // set name
|
||||
* node.name('foo');
|
||||
*
|
||||
* // also node may have multiple names (as css classes)
|
||||
* node.name('foo bar');
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addGetter(Kinetic.Node, 'id');
|
||||
|
6
kinetic.min.js
vendored
6
kinetic.min.js
vendored
File diff suppressed because one or more lines are too long
@ -1667,6 +1667,9 @@
|
||||
*
|
||||
* // set name
|
||||
* node.name('foo');
|
||||
*
|
||||
* // also node may have multiple names (as css classes)
|
||||
* node.name('foo bar');
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addGetter(Kinetic.Node, 'id');
|
||||
|
@ -798,34 +798,25 @@ suite('Container', function() {
|
||||
layer.add(group);
|
||||
stage.add(layer);
|
||||
|
||||
assert.equal(stage.find('.rectangle')[0].attrs.id, 'rectId', 'problem with shape name selector');
|
||||
assert.equal(stage.find('#rectId')[0].attrs.id, 'rectId', 'problem with shape id selector');
|
||||
assert.equal(layer.find('.rectangle')[0].attrs.id, 'rectId', 'problem with shape name selector');
|
||||
assert.equal(layer.find('#rectId')[0].attrs.id, 'rectId', 'problem with shape id selector');
|
||||
assert.equal(group.find('.rectangle')[0].attrs.id, 'rectId', 'problem with shape name selector');
|
||||
assert.equal(group.find('#rectId')[0].attrs.id, 'rectId', 'problem with shape id selector');
|
||||
assert.equal(stage.find('.rectangle')[0], rect, 'problem with shape name selector');
|
||||
assert.equal(layer.find('.rectangle')[0], rect, 'problem with shape name selector');
|
||||
assert.equal(group.find('.rectangle')[0], rect, 'problem with shape name selector');
|
||||
|
||||
assert.equal(stage.find('.circle')[0].attrs.id, 'circleId', 'problem with shape name selector');
|
||||
assert.equal(stage.find('#circleId')[0].attrs.id, 'circleId', 'problem with shape id selector');
|
||||
assert.equal(layer.find('.circle')[0].attrs.id, 'circleId', 'problem with shape name selector');
|
||||
assert.equal(layer.find('#circleId')[0].attrs.id, 'circleId', 'problem with shape id selector');
|
||||
assert.equal(group.find('.circle')[0].attrs.id, 'circleId', 'problem with shape name selector');
|
||||
assert.equal(group.find('#circleId')[0].attrs.id, 'circleId', 'problem with shape id selector');
|
||||
assert.equal(stage.find('.circle')[0], circle, 'problem with shape name selector');
|
||||
assert.equal(layer.find('.circle')[0], circle, 'problem with shape name selector');
|
||||
assert.equal(group.find('.circle')[0], circle, 'problem with shape name selector');
|
||||
|
||||
assert.equal(stage.find('.red')[0].attrs.id, 'rectId', 'problem with shape name selector');
|
||||
assert.equal(stage.find('.red')[1].attrs.id, 'circleId', 'problem with shape name selector');
|
||||
assert.equal(layer.find('.red')[0].attrs.id, 'rectId', 'problem with shape name selector');
|
||||
assert.equal(layer.find('.red')[1].attrs.id, 'circleId', 'problem with shape name selector');
|
||||
assert.equal(group.find('.red')[0].attrs.id, 'rectId', 'problem with shape name selector');
|
||||
assert.equal(group.find('.red')[1].attrs.id, 'circleId', 'problem with shape name selector');
|
||||
assert.equal(stage.find('.red')[0], rect, 'problem with shape name selector');
|
||||
assert.equal(stage.find('.red')[1], circle, 'problem with shape name selector');
|
||||
assert.equal(layer.find('.red')[0], rect, 'problem with shape name selector');
|
||||
assert.equal(layer.find('.red')[1], circle, 'problem with shape name selector');
|
||||
assert.equal(group.find('.red')[0], rect, 'problem with shape name selector');
|
||||
assert.equal(group.find('.red')[1], circle, 'problem with shape name selector');
|
||||
|
||||
assert.equal(stage.find('.groupName')[0].attrs.id, 'groupId', 'problem with group name selector');
|
||||
assert.equal(stage.find('#groupId')[0].attrs.id, 'groupId', 'problem with group id selector');
|
||||
assert.equal(layer.find('.groupName')[0].attrs.id, 'groupId', 'problem with group name selector');
|
||||
assert.equal(layer.find('#groupId')[0].attrs.id, 'groupId', 'problem with group id selector');
|
||||
assert.equal(stage.find('.groupName')[0], group, 'problem with group name selector');
|
||||
assert.equal(layer.find('.groupName')[0], group, 'problem with group name selector');
|
||||
|
||||
assert.equal(stage.find('.layerName')[0].attrs.id, 'layerId', 'problem with layer name selector');
|
||||
assert.equal(stage.find('#layerId')[0].attrs.id, 'layerId', 'problem with layer id selector');
|
||||
assert.equal(stage.find('.layerName')[0], layer, 'problem with layer name selector');
|
||||
});
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user