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,11 +1779,12 @@ CartoCSS.prototype = {
for(var i = 0; i < defs.length; ++i) {
var def = defs[i];
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);
}
}
var k = defKey(def);
var layer = layers[k];

View File

@ -239,11 +239,12 @@ CartoCSS.prototype = {
for(var i = 0; i < defs.length; ++i) {
var def = defs[i];
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);
}
}
var k = defKey(def);
var layer = layers[k];

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) {
return function () {
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.equal(shader.layers.length, 2);