Skip to content

Commit 9177815

Browse files
authored
Preserve old attr type on clearing default. Fixes #1155 (#1156)
1 parent 9660801 commit 9177815

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

src/common/viz/OperationControl.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -187,17 +187,16 @@ define([
187187
OperationControl.prototype.addAttribute = function(opId, name, value) {
188188
var type = 'string';
189189

190-
// Set the defaultValue
191190
if (value === undefined) {
192191
value = null;
193-
}
194-
type = typeof value;
192+
} else { // determine the attribute type
193+
type = typeof value;
195194

196-
// Figure out the type
197-
if (type === 'number') {
198-
type = parseInt(value) === value ? 'integer' : 'float';
195+
// Figure out the type
196+
if (type === 'number') {
197+
type = parseInt(value) === value ? 'integer' : 'float';
198+
}
199199
}
200-
201200
this._client.setAttributeMeta(opId, name, {type: type});
202201
this._client.setAttribute(opId, name, value);
203202
};
@@ -208,8 +207,13 @@ define([
208207
};
209208

210209
OperationControl.prototype.setAttributeDefault = function(opId, name, value) {
211-
this.removeAttribute(opId, name);
212-
this.addAttribute(opId, name, value);
210+
if (value) {
211+
this.removeAttribute(opId, name);
212+
this.addAttribute(opId, name, value);
213+
} else { // just remove the default
214+
value = value !== undefined ? value : null;
215+
this._client.setAttribute(opId, name, value);
216+
}
213217
};
214218

215219
OperationControl.prototype.updateCode = function(fn, nodeId) {

0 commit comments

Comments
 (0)