Skip to content

Conversation

@partic2
Copy link
Contributor

@partic2 partic2 commented May 9, 2025

#703 Fix event.target always null issue

@partic2
Copy link
Contributor Author

partic2 commented May 9, 2025

Seemed CI failed, I'll try to find out the cause later.

@partic2 partic2 changed the title polyfills:make event.target refer to event.currentTarget. polyfills:Implement streamable fetch in request/response, Make event.target refer to event.currentTarget. May 17, 2025
@saghul
Copy link
Owner

saghul commented May 17, 2025

Can you please split the changes into 2 PRs, or at least 2 commits?

@partic2
Copy link
Contributor Author

partic2 commented May 17, 2025

Can you please split the changes into 2 PRs, or at least 2 commits?

Done.
It's just a early version and not tested very well, feel free to test and modify it arbitrarily.

Copy link
Owner

@saghul saghul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did a quick first pass!


function consumed(body) {
if (body._noBody) {
if (body._bodySize===0) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please run the linter? There are a number of style errors in the JS code.

this._bodyReadable = ReadableStream.from([bodyBuffer]);
} else if (isPrototypeOf(URLSearchParams.prototype, body)) {
this._bodyText = body.toString();
const bodyBuffer=new TextEncoder().encode(body);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create a TextEncoder instance and use it for both.

return new Blob(parts);
} else {
return this.blob().then(readBlobAsArrayBuffer);
throw new Error('Unknown body type');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we throw earlier?


xhr.onprogress=function(){
if(controller!=null){
controller.enqueue(new Uint8Array(xhr.__tjsGetAndClearResponseBuffer()));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make this function hidden under some symbol rather than a __ name. Something like xhr[kXhrGetAndClearResponseBuffer]()

})
}else if(request._bodySize===-1){
const reader=request.body.getReader();
xhr.__ontjsstreamsenddata=function(){
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same.

xhr.__ontjsstreamsenddata=function(){
reader.read().then((next)=>{
if(next.done){
xhr.__tjsStreamSend(null);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same.

src/xhr.c Outdated
*/

#include "curl-utils.h"
#include "curl/curl.h"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these includes should be covered by the existing ones, no need to add them explicitly.

JS_FreeValue(ctx, arg);
return;
}

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use make format so clang-format takes care of the styling.

@saghul
Copy link
Owner

saghul commented May 20, 2025

Please don't mix more commits on this PR.

@partic2
Copy link
Contributor Author

partic2 commented May 20, 2025

Please don't mix more commits on this PR.

Ok, I'll learning how to split commit into individual PR later.

@partic2
Copy link
Contributor Author

partic2 commented May 20, 2025

Split into #708 #709 #710

@partic2 partic2 closed this May 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants