Skip to content

Commit

Permalink
body: throw meaningful error
Browse files Browse the repository at this point in the history
  • Loading branch information
indutny committed Apr 1, 2014
1 parent 2c0d30d commit 3a40d0e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/xjst/compiler/entities/body.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,9 @@ Body.prototype.rollOutLocal = function rollOutLocal(ast, changes, body) {
changes.forEach(function(change) {
if (change.type === 'Literal')
return;
assert.equal(change.type, 'ObjectExpression');
assert.equal(change.type,
'ObjectExpression',
'apply() and local() accepts only object literals');
change.properties.forEach(function(property) {
var keys = (property.key.name || property.key.value).split('.');
var isGlobal = keys[0] === '$$global';
Expand Down
3 changes: 3 additions & 0 deletions lib/xjst/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ utils.run = function run(templates, context) {
if (change === null)
return;

if (typeof change !== 'object')
throw new Error('apply() and local() accepts only object literals');

Object.keys(change).forEach(function(key) {
var parts = key.split('.'),
newValue = change[key],
Expand Down

0 comments on commit 3a40d0e

Please sign in to comment.