Skip to content

Commit

Permalink
fix(mvc.View): set style via options (#2705)
Browse files Browse the repository at this point in the history
  • Loading branch information
kumilingus authored Jul 11, 2024
1 parent 7746050 commit db07082
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/joint-core/src/mvc/ViewBase.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ export var ViewBase = function(options) {
var delegateEventSplitter = /^(\S+)\s*(.*)$/;

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

// Set up all inheritable **ViewBase** properties and methods.
assign(ViewBase.prototype, Events, {
Expand Down
19 changes: 19 additions & 0 deletions packages/joint-core/test/jointjs/mvc.view.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,4 +266,23 @@ QUnit.module('joint.mvc.View', function(hooks) {
view.remove();
});
});

QUnit.module('style', function() {

QUnit.test('as class property', function(assert) {
assert.expect(1);
var View = joint.mvc.View.extend({
style: {
'color': 'red'
}
});
assert.strictEqual(new View().el.style.color, 'red');
});

QUnit.test('as option', function(assert) {
assert.expect(1);
var View = joint.mvc.View.extend();
assert.strictEqual(new View({ style: { 'color': 'red' }}).el.style.color, 'red');
});
});
});

0 comments on commit db07082

Please sign in to comment.