Skip to content

Commit

Permalink
Update the renderer args order and test for it
Browse files Browse the repository at this point in the history
  • Loading branch information
yuriy-fix committed Jul 16, 2018
1 parent 2d8603a commit 6b56bd0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/vaadin-notification.html
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,12 @@
*
* `owner` The host element of the renderer function.
*
* **NOTE:** The renderer callback can be called several times with previous content available
* `model` null
*
* **NOTE:** The renderer callback can be called several times with previous content when available.
*
* **NOTE:** `notification` does not have any specific properties to pass with the `model` object,
* it is set to null.
*/
renderer: {
type: Function,
Expand Down Expand Up @@ -392,7 +397,7 @@
}

if (renderer) {
this.renderer(this._card, this);
this.renderer(this._card, this, null);
} else {
this._ensureTemplatized();
}
Expand Down
7 changes: 5 additions & 2 deletions test/notification-renderer-test.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,11 @@
expect(notification._card.textContent.trim()).to.equal('renderer-content');
});

it('renderer should receive notification as owner when it is defined', () => {
notification.renderer = (root, owner) => expect(owner).to.eql(notification);
it('renderer should receive notification as owner and null as model when defined', () => {
notification.renderer = (root, owner, model) => {
expect(owner).to.eql(notification);
expect(model).to.eql(null);
};
});

it('should use only renderer when template was assigned after renderer', done => {
Expand Down

0 comments on commit 6b56bd0

Please sign in to comment.