Skip to content
This repository was archived by the owner on Nov 2, 2023. It is now read-only.

Commit 3cc330c

Browse files
authored
Merge pull request #161 from clint-tseng/cxlt/159
ui/bug #159: more NPE/false-assumption bugs with successor logic.
2 parents 918b1f6 + 9673385 commit 3cc330c

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

public/javascripts/control.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
_.each(properties, function(property)
111111
{
112112
if (property.bindControlClass != null)
113-
$this.toggleClass(property.bindControlClass, property.value !== false);
113+
$this.toggleClass(property.bindControlClass, ((property.value != null) && (property.value !== false)));
114114
});
115115

116116
// SPECIAL CASE:

public/javascripts/property-editor.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -229,15 +229,16 @@
229229
var $select = $editor.find('select');
230230
var update = function()
231231
{
232-
$enable.attr('checked', property.value !== false);
233-
$select.attr('disabled', property.value === false);
232+
var value = (property.value == null) ? false : property.value;
233+
$enable.attr('checked', value);
234+
$select.attr('disabled', value);
234235
updateOptions();
235236
};
236237

237238
var updateOptions = function()
238239
{
239240
var $options = $select.find('option').detach();
240-
var selectedValue = property.value[0]; // default to the saved value.
241+
var selectedValue = (property.value == null) ? undefined : property.value[0]; // default to the saved value.
241242

242243
_.each(optionsProperty.value, function(option)
243244
{
@@ -246,15 +247,15 @@
246247
selectedValue = option.val;
247248

248249
// on the other hand, if we have no ref yet and we match, grab the ref.
249-
if ((selectedOption == null) && (property.value[0] === option.val))
250+
if ((selectedOption == null) && (selectedValue === option.val))
250251
selectedOption = option;
251252

252253
var existing = _.find($options, function(dom) { return $(dom).data('option') === option; });
253254
existing = (existing == null) ? $('<option/>').data('option', option) : $(existing);
254255
$select.append(existing.text(option.val).attr('value', option.val));
255256
});
256257

257-
if (property.value !== false)
258+
if ((property.value !== false) && (property.value != null))
258259
{
259260
if (selectedValue != null)
260261
{

0 commit comments

Comments
 (0)