Skip to content
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