Skip to content

Commit

Permalink
package: bump xjst version, better asserts
Browse files Browse the repository at this point in the history
  • Loading branch information
indutny committed Apr 9, 2014
1 parent fbac350 commit f20817a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
14 changes: 9 additions & 5 deletions lib/bemhtml/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ Compiler.prototype.pretranslate = function pretranslate(ast) {
return ast;
};

Compiler.prototype.translate = function translate(ast) {
Compiler.prototype.translate = function translate(ast, code) {
ast = this.pretranslate(ast);
return this.replaceContext(xjst.translate(ast, this.options));
return this.replaceContext(xjst.translate(ast, code, this.options));
};

Compiler.prototype.markMatches = function markMatches(ast) {
Expand Down Expand Up @@ -614,7 +614,9 @@ Compiler.prototype.traceChanges = function traceChanges(changes, expr) {
};

Compiler.prototype.pregenerate = function pregenerate(code) {
var ast = esprima.parse(code);
var ast = esprima.parse(code, {
loc: true
});

ast = this.pretranslate(ast);

Expand Down Expand Up @@ -668,9 +670,11 @@ Compiler.prototype.generate = function generate(code) {
return this.wrap(xjst.generate(source, this.options));
}

var ast = esprima.parse(code);
var ast = esprima.parse(code, {
loc: true
});

ast = this.translate(ast);
ast = this.translate(ast, code);

var out = uglify.AST_Node.from_mozilla_ast(ast).print_to_string({ beautify: true });

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
"author": "Fedor Indutny",
"license": "MIT",
"dependencies": {
"estraverse": "~1.1.1",
"esprima": "~1.0.2",
"estraverse": "~1.5.0",
"esprima": "~1.1.1",
"ometajs": "~3.2.4",
"uglify-js": "~2.3.2",
"xjst": "~1.3.2",
"xjst": "~1.3.7",
"coa": "~0.3.9",
"q": "~0.9.3"
},
Expand Down
5 changes: 2 additions & 3 deletions test/api-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ describe('BEM.js compiler', function() {
';\n' +
fn.toString().replace(/^function\s*\(\)\s*{|}$/g, '');
var fns = [
bem.compile(body, utile.mixin({}, options, { optimize: false })),
bem.compile(body, options)
];

fns.forEach(function(fn) {
assert.equal(fn.apply.call(data || {}), expected);
fns.forEach(function(fn, i) {
assert.equal(fn.apply.call(data || {}), expected, i);
});
}

Expand Down

0 comments on commit f20817a

Please sign in to comment.