Skip to content

Commit

Permalink
BEMXJST: work with empty string in html field
Browse files Browse the repository at this point in the history
  • Loading branch information
miripiruni committed Jul 29, 2016
1 parent 5bd2476 commit bc28643
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/bemxjst/index.js
Expand Up @@ -275,7 +275,6 @@ BEMXJST.prototype._run = function _run(context) {
else if (Array.isArray(context))
res = this.runMany(context);
else if (
context.html &&
typeof context.html === 'string' &&
!context.tag &&
typeof context.block === 'undefined' &&
Expand Down Expand Up @@ -329,6 +328,7 @@ BEMXJST.prototype.runSimple = function runSimple(simple) {
utils.xmlEscape(simple) :
simple;
}

return res;
};

Expand Down
2 changes: 1 addition & 1 deletion lib/bemxjst/utils.js
Expand Up @@ -49,7 +49,7 @@ exports.isSimple = function isSimple(obj) {
!obj.attrs &&
obj.hasOwnProperty('html') &&
isSimple(obj.html))
return true;
return true;
return typeof obj === 'string' || typeof obj === 'number';
};

Expand Down
6 changes: 6 additions & 0 deletions test/runtime-escaping-test.js
Expand Up @@ -39,6 +39,12 @@ describe('Content escaping', function() {
'<unescaped>');
});

it('should work with empty string in html field', function() {
test(function() {},
{ html: '' },
'');
});

it('should ignore html field if block/elem/cls/attrs/tag exists', function() {
test(function() {
}, { block: 'b', html: '<unescaped>', content: 'safe text' },
Expand Down

0 comments on commit bc28643

Please sign in to comment.