@@ -65,18 +65,20 @@ module.exports = {
6565 overrideAll : overrideAll
6666} ;
6767
68- /*
68+ /**
6969 * For attributes that are largely copied from elsewhere into a plot type that doesn't
7070 * support partial redraws - overrides the editType field of all attributes in the object
7171 *
7272 * @param {object } attrs: the attributes to override. Will not be mutated.
7373 * @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
8082 */
8183function overrideAll ( attrs , editTypeOverride , overrideContainers ) {
8284 var out = extendFlat ( { } , attrs ) ;
@@ -86,7 +88,7 @@ function overrideAll(attrs, editTypeOverride, overrideContainers) {
8688 out [ key ] = overrideOne ( attr , editTypeOverride , overrideContainers , key ) ;
8789 }
8890 }
89- if ( overrideContainers === true ) out . editType = editTypeOverride ;
91+ if ( overrideContainers === 'from-root' ) out . editType = editTypeOverride ;
9092
9193 return out ;
9294}
@@ -99,14 +101,14 @@ function overrideOne(attr, editTypeOverride, overrideContainers, key) {
99101 if ( Array . isArray ( attr . items ) ) {
100102 out . items = new Array ( attr . items . length ) ;
101103 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' ) ;
103105 }
104106 }
105107 return out ;
106108 }
107109 else {
108110 // don't provide an editType for the _deprecated container
109111 return overrideAll ( attr , editTypeOverride ,
110- ( key . charAt ( 0 ) === '_' ) ? overrideContainers && 'nested' : ! ! overrideContainers ) ;
112+ ( key . charAt ( 0 ) === '_' ) ? 'nested' : 'from-root' ) ;
111113 }
112114}
0 commit comments