Use group creation without explicit array declaration, as that's been supported all along.

This commit is contained in:
Jürg Lehni 2012-11-06 20:37:50 -08:00
parent b1c24e2762
commit e9a9066d7f
6 changed files with 10 additions and 13 deletions

View file

@ -41,7 +41,7 @@
overlayColor.alpha = 0.5;
var overlayGradient = new Gradient([new RgbColor(1, 1, 1, 0.5), new RgbColor(1, 1, 1, 1)]);
overlay.fillColor = new GradientColor(overlayGradient, overlayPos, overlayPos + this.radius / 2);
this.item = new Group([compound, overlay]);
this.item = new Group(compound, overlay);
},
iterate: function() {

View file

@ -49,14 +49,14 @@
items = [];
var arrowVector = vector.normalize(10);
var end = vectorStart + vector;
vectorItem = new Group([
new Path([vectorStart, end]),
new Path([
vectorItem = new Group(
new Path(vectorStart, end),
new Path(
end + arrowVector.rotate(135),
end,
end + arrowVector.rotate(-135)
])
]);
)
);
vectorItem.strokeWidth = 0.75;
vectorItem.strokeColor = '#e4141b';
// Display:

View file

@ -73,8 +73,7 @@ var Group = this.Group = Item.extend(/** @lends Group# */{
// Allow Group to have children and named children
this._children = [];
this._namedChildren = {};
this.addChildren(!items || !Array.isArray(items)
|| items.length && typeof items[0] !== 'object' ? arguments : items);
this.addChildren(Array.isArray(items) ? items : arguments);
},
_changed: function(flags) {

View file

@ -1157,7 +1157,7 @@ function(name) {
* its children list. You can use this function for groups, compound
* paths and layers.
*
* @param {item[]} items The items to be added as children
* @param {Item[]} items The items to be added as children
*/
addChildren: function(items) {
this.insertChildren(this._children.length, items);

View file

@ -48,9 +48,7 @@ var CompoundPath = this.CompoundPath = PathItem.extend(/** @lends CompoundPath#
this._namedChildren = {};
// Do not reassign to paths, since arguments would get modified, which
// we potentially use as array, depending on what is passed.
var items = !paths || !Array.isArray(paths)
|| typeof paths[0] !== 'object' ? arguments : paths;
this.addChildren(items);
this.addChildren(Array.isArray(paths) ? paths : arguments);
},
insertChild: function(index, item) {

View file

@ -310,7 +310,7 @@ new function() {
// http://www.w3.org/TR/SVG/masking.html#ClipPathProperty
case 'clip-path':
var clipPath = getDefinition(value).clone().flatten(),
group = new Group([clipPath]);
group = new Group(clipPath);
group.moveAbove(item);
group.addChild(item);
group.setClipped(true);