Skip to content

Commit db07082

Browse files
authored
fix(mvc.View): set style via options (#2705)
1 parent 7746050 commit db07082

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

packages/joint-core/src/mvc/ViewBase.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ export var ViewBase = function(options) {
3535
var delegateEventSplitter = /^(\S+)\s*(.*)$/;
3636

3737
// List of view options to be set as properties.
38-
var viewOptions = ['model', 'collection', 'el', 'id', 'attributes', 'className', 'tagName', 'events'];
38+
// TODO: `style` attribute is not supported in ViewBase class yet, but only in View class that extends ViewBase.
39+
var viewOptions = ['model', 'collection', 'el', 'id', 'attributes', 'className', 'tagName', 'events', 'style'];
3940

4041
// Set up all inheritable **ViewBase** properties and methods.
4142
assign(ViewBase.prototype, Events, {

packages/joint-core/test/jointjs/mvc.view.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,4 +266,23 @@ QUnit.module('joint.mvc.View', function(hooks) {
266266
view.remove();
267267
});
268268
});
269+
270+
QUnit.module('style', function() {
271+
272+
QUnit.test('as class property', function(assert) {
273+
assert.expect(1);
274+
var View = joint.mvc.View.extend({
275+
style: {
276+
'color': 'red'
277+
}
278+
});
279+
assert.strictEqual(new View().el.style.color, 'red');
280+
});
281+
282+
QUnit.test('as option', function(assert) {
283+
assert.expect(1);
284+
var View = joint.mvc.View.extend();
285+
assert.strictEqual(new View({ style: { 'color': 'red' }}).el.style.color, 'red');
286+
});
287+
});
269288
});

0 commit comments

Comments
 (0)