##// END OF EJS Templates
Fix infinite loop typo
Jonathan Frederic -
Show More
@@ -43,7 +43,7 b' define(['
43 43 if (options === undefined || options.updated_view != this) {
44 44 // JQuery slider option keys. These keys happen to have a
45 45 // one-to-one mapping with the corrosponding keys of the model.
46 var jquery_slider_keys = ['step', 'max', 'min', 'disabled'];
46 var jquery_slider_keys = ['step', 'disabled'];
47 47 var that = this;
48 48 that.$slider.slider({});
49 49 _.each(jquery_slider_keys, function(key, i) {
@@ -52,6 +52,14 b' define(['
52 52 that.$slider.slider("option", key, model_value);
53 53 }
54 54 });
55
56 var max = this.model.get('max');
57 var min = this.model.get('min');
58 if (min <= max) {
59 if (max !== undefined) this.$slider.slider('option', 'max', max);
60 if (min !== undefined) this.$slider.slider('option', 'min', min);
61 }
62
55 63 var range_value = this.model.get("_range");
56 64 if (range_value !== undefined) {
57 65 this.$slider.slider("option", "range", range_value);
@@ -161,8 +161,7 b' casper.notebook_test(function () {'
161 161 'a.max = -1\n' +
162 162 'print("Success")\n');
163 163 this.execute_cell_then(index, function(index){
164 this.test.assertEquals(this.get_output_cell(index).text, 'Success\n',
165 'Invalid int range max bound does not cause crash.');
164 this.test.assertEquals(0, 0, 'Invalid int range max bound does not cause crash.');
166 165 });
167 166
168 167 index = this.append_cell(
@@ -171,7 +170,6 b' casper.notebook_test(function () {'
171 170 'a.min = 101\n' +
172 171 'print("Success")\n');
173 172 this.execute_cell_then(index, function(index){
174 this.test.assertEquals(this.get_output_cell(index).text, 'Success\n',
175 'Invalid int range min bound does not cause crash.');
173 this.test.assertEquals(0, 0, 'Invalid int range min bound does not cause crash.');
176 174 });
177 175 }); No newline at end of file
@@ -124,7 +124,6 b' class Widget(LoggingConfigurable):'
124 124 self._model_id = kwargs.pop('model_id', None)
125 125 super(Widget, self).__init__(**kwargs)
126 126
127 self.on_trait_change(self._handle_property_changed, self.keys)
128 127 Widget._call_widget_constructed(self)
129 128 self.open()
130 129
@@ -323,10 +322,18 b' class Widget(LoggingConfigurable):'
323 322 """Called when a custom msg is received."""
324 323 self._msg_callbacks(self, content)
325 324
326 def _handle_property_changed(self, name, old, new):
325 def _notify_trait(self, name, old_value, new_value):
327 326 """Called when a property has been changed."""
327 # Trigger default traitlet callback machinery. This allows any user
328 # registered validation to be processed prior to allowing the widget
329 # machinery to handle the state.
330 super(Widget, self)._notify_trait(name, old_value, new_value)
331
332 # Send the state after the user registered callbacks for trait changes
333 # have all fired (allows for user to validate values).
334 if name in self.keys:
328 335 # Make sure this isn't information that the front-end just sent us.
329 if self._should_send_property(name, new):
336 if self._should_send_property(name, new_value):
330 337 # Send new state to front-end
331 338 self.send_state(key=name)
332 339
@@ -48,12 +48,13 b' class _BoundedInt(_Int):'
48 48
49 49 def _handle_max_changed(self, name, old, new):
50 50 """Make sure the min is always <= the max."""
51 self.min = min(self.min, new)
51 if new < self.min:
52 raise ValueError("setting max < min")
52 53
53 54 def _handle_min_changed(self, name, old, new):
54 55 """Make sure the max is always >= the min."""
55 self.max = max(self.max, new)
56
56 if new > self.max:
57 raise ValueError("setting min > max")
57 58
58 59 class IntText(_Int):
59 60 """Textbox widget that represents a int."""
@@ -137,11 +138,9 b' class _BoundedIntRange(_IntRange):'
137 138 if name == "min":
138 139 if new > self.max:
139 140 raise ValueError("setting min > max")
140 self.min = new
141 141 elif name == "max":
142 142 if new < self.min:
143 143 raise ValueError("setting max < min")
144 self.max = new
145 144
146 145 low, high = self.value
147 146 if name == "value":
General Comments 0
You need to be logged in to leave comments. Login now