Skip to content

Commit

Permalink
Make "column"-property of Errors enumerable
Browse files Browse the repository at this point in the history
  • Loading branch information
nknapp committed Dec 21, 2016
1 parent 5bbb54e commit c562a5a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/handlebars/exception.js
Expand Up @@ -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;
}
Expand Down
9 changes: 9 additions & 0 deletions spec/compiler.js
Expand Up @@ -48,6 +48,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',
Expand Down

0 comments on commit c562a5a

Please sign in to comment.