Make "column"-property of Errors enumerable
Fixes #1284
Appearently, there is a use-case of stringifying the error in order to
evaluated its properties on another system. There was a regression
from 4.0.5 to 4.0.6 that the column-property of compilation errors
was not enumerable anymore in 4.0.6 (due to commit 20c965c) and
thus was not included in the output of "JSON.stringify".
This commit is contained in:
committed by
Nils Knappmeier
parent
c7dc353956
commit
a023cb4dd9
@@ -31,7 +31,10 @@ function Exception(message, node) {
|
||||
// Work around issue under safari where we can't directly set the column value
|
||||
/* istanbul ignore next */
|
||||
if (Object.defineProperty) {
|
||||
Object.defineProperty(this, 'column', {value: column});
|
||||
Object.defineProperty(this, 'column', {
|
||||
value: column,
|
||||
enumerable: true
|
||||
});
|
||||
} else {
|
||||
this.column = column;
|
||||
}
|
||||
|
||||
@@ -54,6 +54,15 @@ describe('compiler', function() {
|
||||
}
|
||||
});
|
||||
|
||||
it('should include the location as enumerable property', function() {
|
||||
try {
|
||||
Handlebars.compile(' \n {{#if}}\n{{/def}}')();
|
||||
equal(true, false, 'Statement must throw exception. This line should not be executed.');
|
||||
} catch (err) {
|
||||
equal(err.propertyIsEnumerable('column'), true, 'Checking error column');
|
||||
}
|
||||
});
|
||||
|
||||
it('can utilize AST instance', function() {
|
||||
equal(Handlebars.compile({
|
||||
type: 'Program',
|
||||
|
||||
Reference in New Issue
Block a user