@@ -65,18 +65,20 @@ module.exports = {
65
65
overrideAll : overrideAll
66
66
} ;
67
67
68
- /*
68
+ /**
69
69
* For attributes that are largely copied from elsewhere into a plot type that doesn't
70
70
* support partial redraws - overrides the editType field of all attributes in the object
71
71
*
72
72
* @param {object } attrs: the attributes to override. Will not be mutated.
73
73
* @param {string } editTypeOverride: the new editType to use
74
- * @param {bool|'nested' } overrideContainers: should we override editType for containers or just
75
- * `valObject`s? 'nested' will override editType for all but the top level. Containers below
76
- * the absolute top level (trace or layout root) DO need an editType, to handle the case
77
- * where you edit the whole container, but in some cases you want to provide it explicitly
78
- * as it may be more expansive than the attribute editTypes, since you don't know if there
79
- * is a data array in the container (which if provided directly triggers an automatic docalc)
74
+ * @param {'nested'|'from-root' } overrideContainers:
75
+ * - 'nested' will override editType for nested containers but not the root.
76
+ * - 'from-root' will also override editType of the root container.
77
+ * Containers below the absolute top level (trace or layout root) DO need an
78
+ * editType even if they are not `valObject`s themselves (eg `scatter.marker`)
79
+ * to handle the case where you edit the whole container.
80
+ *
81
+ * @return {object } a new attributes object with `editType` modified as directed
80
82
*/
81
83
function overrideAll ( attrs , editTypeOverride , overrideContainers ) {
82
84
var out = extendFlat ( { } , attrs ) ;
@@ -86,7 +88,7 @@ function overrideAll(attrs, editTypeOverride, overrideContainers) {
86
88
out [ key ] = overrideOne ( attr , editTypeOverride , overrideContainers , key ) ;
87
89
}
88
90
}
89
- if ( overrideContainers === true ) out . editType = editTypeOverride ;
91
+ if ( overrideContainers === 'from-root' ) out . editType = editTypeOverride ;
90
92
91
93
return out ;
92
94
}
@@ -99,14 +101,14 @@ function overrideOne(attr, editTypeOverride, overrideContainers, key) {
99
101
if ( Array . isArray ( attr . items ) ) {
100
102
out . items = new Array ( attr . items . length ) ;
101
103
for ( var i = 0 ; i < attr . items . length ; i ++ ) {
102
- out . items [ i ] = overrideOne ( attr . items [ i ] , editTypeOverride , ! ! overrideContainers ) ;
104
+ out . items [ i ] = overrideOne ( attr . items [ i ] , editTypeOverride , 'from-root' ) ;
103
105
}
104
106
}
105
107
return out ;
106
108
}
107
109
else {
108
110
// don't provide an editType for the _deprecated container
109
111
return overrideAll ( attr , editTypeOverride ,
110
- ( key . charAt ( 0 ) === '_' ) ? overrideContainers && 'nested' : ! ! overrideContainers ) ;
112
+ ( key . charAt ( 0 ) === '_' ) ? 'nested' : 'from-root' ) ;
111
113
}
112
114
}
0 commit comments