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
feat(html/minifier): improve the remove_redundant_attributes
option
#6197
Merged
kdy1
merged 5 commits into
swc-project:main
from
alexander-akait:refactor-html-minifier-reducant-attributes
Oct 20, 2022
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
bf65e0e
feat(html/minify): smart mode for redundant attributes
alexander-akait 309febd
chore: fix clippy
alexander-akait b5a9f0a
refactor: impl default
alexander-akait c176d5b
fix: logic
alexander-akait 7c2f82e
Merge branch 'main' into refactor-html-minifier-reducant-attributes
swc-bot File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
crates/swc_html_minifier/tests/fixture/attribute/colspan/output.min.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
crates/swc_html_minifier/tests/fixture/attribute/data/output.min.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<!doctype html><html lang=en><title>Document</title><input class=form-control id={{vm.formInputName}} name={{vm.formInputName}} placeholder=YYYY-MM-DD date-range-picker data-ng-model=vm.value data-ng-model-options="{ debounce: 1000 }" data-ng-pattern=vm.options.format data-options=vm.datepickerOptions> | ||
<!doctype html><html lang=en><title>Document</title><input class=form-control type=text id={{vm.formInputName}} name={{vm.formInputName}} placeholder=YYYY-MM-DD date-range-picker data-ng-model=vm.value data-ng-model-options="{ debounce: 1000 }" data-ng-pattern=vm.options.format data-options=vm.datepickerOptions> |
3 changes: 0 additions & 3 deletions
3
...wc_html_minifier/tests/fixture/attribute/disabled-remove_redundant_attributes/config.json
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
...swc_html_minifier/tests/fixture/attribute/disabled-remove_redundant_attributes/input.html
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
...tml_minifier/tests/fixture/attribute/disabled-remove_redundant_attributes/output.min.html
This file was deleted.
Oops, something went wrong.
8 changes: 4 additions & 4 deletions
8
crates/swc_html_minifier/tests/fixture/attribute/form/output.min.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
<!doctype html><meta charset=utf-8><title>Test</title><form action=handler.php method=post> | ||
<input name=str> | ||
<input type=text name=str> | ||
<input type=submit value=send> | ||
</form> | ||
<form action=handler.php> | ||
<input name=str> | ||
<form action=handler.php method=get> | ||
<input type=text name=str> | ||
<input type=submit value=send> | ||
<input value=foo> | ||
<input type=text value=foo> | ||
<input type=checkbox> | ||
</form> |
2 changes: 1 addition & 1 deletion
2
crates/swc_html_minifier/tests/fixture/attribute/iframe/output.min.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<!doctype html><html lang=en><meta charset=UTF-8><meta name=viewport content="width=device-width,user-scalable=no,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0"><meta http-equiv=X-UA-Compatible content="ie=edge"><title>Document</title><iframe id=test src=test.html></iframe> | ||
<!doctype html><html lang=en><meta charset=UTF-8><meta name=viewport content="width=device-width,user-scalable=no,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0"><meta http-equiv=X-UA-Compatible content="ie=edge"><title>Document</title><iframe id=test src=test.html height=150 width=300 loading=eager fetchpriority=auto referrerpolicy=strict-origin-when-cross-origin></iframe> |
2 changes: 1 addition & 1 deletion
2
crates/swc_html_minifier/tests/fixture/attribute/img/output.min.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<!doctype html><html lang=en><title>Document</title><img src=test.png alt=test> | ||
<!doctype html><html lang=en><title>Document</title><img src=test.png alt=test decoding=auto loading=eager referrerpolicy=strict-origin-when-cross-origin> |
8 changes: 4 additions & 4 deletions
8
crates/swc_html_minifier/tests/fixture/attribute/input/output.min.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<!doctype html><html lang=en><title>Document</title><input name=a> | ||
<input name=b> | ||
<input name=c> | ||
<input name=d> | ||
<!doctype html><html lang=en><title>Document</title><input name=a type=text> | ||
<input name=b type=text> | ||
<input name=c type=text> | ||
<input name=d size=20> |
2 changes: 1 addition & 1 deletion
2
crates/swc_html_minifier/tests/fixture/attribute/javascript-prefix/output.min.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
crates/swc_html_minifier/tests/fixture/attribute/meter/output.min.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<!doctype html><html lang=en><title>Document</title><meter id=fuel max=100 low=33 high=66 optimum=80 value=50> | ||
<!doctype html><html lang=en><title>Document</title><meter id=fuel min=0 max=100 low=33 high=66 optimum=80 value=50> | ||
at 50/100 | ||
</meter> |
4 changes: 2 additions & 2 deletions
4
crates/swc_html_minifier/tests/fixture/attribute/ol/output.min.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
crates/swc_html_minifier/tests/fixture/attribute/progress/output.min.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<!doctype html><html lang=en><title>Document</title><progress></progress> | ||
<!doctype html><html lang=en><title>Document</title><progress max=1></progress> |
3 changes: 3 additions & 0 deletions
3
crates/swc_html_minifier/tests/fixture/attribute/remove_redundant_attributes-all/config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"removeRedundantAttributes": "all" | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Let's implement
Default
for this type instead of using#[serde(default = "")]
.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.
You can then change
#[serde(default = "...")]
to#[serde(default)]