mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-19 06:00:56 -05:00
Have paper.install() override existing definitions.
And include a warning about this approach in the documentation.
This commit is contained in:
parent
1ee6bb7e79
commit
9c98ef8316
1 changed files with 7 additions and 2 deletions
|
@ -129,7 +129,12 @@ var PaperScope = Base.extend(/** @lends PaperScope# */{
|
|||
* Injects the paper scope into any other given scope. Can be used for
|
||||
* examle to inject the currently active PaperScope into the window's global
|
||||
* scope, to emulate PaperScript-style globally accessible Paper classes and
|
||||
* objects:
|
||||
* objects.
|
||||
*
|
||||
* <b>Please note:</b> Using this method may override native constructors
|
||||
* (e.g. Path, RGBColor). This may cause problems when using Paper.js in
|
||||
* conjunction with other libraries that rely on these constructors. Keep
|
||||
* the library scoped if you encounter issues caused by this.
|
||||
*
|
||||
* @example
|
||||
* paper.install(window);
|
||||
|
@ -150,7 +155,7 @@ var PaperScope = Base.extend(/** @lends PaperScope# */{
|
|||
// 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)/.test(key) && !(key in scope))
|
||||
if (!/^(version|_id)/.test(key))
|
||||
scope[key] = this[key];
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue