-
-
Notifications
You must be signed in to change notification settings - Fork 94
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
perf: template abbreviation of end tag #166
Comments
Could you please create a PR for your code, so that we can discuss some details conveniently? |
I added some unit tests for your reference. |
|
related #112
I've been working on optimizing the abbreviation of end tags in templates and would greatly appreciate it if you could review my solution at your convenience.So there is my solution:
Take the HTML code
<div><span></span></div>
as an example. The parsing mechanism sequentially executes handling (<div
,<span
) and closing (</
) actions. My optimization's primary objective is to leverage self-closing tags whenever feasible, especially for the sequence's terminal element.My strategy unfolds in two steps:
close
action directly follows ahandle
action, identified bythis.currentStage === 'stateInTagName'
. When this condition is met, we flag the current Node withisShouldSelfClosing
. This flag is later used during thetransformElement
phase to implement the optimization. If the condition isn't met, we don't set the flag.currentStage
attribute to accurately represent the ongoing parsing phase, thus accommodating various tag processing scenarios.here is some draft code
I've integrated the
isShouldSelfClosing
flag into the standard Node structure and have made the necessary updates intokenizer.ts
. However, I'm uncertain if this is the best approach.Any feedback or advice you could offer on this strategy would be incredibly valuable to me~~
ps:code is in https://github.com/CathLee/core-vapor/tree/transform/close_tag
The text was updated successfully, but these errors were encountered: