From d31da4a0ecba434ce11efb5e4d2a7d1ea81390b0 Mon Sep 17 00:00:00 2001 From: Andrew Bastin Date: Mon, 22 Jun 2020 03:36:34 -0400 Subject: [PATCH 1/3] Removed redundant HTML response type check for preview code --- .../lenses/renderers/HTMLLensRenderer.vue | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/components/lenses/renderers/HTMLLensRenderer.vue b/components/lenses/renderers/HTMLLensRenderer.vue index dc050b0a7..20438ce43 100644 --- a/components/lenses/renderers/HTMLLensRenderer.vue +++ b/components/lenses/renderers/HTMLLensRenderer.vue @@ -151,23 +151,18 @@ export default { togglePreview() { this.previewEnabled = !this.previewEnabled if (this.previewEnabled) { - // If you want to add 'preview' support for other response types, - // just add them here. - if (this.responseType === "text/html") { - // If the preview already has that URL loaded, let's not bother re-loading it all. - if (this.$refs.previewFrame.getAttribute("data-previewing-url") === this.url) return - // Use DOMParser to parse document HTML. - const previewDocument = new DOMParser().parseFromString( - this.responseBodyText, - this.responseType - ) - // Inject tag to head, to fix relative CSS/HTML paths. - previewDocument.head.innerHTML = - `` + previewDocument.head.innerHTML - // Finally, set the iframe source to the resulting HTML. - this.$refs.previewFrame.srcdoc = previewDocument.documentElement.outerHTML - this.$refs.previewFrame.setAttribute("data-previewing-url", this.url) - } + if (this.$refs.previewFrame.getAttribute("data-previewing-url") === this.url) return + // Use DOMParser to parse document HTML. + const previewDocument = new DOMParser().parseFromString( + this.responseBodyText, + this.responseType + ) + // Inject tag to head, to fix relative CSS/HTML paths. + previewDocument.head.innerHTML = + `` + previewDocument.head.innerHTML + // Finally, set the iframe source to the resulting HTML. + this.$refs.previewFrame.srcdoc = previewDocument.documentElement.outerHTML + this.$refs.previewFrame.setAttribute("data-previewing-url", this.url) } }, }, From a41b6be1855dbc2b21ce719fcac1a446af8ecd54 Mon Sep 17 00:00:00 2001 From: Andrew Bastin Date: Mon, 22 Jun 2020 04:31:55 -0400 Subject: [PATCH 2/3] Don't run the response lenses if the body is the loading text --- pages/index.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/index.vue b/pages/index.vue index c03949fec..2c437939a 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -952,7 +952,7 @@ /> -
+