Skip to content

Commit

Permalink
Allow raw response text to be read from event listeners
Browse files Browse the repository at this point in the history
 response.text() cannot be called twice without cloning first. Since we're calling it without cloning the response,
 we are making the raw text inaccessible to event listeners that want to access the response data, so let's cache the text we've read.
  • Loading branch information
justisr committed Oct 27, 2024
1 parent 3346d14 commit a253a83
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ async function send(control, action = '', method = 'GET', body = null, enctype =
let text = await response.text()
let wrapper = document.createRange().createContextualFragment('<template>' + text + '</template>')
response.html = wrapper.firstElementChild.content

response.raw = text
return response
})

Expand Down

0 comments on commit a253a83

Please sign in to comment.