Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Enable styling via class attribute in ListItemView.
Browse files Browse the repository at this point in the history
  • Loading branch information
oleq committed Mar 9, 2017
1 parent e42cf46 commit ba075e4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/list/listitemview.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ export default class ListItemView extends View {

attributes: {
class: [
'ck-list__item'
'ck-list__item',
bind.to( 'class' )
],
style: bind.to( 'style' ),
tabindex: bind.to( 'tabindex' )
Expand Down Expand Up @@ -69,6 +70,13 @@ export default class ListItemView extends View {
* @member {String} #style
*/

/**
* (Optional) The additional class set on the {@link #element}.
*
* @observable
* @member {String} #class
*/

/**
* Fired when the list item has been clicked.
*
Expand Down
10 changes: 10 additions & 0 deletions tests/list/listitemview.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ describe( 'ListItemView', () => {
} );

describe( 'DOM bindings', () => {
describe( '"class" attribute', () => {
it( 'reacts on view#class', () => {
expect( view.element.classList ).to.have.length( 1 );

view.set( 'class', 'foo' );

expect( view.element.classList.contains( 'foo' ) ).to.be.true;
} );
} );

describe( '"style" attribute', () => {
it( 'reacts on view#style', () => {
expect( view.element.attributes.getNamedItem( 'style' ).value ).to.equal( 'foo' );
Expand Down

0 comments on commit ba075e4

Please sign in to comment.