diff --git a/lib/bemxjst/tree.js b/lib/bemxjst/tree.js index 32fa6f95..a2ecacb2 100644 --- a/lib/bemxjst/tree.js +++ b/lib/bemxjst/tree.js @@ -80,12 +80,13 @@ ReplaceMatch.prototype.wrapBody = function wrapBody(body) { if (typeof body !== 'function') { return function inlineAdaptor() { - return applyCtx(body); + return applyCtx(body, { position: this.position - 1 }); }; } return function replaceAdaptor() { - return applyCtx(body.call(this, this, this.ctx)); + return applyCtx(body.call(this, this, this.ctx), + { position: this.position - 1 }); }; }; diff --git a/test/bemcontext-position-test.js b/test/bemcontext-position-test.js index a2e2ad12..bd9ac612 100644 --- a/test/bemcontext-position-test.js +++ b/test/bemcontext-position-test.js @@ -113,4 +113,20 @@ describe('BEMContext this.position', function() { { block: 'a1', content: { block: 'a2', content: { block: 'a3' } } }, '