From 87e89d126f8190d00de0704b67827ca6a4640477 Mon Sep 17 00:00:00 2001 From: Vasiliy Loginevskiy Date: Fri, 17 Jun 2016 21:51:47 +0300 Subject: [PATCH] Add escaped object to simple primitives. --- lib/bh.js | 3 ++- test/test.isSimple.js | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/bh.js b/lib/bh.js index f8acdce..6bf1b2a 100644 --- a/lib/bh.js +++ b/lib/bh.js @@ -76,7 +76,8 @@ function BH() { isSimple: function(obj) { if (!obj || obj === true) return true; var t = typeof obj; - return t === 'string' || t === 'number'; + return t === 'string' || t === 'number' || + Boolean(typeof obj.tag !== 'undefined' && !obj.tag && obj.html); }, /** * Расширяет один объект свойствами другого (других). diff --git a/test/test.isSimple.js b/test/test.isSimple.js index ede17e6..ff17ee5 100644 --- a/test/test.isSimple.js +++ b/test/test.isSimple.js @@ -15,6 +15,9 @@ describe('ctx.isSimple()', function() { it('should return true for string', function() { bh.utils.isSimple('1').should.equal(true); }); + it('should return true for escaped string', function() { + bh.utils.isSimple({ tag: false, html: '42' }).should.equal(true); + }); it('should return true for boolean', function() { bh.utils.isSimple(false).should.equal(true); });