Let paper be an instance of Base, and use its #extend() function to create scopes that inherit from paper but do not directly modify it.

This commit is contained in:
Jürg Lehni 2011-03-03 18:35:37 +00:00
parent 2c78a0a08b
commit 0b3c57ff88
2 changed files with 5 additions and 3 deletions

View file

@ -1,4 +1,4 @@
var paper = {
var paper = new Base().inject({
document: null,
documents: [],
@ -7,4 +7,4 @@ var paper = {
scope[i] = paper[i];
}
}
};
});

View file

@ -4,7 +4,9 @@ var PaperScript = new function() {
}
function run(code) {
with (paper) {
// Use paper.extend() to create a paper scope within which the code is
// evaluated.
with (paper.extend()) {
return eval(compile(code));
}
}