Skip to content

Commit

Permalink
Remove a redundant error check.
Browse files Browse the repository at this point in the history
Followup to #87 (comment)
  • Loading branch information
lgarron committed Dec 2, 2022
1 parent 5dfb899 commit 7e5cadd
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> {
return this.#getStringOrErrorData()
return this.#getStringData()
}

#busy = false
Expand Down Expand Up @@ -118,7 +118,7 @@ export default class IncludeFragmentElement extends HTMLElement {
}

load(): Promise<string> {
return this.#getStringOrErrorData()
return this.#getStringData()
}

fetch(request: RequestInfo): Promise<Response> {
Expand Down Expand Up @@ -194,12 +194,8 @@ export default class IncludeFragmentElement extends HTMLElement {
}
}

async #getStringOrErrorData(): Promise<string> {
const data = await this.#getData()
if (data instanceof Error) {
throw data
}
return data.toString()
async #getStringData(): Promise<string> {
return (await this.#getData()).toString()
}

// Functional stand in for the W3 spec "queue a task" paradigm
Expand Down

0 comments on commit 7e5cadd

Please sign in to comment.