From bc28643520cee83154ad350d8fbe5511f61d2675 Mon Sep 17 00:00:00 2001 From: miripiruni Date: Fri, 29 Jul 2016 13:55:05 +0300 Subject: [PATCH] BEMXJST: work with empty string in html field --- lib/bemxjst/index.js | 2 +- lib/bemxjst/utils.js | 2 +- test/runtime-escaping-test.js | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/bemxjst/index.js b/lib/bemxjst/index.js index 3a4736f8..1b8d0042 100644 --- a/lib/bemxjst/index.js +++ b/lib/bemxjst/index.js @@ -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' && @@ -329,6 +328,7 @@ BEMXJST.prototype.runSimple = function runSimple(simple) { utils.xmlEscape(simple) : simple; } + return res; }; diff --git a/lib/bemxjst/utils.js b/lib/bemxjst/utils.js index 6b23146b..8e7ce5b7 100644 --- a/lib/bemxjst/utils.js +++ b/lib/bemxjst/utils.js @@ -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'; }; diff --git a/test/runtime-escaping-test.js b/test/runtime-escaping-test.js index 32ec2c2f..3409bc4a 100644 --- a/test/runtime-escaping-test.js +++ b/test/runtime-escaping-test.js @@ -39,6 +39,12 @@ describe('Content escaping', function() { ''); }); + 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: '', content: 'safe text' },