From 7e5cadd3041007d9e81960ca324b8fa803f38091 Mon Sep 17 00:00:00 2001 From: Lucas Garron Date: Fri, 2 Dec 2022 04:44:09 -0800 Subject: [PATCH] Remove a redundant error check. Followup to https://github.com/github/include-fragment-element/pull/87#issuecomment-1335174966 --- src/index.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/index.ts b/src/index.ts index bad1b3a..c1ae7c3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -66,7 +66,7 @@ export default class IncludeFragmentElement extends HTMLElement { // We will return string or error for API backwards compatibility. We can consider // returning TrustedHTML in the future. get data(): Promise { - return this.#getStringOrErrorData() + return this.#getStringData() } #busy = false @@ -118,7 +118,7 @@ export default class IncludeFragmentElement extends HTMLElement { } load(): Promise { - return this.#getStringOrErrorData() + return this.#getStringData() } fetch(request: RequestInfo): Promise { @@ -194,12 +194,8 @@ export default class IncludeFragmentElement extends HTMLElement { } } - async #getStringOrErrorData(): Promise { - const data = await this.#getData() - if (data instanceof Error) { - throw data - } - return data.toString() + async #getStringData(): Promise { + return (await this.#getData()).toString() } // Functional stand in for the W3 spec "queue a task" paradigm