Permit keywords as strings. Fixes #193

This commit is contained in:
Tom MacWright 2012-10-08 18:28:27 -04:00
parent 4b7fc5fb57
commit 1d9b5d93ca
4 changed files with 49 additions and 3 deletions

View File

@ -136,9 +136,17 @@ tree.Reference.validValue = function(env, selector, value) {
if (!tree.Reference.selector(selector)) {
return false;
} else if (value.value[0].is == 'keyword') {
return tree.Reference
.selector(selector).type
.indexOf(value.value[0].value) !== -1;
if (typeof tree.Reference.selector(selector).type === 'object') {
return tree.Reference
.selector(selector).type
.indexOf(value.value[0].value) !== -1;
// Lax permissions for single strings. If you provide a keyword
// aka unquoted string to a property that is a string, it'll be fine.
} else if (tree.Reference.selector(selector).type === 'string') {
return true;
} else {
return false;
}
} else if (value.value[0].is == 'undefined') {
// caught earlier in the chain - ignore here so that
// error is not overridden

View File

@ -0,0 +1,14 @@
{
"srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over",
"Stylesheet": [
"noquote_font.mss"
],
"Layer": [{
"name": "world",
"srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over",
"Datasource": {
"file": "http://tilemill-data.s3.amazonaws.com/test_data/shape_demo.zip",
"type": "shape"
}
}]
}

View File

@ -0,0 +1,4 @@
#world {
text-name: 'foo';
text-face-name: Helvetica;
}

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE Map[]>
<Map srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over" maximum-extent="-20037508.34,-20037508.34,20037508.34,20037508.34">
<Style name="world" filter-mode="first" >
<Rule>
<TextSymbolizer face-name="Helvetica" ><![CDATA[foo]]></TextSymbolizer>
</Rule>
</Style>
<Layer name="world"
srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over">
<StyleName>world</StyleName>
<Datasource>
<Parameter name="file"><![CDATA[[absolute path]]]></Parameter>
<Parameter name="type"><![CDATA[shape]]></Parameter>
</Datasource>
</Layer>
</Map>