Adding a keepData option to formats. If true, formats will be given a reference to the parsed data (named data) after a read. Use this when you need to access part of the structure that was not extracted in creating features (for example). Note that for versioned parsers, the data property is available on format.parser.data. Thanks for the patch sky. r=me (closes #1753)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@8924 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -34,6 +34,18 @@
|
||||
t.eq(data, obj, "writing data to json works.");
|
||||
}
|
||||
|
||||
|
||||
function test_keepData(t) {
|
||||
t.plan(2);
|
||||
|
||||
var options = {'keepData': true};
|
||||
var format = new OpenLayers.Format.JSON(options);
|
||||
format.read('{"a":["b"], "c":1}');
|
||||
|
||||
t.ok(format.data != null, 'data property is not null after read with keepData=true');
|
||||
t.eq(format.data.c,1,'keepData keeps the right data');
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -668,6 +668,17 @@
|
||||
|
||||
}
|
||||
|
||||
function test_keepData(t) {
|
||||
t.plan(2);
|
||||
|
||||
var options = {'keepData': true};
|
||||
var format = new OpenLayers.Format.XML(options);
|
||||
format.read(text);
|
||||
|
||||
t.ok(format.data != null, 'data property is not null after read with keepData=true');
|
||||
t.eq(format.data.documentElement.tagName,'ol:root','keepData keeps the right data');
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
Reference in New Issue
Block a user