diff --git a/lib/bh.js b/lib/bh.js index 9532123..2cb8ba5 100644 --- a/lib/bh.js +++ b/lib/bh.js @@ -822,12 +822,12 @@ BH.prototype = { if (decl.elemMod) { conds.push( 'json.elemMods && json.elemMods["' + decl.elemMod + '"] === ' + - (decl.elemModVal === true || '"' + decl.elemModVal + '"')); + (decl.elemModVal === true || Number(decl.elemModVal) || '"' + decl.elemModVal + '"')); } if (decl.blockMod) { conds.push( 'json.mods && json.mods["' + decl.blockMod + '"] === ' + - (decl.blockModVal === true || '"' + decl.blockModVal + '"')); + (decl.blockModVal === true || Number(decl.blockModVal) || '"' + decl.blockModVal + '"')); } res.push('if (' + conds.join(' && ') + ') {'); pushMatcher(res, fn.__id, decl.index); diff --git a/test/test.match.js b/test/test.match.js index 77b0185..a615083 100644 --- a/test/test.match.js +++ b/test/test.match.js @@ -156,4 +156,23 @@ describe('bh.match()', function() { '
' ); }); + + it('should match on Number mod values', function() { + bh.match('title', function(ctx) { + ctx.tag('h1'); + }); + + bh.match('title_level_2', function(ctx) { + ctx.tag('h2'); + }); + + bh.apply({ + block: 'title', + mods: { + level: 2 + } + }).should.equal( + '' + ); + }); });