Fix throw when creating exception object in Safari
https://github.com/jquery/esprima/issues/1290
This commit is contained in:
@@ -12,7 +12,7 @@ function Exception(message, node) {
|
||||
message += ' - ' + line + ':' + column;
|
||||
}
|
||||
|
||||
let tmp = Error.prototype.constructor.call(this, message);
|
||||
let tmp = Error.prototype.constructor.call(this, message, loc && loc.source, line);
|
||||
|
||||
// Unfortunately errors are not enumerable in Chrome (at least), so `for prop in tmp` doesn't work.
|
||||
for (let idx = 0; idx < errorProps.length; idx++) {
|
||||
@@ -24,9 +24,19 @@ function Exception(message, node) {
|
||||
Error.captureStackTrace(this, Exception);
|
||||
}
|
||||
|
||||
if (loc) {
|
||||
this.lineNumber = line;
|
||||
this.column = column;
|
||||
try {
|
||||
if (loc) {
|
||||
this.lineNumber = line;
|
||||
|
||||
// Work around issue under safari where we can't directly set the column value
|
||||
if (Object.defineProperty) {
|
||||
Object.defineProperty(this, 'column', {value: column});
|
||||
} else {
|
||||
this.column = column;
|
||||
}
|
||||
}
|
||||
} catch (nop) {
|
||||
/* Ignore if the browser is very particular */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user