Skip to content

Provide standalone ParseScript wrapper - #7969

Closed
annevk wants to merge 1 commit into
mainfrom
annevk/parse-script
Closed

Provide standalone ParseScript wrapper#7969
annevk wants to merge 1 commit into
mainfrom
annevk/parse-script

Conversation

@annevk

@annevk annevk commented May 31, 2022

Copy link
Copy Markdown
Member

For use by whatwg/fetch#1442.


Writing this up made me consider again whether we can pull in some of the encoding aspects as previously discussed, but I couldn't find a way that works well for all callers of "create a classic script". The main benefit of taking this PR would be that if JavaScript ever changes how this works, we only have to update HTML. Although if the return type changes I suppose we still need to update Fetch...


/webappapis.html ( diff )

@domenic

domenic commented May 31, 2022

Copy link
Copy Markdown
Member

Hmm, I think having Fetch call ParseScript directly seems better. Although I understand the instinct, the part where you basically have an optional argument that takes you down the HTML-path or the Fetch-path makes this feel like not a very worthwhile wrapper.

@annevk

annevk commented May 31, 2022

Copy link
Copy Markdown
Member Author

That's fine too. My PR currently invokes ParseText directly, but I suppose if passing undefined and empty as second and third arguments is reasonable perhaps ParseScript is slightly better so I don't have to take a dependency on goal symbols.

@bakkot @ljharb thoughts?

@domenic

domenic commented May 31, 2022

Copy link
Copy Markdown
Member

IMO it's kind of undesired to pass undefined for the realm argument to ParseScript, even though technically it is just a pass-through. So that's why I like ParseText.

@bakkot

bakkot commented May 31, 2022

Copy link
Copy Markdown
Contributor

ParseScript just invokes ParseText(x, |Script|) and wraps up a couple values into a record, so if you don't want the "construct a record" part it makes more sense invoke ParseText directly, IMO.

@annevk

annevk commented May 31, 2022

Copy link
Copy Markdown
Member Author

Thanks!

@annevk annevk closed this May 31, 2022
@annevk
annevk deleted the annevk/parse-script branch May 31, 2022 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants