Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove a redundant error check. #89

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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