context can now be given as argument in StyleMap.addUniqueValueRules()

this, for example, allows user to access to properties that are not part of the feature attributes.
r=elemoine (closes #1548)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@7216 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
pgiraud
2008-05-19 13:34:35 +00:00
parent 34ff282397
commit 815e55888a
4 changed files with 77 additions and 2 deletions
+27
View File
@@ -13,6 +13,33 @@
t.eq(rule.foo, "bar", "constructor sets options correctly");
t.eq(typeof rule.evaluate, "function", "rule has an evaluate function");
}
function test_Rule_getContext(t) {
t.plan(2);
var rule, options;
var feature = {
attributes: {
'dude': 'hello'
},
'foobar': 'world'
}
rule = new OpenLayers.Rule();
var context = rule.getContext(feature);
t.eq(context.dude, "hello", "value returned by getContext is correct"
+ " if no context is specified");
var options = {
context: function(feature){
return feature;
}
};
rule = new OpenLayers.Rule(options);
var context = rule.getContext(feature);
t.eq(context.foobar, "world", "value returned by getContext is correct"
+ " if a context is given in constructor options");
}
function test_Rule_destroy(t) {
t.plan(1);