Skip to content

Commit ee0dc3c

Browse files
committed
Check if there's a network request already in flight
1 parent 73421ea commit ee0dc3c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/index.ts

+5
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ export default class IncludeFragmentElement extends HTMLElement {
5050
return this.#getData()
5151
}
5252

53+
#busy = false
54+
5355
attributeChangedCallback(attribute: string, oldVal: string | null): void {
5456
if (attribute === 'src') {
5557
// Source changed after attached so replace element.
@@ -132,6 +134,9 @@ export default class IncludeFragmentElement extends HTMLElement {
132134
)
133135

134136
#handleData(): Promise<void> {
137+
if (this.#busy) return Promise.resolve()
138+
this.#busy = true
139+
135140
this.#observer.unobserve(this)
136141
return this.#getData().then(
137142
(html: string) => {

0 commit comments

Comments
 (0)