mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-06 04:42:15 -05:00
Minor PaperScript clean-ups.
This commit is contained in:
parent
7291956155
commit
51eff78919
1 changed files with 6 additions and 4 deletions
|
@ -293,7 +293,8 @@ var PaperScript = Base.exports.PaperScript = (function() {
|
||||||
if (handlers)
|
if (handlers)
|
||||||
code += '\nreturn { ' + handlers + ' };';
|
code += '\nreturn { ' + handlers + ' };';
|
||||||
/*#*/ if (__options.environment == 'browser') {
|
/*#*/ if (__options.environment == 'browser') {
|
||||||
if (window.InstallTrigger || window.chrome) { // Firefox and Chrome
|
var firefox = window.InstallTrigger;
|
||||||
|
if (firefox || window.chrome) {
|
||||||
// On Firefox, all error numbers inside dynamically compiled code
|
// On Firefox, all error numbers inside dynamically compiled code
|
||||||
// are relative to the line where the eval / compilation happened.
|
// are relative to the line where the eval / compilation happened.
|
||||||
// To fix this issue, we're temporarily inserting a new script
|
// To fix this issue, we're temporarily inserting a new script
|
||||||
|
@ -302,15 +303,16 @@ var PaperScript = Base.exports.PaperScript = (function() {
|
||||||
// https://code.google.com/p/chromium/issues/detail?id=331655
|
// https://code.google.com/p/chromium/issues/detail?id=331655
|
||||||
var script = document.createElement('script'),
|
var script = document.createElement('script'),
|
||||||
head = document.head;
|
head = document.head;
|
||||||
// Do not add a new-line before the code on Chrome since the error
|
// Add a new-line before the code on Firefox since the error
|
||||||
// messages are shifted by one line there...
|
// messages appeawr to be aligned to line number 0...
|
||||||
if (!window.chrome)
|
if (firefox)
|
||||||
code = '\n' + code;
|
code = '\n' + code;
|
||||||
script.appendChild(document.createTextNode(
|
script.appendChild(document.createTextNode(
|
||||||
'paper._execute = function(' + params + ') {' + code + '\n}'
|
'paper._execute = function(' + params + ') {' + code + '\n}'
|
||||||
));
|
));
|
||||||
head.appendChild(script);
|
head.appendChild(script);
|
||||||
func = paper._execute;
|
func = paper._execute;
|
||||||
|
delete paper._execute;
|
||||||
head.removeChild(script);
|
head.removeChild(script);
|
||||||
} else {
|
} else {
|
||||||
func = Function(params, code);
|
func = Function(params, code);
|
||||||
|
|
Loading…
Reference in a new issue