@@ -114,30 +114,23 @@ function npGet(cont, parts) {
114
114
} ;
115
115
}
116
116
117
- /*
118
- * Check known non-data-array arrays (containers). Data arrays only contain scalars,
119
- * so parts[end] values, such as -1 or n, indicate we are not dealing with a dataArray.
120
- * The ONLY case we are looking for is where the entire array is selected, parts[end] === 'x'
121
- * AND the replacement value is an array.
122
- */
123
- // function isNotAContainer(key) {
124
- // var containers = ['annotations', 'shapes', 'range', 'domain', 'buttons'];
125
-
126
- // return containers.indexOf(key) === -1;
127
- // }
128
-
129
117
/*
130
118
* Can this value be deleted? We can delete any empty object (null, undefined, [], {})
131
- * EXCEPT empty data arrays. If it's not a data array, it's a container array,
132
- * ie containing objects like annotations, buttons, etc
119
+ * EXCEPT empty data arrays. Info arrays can be safely deleted, but not deleting them
120
+ * has no ill effects other than leaving a trace or layout object with some cruft in it.
121
+ * But deleting data arrays can change the meaning of the object, as `[]` means there is
122
+ * data for this attribute, it's just empty right now while `undefined` means the data
123
+ * should be filled in with defaults to match other data arrays. So we do some simple
124
+ * tests here to find known non-data arrays but don't worry too much about not deleting
125
+ * some arrays that would actually be safe to delete.
133
126
*/
134
- var DOMAIN_RANGE = / ( ^ | .) ( d o m a i n | r a n g e ) $ / ;
127
+ var INFO_PATTERNS = / ( ^ | .) ( ( d o m a i n | r a n g e ) ( \. [ x y ] ) ? | a r g s | p a r a l l e l s ) $ / ;
135
128
function isDeletable ( val , propStr ) {
136
129
if ( ! emptyObj ( val ) ) return false ;
137
130
if ( ! isArray ( val ) ) return true ;
138
131
139
132
// domain and range are special - they show up in lots of places so hard code here.
140
- if ( propStr . match ( DOMAIN_RANGE ) ) return true ;
133
+ if ( propStr . match ( INFO_PATTERNS ) ) return true ;
141
134
142
135
var match = containerArrayMatch ( propStr ) ;
143
136
// if propStr matches the container array itself, index is an empty string
0 commit comments