mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Solve variable scoping issue differently by using Base.each() to provide a local closure scope.
This commit is contained in:
parent
c18a5e6ffb
commit
ca3993fe8e
1 changed files with 4 additions and 6 deletions
|
@ -291,9 +291,7 @@ paper.PaperScope.prototype.PaperScript = (function(root) {
|
|||
/*#*/ if (options.environment == 'browser') {
|
||||
|
||||
function load() {
|
||||
var scripts = document.getElementsByTagName('script');
|
||||
for (var i = 0, l = scripts.length; i < l; i++) {
|
||||
var script = scripts[i];
|
||||
Base.each(document.getElementsByTagName('script'), function(script) {
|
||||
// Only load this script if it not loaded already.
|
||||
// Support both text/paperscript and text/x-paperscript:
|
||||
if (/^text\/(?:x-|)paperscript$/.test(script.type)
|
||||
|
@ -315,9 +313,9 @@ paper.PaperScope.prototype.PaperScript = (function(root) {
|
|||
if (src) {
|
||||
// If we're loading from a source, request that first and
|
||||
// then run later.
|
||||
paper.Http.request('get', src, function(scope, code) {
|
||||
paper.Http.request('get', src, function(code) {
|
||||
evaluate(code, scope);
|
||||
}.bind(this, scope));
|
||||
});
|
||||
} else {
|
||||
// We can simply get the code form the script tag.
|
||||
evaluate(script.innerHTML, scope);
|
||||
|
@ -325,7 +323,7 @@ paper.PaperScope.prototype.PaperScript = (function(root) {
|
|||
// Mark script as loaded now.
|
||||
script.setAttribute('data-paper-ignore', true);
|
||||
}
|
||||
}
|
||||
}, this, true); // Pass true for asArray to handle HTMLCollection
|
||||
}
|
||||
|
||||
// Catch cases where paper.js is loaded after the browser event has already
|
||||
|
|
Loading…
Reference in a new issue