Allow optional initial values to be passed to ol.Object

This commit is contained in:
Tom Payne
2012-07-10 16:56:28 +02:00
committed by Tom Payne
parent 5a7c2e72a6
commit defffdada8
2 changed files with 11 additions and 1 deletions

View File

@@ -32,9 +32,13 @@ ol.ObjectProperty = {
/**
* @constructor
* @extends {goog.events.EventTarget}
* @param {Object.<string, *>=} opt_values Values.
*/
ol.Object = function() {
ol.Object = function(opt_values) {
goog.base(this);
if (goog.isDef(opt_values)) {
this.setValues(opt_values);
}
};
goog.inherits(ol.Object, goog.events.EventTarget);

View File

@@ -448,3 +448,9 @@ function testCreateFromObject() {
var obj2 = ol.Object.create(obj1);
assertTrue(obj2 === obj1);
}
function testCreateWithOptions() {
var obj = new ol.Object({k: 1});
assertEquals(1, obj.get('k'));
}