Skip to content

Commit 7a7dc6d

Browse files
committed
let PlotSchema.crawl report the complete attribute string
1 parent e895b32 commit 7a7dc6d

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/plot_api/plot_schema.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,23 +100,31 @@ exports.get = function() {
100100
* The decision to not use callback return values for controlling tree pruning arose from
101101
* the goal of keeping the crawler backwards compatible. Observe that one of the pruning conditions
102102
* precedes the callback call.
103+
* @param {string} [attrString]
104+
* the path to the current attribute, as an attribute string (ie 'marker.line')
105+
* typically unsupplied, but you may supply it if you want to disambiguate which attrs tree you
106+
* are starting from
103107
*
104108
* @return {object} transformOut
105109
* copy of transformIn that contains attribute defaults
106110
*/
107-
exports.crawl = function(attrs, callback, specifiedLevel) {
111+
exports.crawl = function(attrs, callback, specifiedLevel, attrString) {
108112
var level = specifiedLevel || 0;
113+
attrString = attrString || '';
109114

110115
Object.keys(attrs).forEach(function(attrName) {
111116
var attr = attrs[attrName];
112117

113118
if(UNDERSCORE_ATTRS.indexOf(attrName) !== -1) return;
114119

115-
callback(attr, attrName, attrs, level);
120+
var fullAttrString = (attrString ? attrString + '.' : '') + attrName;
121+
callback(attr, attrName, attrs, level, fullAttrString);
116122

117123
if(exports.isValObject(attr)) return;
118124

119-
if(Lib.isPlainObject(attr)) exports.crawl(attr, callback, level + 1);
125+
if(Lib.isPlainObject(attr)) {
126+
exports.crawl(attr, callback, level + 1, fullAttrString);
127+
}
120128
});
121129
};
122130

0 commit comments

Comments
 (0)