Preserve redoc element params after dispose

This commit is contained in:
Roman Hotsiy 2016-01-22 23:30:06 +02:00
parent 3f04192a15
commit 0fb88e99c2

View File

@ -117,6 +117,7 @@ export default class Redoc extends BaseComponent {
static dispose() { static dispose() {
let dom = new BrowserDomAdapter(); let dom = new BrowserDomAdapter();
let el = dom.query('redoc'); let el = dom.query('redoc');
let elClone;
let parent; let parent;
let nextSibling; let nextSibling;
if (el) { if (el) {
@ -124,14 +125,15 @@ export default class Redoc extends BaseComponent {
nextSibling = el.nextElementSibling; nextSibling = el.nextElementSibling;
} }
elClone = el.cloneNode(false);
if (Redoc.appRef) { if (Redoc.appRef) {
Redoc.appRef.dispose(); Redoc.appRef.dispose();
Redoc.appRef = null; Redoc.appRef = null;
// Redoc dispose removes host element, so need to restore it // Redoc dispose removes host element, so need to restore it
el = dom.createElement('redoc'); elClone.innerHTML = 'Loading...';
el.innerText = 'Loading...'; parent && parent.insertBefore(elClone, nextSibling);
parent && parent.insertBefore(el, nextSibling);
} }
} }
} }