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