Skip to content

Commit c6cf4f9

Browse files
committed
Only create an empty Project for a PaperScope if a canvas was provided for it.
1 parent da6f923 commit c6cf4f9

2 files changed

Lines changed: 11 additions & 10 deletions

File tree

src/core/PaperScope.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,26 +39,24 @@
3939
var PaperScope = this.PaperScope = Base.extend(/** @lends PaperScope# */{
4040

4141
/**
42-
* Creates a PaperScope object and an empty {@link Project} for it. If a
43-
* canvas is provided, it also creates a {@link View} for it.
44-
* Both project and view are linked to this scope.
42+
* Creates a PaperScope object. If a canvas is provided, it also creates a
43+
* an empty {@link Project} and a {@link View} for it, both linked to this
44+
* scope.
4545
*
4646
* @name PaperScope#initialize
4747
* @function
4848
* @param {HTMLCanvasElement} canvas The canvas this scope should be
49-
* associated with.
49+
* associated with.
5050
*/
5151
initialize: function(canvas, script) {
5252
// script is only used internally, when creating scopes for PaperScript.
5353
// Whenever a PaperScope is created, it automatically becomes the active
5454
// one.
5555
paper = this;
56-
this.views = [];
5756
this.view = null;
57+
this.views = [];
58+
this.project = null;
5859
this.projects = [];
59-
// Since the global paper variable points to this PaperScope, the
60-
// created project and view are automatically associated with it.
61-
this.project = new Project();
6260
this.tool = null;
6361
this.tools = [];
6462
var obj = script || canvas;
@@ -72,6 +70,10 @@ var PaperScope = this.PaperScope = Base.extend(/** @lends PaperScope# */{
7270
script.setAttribute('id', this._id);
7371
PaperScope._scopes[this._id] = this;
7472
if (canvas) {
73+
// Create an empty project for the scope.
74+
// Since the global paper variable points to this PaperScope, the
75+
// created project and view are automatically associated with it.
76+
this.project = new Project();
7577
// Create a view for the canvas.
7678
this.view = new View(canvas);
7779
}

src/core/PaperScript.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,7 @@ var PaperScript = this.PaperScript = new function() {
144144

145145
/**
146146
* Evaluates parsed PaperScript code in the passed {@link PaperScope}
147-
* object. It also handles canvas setup, tool creation and handlers
148-
* automatically for us.
147+
* object. It also installs handlers automatically for us.
149148
*
150149
* @name PaperScript.evaluate
151150
* @function

0 commit comments

Comments
 (0)