Skip to content

Commit a775e66

Browse files
committed
Do not use #splice() for the initial push to the documents / children list.
1 parent 8c2ad5f commit a775e66

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/document/Document.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ var Document = this.Document = Base.extend({
5959
this.bounds = Rectangle.create(0, 0, this._size.width,
6060
this._size.height);
6161
this.context = this.canvas.getContext('2d');
62-
// Push it onto paper.documents and adjust index in one:
63-
Base.splice(paper.documents, [this]);
62+
// Push it onto paper.documents and set index:
63+
this._index = paper.documents.push(this) - 1;
6464
this.activate();
6565
this.layers = [];
6666
this.activeLayer = new Layer();

src/item/Layer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ var Layer = this.Layer = Group.extend({
2020
initialize: function() {
2121
this.children = [];
2222
this._document = paper.document;
23-
// Push it onto document.layers and adjust index in one:
24-
Base.splice(this._document.layers, [this]);
23+
// Push it onto document.layers and set index:
24+
this._index = this._document.layers.push(this) - 1;
2525
this.activate();
2626
},
2727

0 commit comments

Comments
 (0)