Have paper.install() override existing definitions.

And include a warning about this approach in the documentation.
This commit is contained in:
Jürg Lehni 2013-09-23 11:49:23 -07:00
parent 1ee6bb7e79
commit 9c98ef8316

View file

@ -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];
}
},