|
54 | 54 | /** Used to store tokenized template text snippets */
|
55 | 55 | var tokenized = [];
|
56 | 56 |
|
| 57 | + /** Detect if sourceURL syntax is usable without erroring */ |
| 58 | + try { |
| 59 | + // Adobe's and Narwhal's JS engines will error |
| 60 | + var useSourceURL = (Function('//@')(), true); |
| 61 | + } catch(e){ } |
| 62 | + |
57 | 63 | /**
|
58 | 64 | * Used to escape characters for inclusion in HTML.
|
59 | 65 | * The `>` and `/` characters don't require escaping in HTML and have no
|
|
2641 | 2647 | // ensure both objects have the same number of properties
|
2642 | 2648 | if (result) {
|
2643 | 2649 | for (prop in b) {
|
2644 |
| - // Adobe JS engines have an operator precedence bug that causes `!size--` |
2645 |
| - // to produce the wrong result so it must be wrapped in parentheses. |
| 2650 | + // Adobe's JS engine, embedded in applications like InDesign, has a |
| 2651 | + // bug that causes `!size--` to throw an error so it must be wrapped |
| 2652 | + // in parentheses. |
2646 | 2653 | // https://github.com/documentcloud/underscore/issues/355
|
2647 | 2654 | if (hasOwnProperty.call(b, prop) && !(size--)) {
|
2648 | 2655 | break;
|
|
3208 | 3215 | 'var __p, __t, __j = Array.prototype.join;\n' +
|
3209 | 3216 | 'function print() { __p += __j.call(arguments, \'\') }\n' +
|
3210 | 3217 | text +
|
3211 |
| - 'return __p\n}\n' + |
3212 |
| - // add sourceURL for easier debugging |
3213 |
| - // (Narwhal requires a trailing newline to prevent a syntax error) |
3214 |
| - // http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl |
3215 |
| - '//@ sourceURL=/lodash/template/source[' + (templateCounter++) + ']\n'; |
| 3218 | + 'return __p\n}'; |
| 3219 | + |
| 3220 | + // add a sourceURL for easier debugging |
| 3221 | + // http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl |
| 3222 | + if (useSourceURL) { |
| 3223 | + text += '\n//@ sourceURL=/lodash/template/source[' + (templateCounter++) + ']'; |
| 3224 | + } |
3216 | 3225 |
|
3217 | 3226 | result = Function('_', 'return ' + text)(lodash);
|
3218 | 3227 |
|
|
0 commit comments