@@ -100,23 +100,31 @@ exports.get = function() {
100
100
* The decision to not use callback return values for controlling tree pruning arose from
101
101
* the goal of keeping the crawler backwards compatible. Observe that one of the pruning conditions
102
102
* 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
103
107
*
104
108
* @return {object } transformOut
105
109
* copy of transformIn that contains attribute defaults
106
110
*/
107
- exports . crawl = function ( attrs , callback , specifiedLevel ) {
111
+ exports . crawl = function ( attrs , callback , specifiedLevel , attrString ) {
108
112
var level = specifiedLevel || 0 ;
113
+ attrString = attrString || '' ;
109
114
110
115
Object . keys ( attrs ) . forEach ( function ( attrName ) {
111
116
var attr = attrs [ attrName ] ;
112
117
113
118
if ( UNDERSCORE_ATTRS . indexOf ( attrName ) !== - 1 ) return ;
114
119
115
- callback ( attr , attrName , attrs , level ) ;
120
+ var fullAttrString = ( attrString ? attrString + '.' : '' ) + attrName ;
121
+ callback ( attr , attrName , attrs , level , fullAttrString ) ;
116
122
117
123
if ( exports . isValObject ( attr ) ) return ;
118
124
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
+ }
120
128
} ) ;
121
129
} ;
122
130
0 commit comments