Merge pull request #33 from CartoDB/SMOKES-reference-errors

Smokes reference errors
This commit is contained in:
Francisco López 2017-05-19 09:32:19 +02:00 committed by GitHub
commit f2e49864d9
5 changed files with 19 additions and 12 deletions

2
dist/carto.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1779,10 +1779,11 @@ CartoCSS.prototype = {
for(var i = 0; i < defs.length; ++i) { for(var i = 0; i < defs.length; ++i) {
var def = defs[i]; var def = defs[i];
def.toXML(parse_env, {}); if (this.options.strict) {
def.toXML(parse_env, {});
if (this.options.strict && parse_env.errors.message) { if (parse_env.errors.message) {
throw new Error(parse_env.errors.message); throw new Error(parse_env.errors.message);
}
} }
var k = defKey(def); var k = defKey(def);

View File

@ -239,10 +239,11 @@ CartoCSS.prototype = {
for(var i = 0; i < defs.length; ++i) { for(var i = 0; i < defs.length; ++i) {
var def = defs[i]; var def = defs[i];
def.toXML(parse_env, {}); if (this.options.strict) {
def.toXML(parse_env, {});
if (this.options.strict && parse_env.errors.message) { if (parse_env.errors.message) {
throw new Error(parse_env.errors.message); throw new Error(parse_env.errors.message);
}
} }
var k = defKey(def); var k = defKey(def);

View File

@ -0,0 +1,8 @@
var ref = require('./reference.json');
var carto = require('../../lib/carto/index.js');
var ccss = new carto.RendererJS({
reference: ref,
strict: true
}).render("#layer { polygon-fill: #abcdef; }");

View File

@ -124,9 +124,6 @@ describe('RendererJS Strict Mode', function() {
function rendererStrictModeOffTest(RendererJS) { function rendererStrictModeOffTest(RendererJS) {
return function () { return function () {
var shader = RendererJS.render(style); var shader = RendererJS.render(style);
assert.ok(shader.parse_env);
assert.ok(shader.parse_env.errors);
assert.ok(shader.parse_env.errors.message.match(expectedErrorMessageRegex));
assert.ok(shader.layers); assert.ok(shader.layers);
assert.equal(shader.layers.length, 2); assert.equal(shader.layers.length, 2);