mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 18:37:50 +00:00
Ensure sourceURL support doesn't cause errors in Adobe's JS engine.
Former-commit-id: 2ad1214e6a58832c732499b272ebfc434953213b
This commit is contained in:
@@ -217,7 +217,7 @@
|
|||||||
source = source.replace('"\';\\n"', '"\';"');
|
source = source.replace('"\';\\n"', '"\';"');
|
||||||
|
|
||||||
// remove debug sourceURL in `_.template`
|
// remove debug sourceURL in `_.template`
|
||||||
source = source.replace(/\+(?:\s*\/\/.*)*\s*'\/\/@ sourceURL=[^;]+/, '');
|
source = source.replace(/(?:\s*\/\/.*\n)* *if *\(useSourceURL[^}]+}/, '');
|
||||||
|
|
||||||
// minify `_.sortBy` internal properties
|
// minify `_.sortBy` internal properties
|
||||||
(function() {
|
(function() {
|
||||||
|
|||||||
23
lodash.js
23
lodash.js
@@ -54,6 +54,12 @@
|
|||||||
/** Used to store tokenized template text snippets */
|
/** Used to store tokenized template text snippets */
|
||||||
var tokenized = [];
|
var tokenized = [];
|
||||||
|
|
||||||
|
/** Detect if sourceURL syntax is usable without erroring */
|
||||||
|
try {
|
||||||
|
// Adobe's and Narwhal's JS engines will error
|
||||||
|
var useSourceURL = (Function('//@')(), true);
|
||||||
|
} catch(e){ }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to escape characters for inclusion in HTML.
|
* Used to escape characters for inclusion in HTML.
|
||||||
* The `>` and `/` characters don't require escaping in HTML and have no
|
* The `>` and `/` characters don't require escaping in HTML and have no
|
||||||
@@ -2641,8 +2647,9 @@
|
|||||||
// ensure both objects have the same number of properties
|
// ensure both objects have the same number of properties
|
||||||
if (result) {
|
if (result) {
|
||||||
for (prop in b) {
|
for (prop in b) {
|
||||||
// Adobe JS engines have an operator precedence bug that causes `!size--`
|
// Adobe's JS engine, embedded in applications like InDesign, has a
|
||||||
// to produce the wrong result so it must be wrapped in parentheses.
|
// bug that causes `!size--` to throw an error so it must be wrapped
|
||||||
|
// in parentheses.
|
||||||
// https://github.com/documentcloud/underscore/issues/355
|
// https://github.com/documentcloud/underscore/issues/355
|
||||||
if (hasOwnProperty.call(b, prop) && !(size--)) {
|
if (hasOwnProperty.call(b, prop) && !(size--)) {
|
||||||
break;
|
break;
|
||||||
@@ -3208,11 +3215,13 @@
|
|||||||
'var __p, __t, __j = Array.prototype.join;\n' +
|
'var __p, __t, __j = Array.prototype.join;\n' +
|
||||||
'function print() { __p += __j.call(arguments, \'\') }\n' +
|
'function print() { __p += __j.call(arguments, \'\') }\n' +
|
||||||
text +
|
text +
|
||||||
'return __p\n}\n' +
|
'return __p\n}';
|
||||||
// add sourceURL for easier debugging
|
|
||||||
// (Narwhal requires a trailing newline to prevent a syntax error)
|
// add a sourceURL for easier debugging
|
||||||
// http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl
|
// http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl
|
||||||
'//@ sourceURL=/lodash/template/source[' + (templateCounter++) + ']\n';
|
if (useSourceURL) {
|
||||||
|
text += '\n//@ sourceURL=/lodash/template/source[' + (templateCounter++) + ']';
|
||||||
|
}
|
||||||
|
|
||||||
result = Function('_', 'return ' + text)(lodash);
|
result = Function('_', 'return ' + text)(lodash);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user