mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Fix PaperScope#install() so classes actually get injected.
This commit is contained in:
parent
a8c08b3301
commit
14895f412c
2 changed files with 12 additions and 6 deletions
|
@ -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];
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -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'
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue