Skip to content

Commit

Permalink
Update demos and root clearing logic
Browse files Browse the repository at this point in the history
  • Loading branch information
yuriy-fix committed Nov 8, 2018
1 parent 639770b commit 31b4e5a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 9 additions & 0 deletions demo/notification-basic-demos.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ <h3>Simple Notification</h3>
});

notification.renderer = function(root) {
// Check if there is a content generated with the previous renderer call not to recreate it.
if (root.firstElementChild) {
return;
}

const container = window.document.createElement('div');
const boldText = window.document.createElement('b');
boldText.textContent = 'Notice';
Expand Down Expand Up @@ -98,6 +103,10 @@ <h3>Action</h3>
});

notification.renderer = function(root, owner) {
if (root.firstElementChild) {
return;
}

const plainText = window.document.createTextNode('Can\'t send message.');
const retryBtn = window.document.createElement('vaadin-button');

Expand Down
4 changes: 3 additions & 1 deletion src/vaadin-notification.html
Original file line number Diff line number Diff line change
Expand Up @@ -359,12 +359,14 @@
}

this._oldTemplate = template;

const rendererChanged = this._oldRenderer !== renderer;
this._oldRenderer = renderer;

if (renderer) {
this._card = this.$['vaadin-notification-card'];

while (this._card.firstChild) {
while (this._card.firstChild && rendererChanged) {
this._card.removeChild(this._card.firstChild);
}

Expand Down

0 comments on commit 31b4e5a

Please sign in to comment.