Skip to content

Commit

Permalink
Call renderer when first opened
Browse files Browse the repository at this point in the history
  • Loading branch information
samiheikki committed Aug 30, 2018
1 parent a97bac3 commit fe9560a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 1 addition & 4 deletions src/vaadin-dialog.html
Expand Up @@ -219,10 +219,6 @@

this._oldTemplate = template;
this._oldRenderer = renderer;

if (renderer) {
this.$.overlay.setProperties({owner: this, renderer: renderer});
}
}

disconnectedCallback() {
Expand All @@ -232,6 +228,7 @@

_openedChanged(opened) {
if (opened) {
this.$.overlay.setProperties({owner: this, renderer: this.renderer});
this.$.overlay.template = this.querySelector('template');
}
this.$.overlay.opened = opened;
Expand Down
9 changes: 9 additions & 0 deletions test/vaadin-dialog_renderer-test.html
Expand Up @@ -57,6 +57,15 @@
}).to.throw(Error);
expect(dialog._contentTemplate).to.be.not.ok;
});

it('should not render the content of renderer function if the dialog is not opened', () => {
dialog.renderer = (root, dialog) => {
const div = document.createElement('div');
div.textContent = 'The content of the dialog';
root.appendChild(div);
};
expect(overlay.textContent).to.include('');
});
});

describe('renderer function with template', () => {
Expand Down

0 comments on commit fe9560a

Please sign in to comment.