Fix PaperScope#install() so classes actually get injected.

This commit is contained in:
Jürg Lehni 2011-08-01 12:02:50 +01:00
parent a8c08b3301
commit 14895f412c
2 changed files with 12 additions and 6 deletions

View file

@ -137,12 +137,15 @@ var PaperScope = this.PaperScope = Base.extend(/** @lends PaperScope# */{
}
});
});
// Use scope as side-car (= 'this' inside iterator), and have it
// returned at the end.
return Base.each(this, function(value, key) {
if (!(key in this))
this[key] = value;
}, scope);
// Copy over all fields from this scope to the destination.
// Do not use Base.each, since we also want to enumerate over
// fields on PaperScope.prototype, e.g. all classes
for (var key in this) {
if (!/^(version|_id|load)/.test(key) && !(key in scope)) {
console.log(key);
scope[key] = this[key];
}
}
},
/**

View file

@ -127,6 +127,9 @@ var paper = new function() {
// the first PaperScope and return it, all in one statement.
// The version for 'dev' of this happens in core/initialize.js, since it depends
// on sequentiality of include() loading.
// Mark this object as enumerable, so all the injected classes can be enumerated
// again in PaperScope#install().
this.enumerable = true;
return new (PaperScope.inject(this));
/*#*/ } // options.version != 'dev'
};