Skip to content

Commit 14895f4

Browse files
committed
Fix PaperScope#install() so classes actually get injected.
1 parent a8c08b3 commit 14895f4

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

src/core/PaperScope.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,15 @@ var PaperScope = this.PaperScope = Base.extend(/** @lends PaperScope# */{
137137
}
138138
});
139139
});
140-
// Use scope as side-car (= 'this' inside iterator), and have it
141-
// returned at the end.
142-
return Base.each(this, function(value, key) {
143-
if (!(key in this))
144-
this[key] = value;
145-
}, scope);
140+
// Copy over all fields from this scope to the destination.
141+
// Do not use Base.each, since we also want to enumerate over
142+
// fields on PaperScope.prototype, e.g. all classes
143+
for (var key in this) {
144+
if (!/^(version|_id|load)/.test(key) && !(key in scope)) {
145+
console.log(key);
146+
scope[key] = this[key];
147+
}
148+
}
146149
},
147150

148151
/**

src/paper.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ var paper = new function() {
127127
// the first PaperScope and return it, all in one statement.
128128
// The version for 'dev' of this happens in core/initialize.js, since it depends
129129
// on sequentiality of include() loading.
130+
// Mark this object as enumerable, so all the injected classes can be enumerated
131+
// again in PaperScope#install().
132+
this.enumerable = true;
130133
return new (PaperScope.inject(this));
131134
/*#*/ } // options.version != 'dev'
132135
};

0 commit comments

Comments
 (0)