mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-05 20:32:00 -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') {
|
/*#*/ if (options.environment == 'browser') {
|
||||||
|
|
||||||
function load() {
|
function load() {
|
||||||
var scripts = document.getElementsByTagName('script');
|
Base.each(document.getElementsByTagName('script'), function(script) {
|
||||||
for (var i = 0, l = scripts.length; i < l; i++) {
|
|
||||||
var script = scripts[i];
|
|
||||||
// Only load this script if it not loaded already.
|
// Only load this script if it not loaded already.
|
||||||
// Support both text/paperscript and text/x-paperscript:
|
// Support both text/paperscript and text/x-paperscript:
|
||||||
if (/^text\/(?:x-|)paperscript$/.test(script.type)
|
if (/^text\/(?:x-|)paperscript$/.test(script.type)
|
||||||
|
@ -315,9 +313,9 @@ paper.PaperScope.prototype.PaperScript = (function(root) {
|
||||||
if (src) {
|
if (src) {
|
||||||
// If we're loading from a source, request that first and
|
// If we're loading from a source, request that first and
|
||||||
// then run later.
|
// then run later.
|
||||||
paper.Http.request('get', src, function(scope, code) {
|
paper.Http.request('get', src, function(code) {
|
||||||
evaluate(code, scope);
|
evaluate(code, scope);
|
||||||
}.bind(this, scope));
|
});
|
||||||
} else {
|
} else {
|
||||||
// We can simply get the code form the script tag.
|
// We can simply get the code form the script tag.
|
||||||
evaluate(script.innerHTML, scope);
|
evaluate(script.innerHTML, scope);
|
||||||
|
@ -325,7 +323,7 @@ paper.PaperScope.prototype.PaperScript = (function(root) {
|
||||||
// Mark script as loaded now.
|
// Mark script as loaded now.
|
||||||
script.setAttribute('data-paper-ignore', true);
|
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
|
// Catch cases where paper.js is loaded after the browser event has already
|
||||||
|
|
Loading…
Reference in a new issue