-
-
Notifications
You must be signed in to change notification settings - Fork 793
feat(core): offset parsing #6652
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Parser conformance results onjs/262
jsx/babel
symbols/microsoft
ts/babel
ts/microsoft
|
028bc3d to
eedab2b
Compare
CodSpeed Performance ReportMerging #6652 will not alter performanceComparing Summary
|
arendjr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sweet!
|
|
||
| // Walk through all HTML elements looking for script tags | ||
| for element in html_root.syntax().descendants() { | ||
| let Some(html_element) = HtmlElement::cast(element.clone()) else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: If we put the entire inner body for the loop inside of a separate extract_embedded_script() function (note it's singular), I believe we can get rid of all these continue statements, and the extra indentation of the last if statement may be avoidable too.
Also, I guess HtmlElement::cast_ref() is a better choice here?
| if matches!(file_source, DocumentFileSource::Html(_)) { | ||
| if let Some(Ok(any_parse)) = &syntax { | ||
| if let Some(html_root) = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it's time for Rust 1.88's let chains :D
Summary
Part of #6657
This PR introduces two new parsing strategies for JS and CSS, allowing us to parse a document and set an offset. These parsing strategies are useful for supporting JavaScript and CSS inside HTML documents and keeping the same text range of the original content.
The PR also adds a potential solution for storing the information. The
Documenttype, insidebiome_servicenow stores new types calledSendJsEmbeddedParseandSendCssEmbeddedParse. These types are strongly typed,SyncandSendnodes of new types calledJsOffsetParseandCssOffsetParseInternally, these
Send*types use the new typeEmbeddedSendNode, which stores the offset.Test Plan
Added new tests