Skip to content

Commit

Permalink
Merge pull request #181 from SukkaW/fix-180
Browse files Browse the repository at this point in the history
Fix(#180): exclude "sizes" from attributesWithLists
  • Loading branch information
maltsev committed Apr 2, 2022
2 parents 2a6ad50 + 00e7ac9 commit e4eedd0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/modules/collapseAttributeWhitespace.es6
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ export const attributesWithLists = new Set([
'rel', // a, area, link
'ping', // a, area
'sandbox', // iframe
'sizes', // link
/**
* https://github.com/posthtml/htmlnano/issues/180
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-sizes
*
* "sizes" of <img> should not be modified, while "sizes" of <link> will only have one entry in most cases.
*/
// 'sizes', // link
'headers' // td, th
]);

Expand Down
10 changes: 10 additions & 0 deletions test/modules/sortAttributesWithLists.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ describe('sortAttributesWithLists', () => {
);
});

it('issue #180', () => {
return init(
'<img sizes="(min-width: 300px) 200px, 100px">',
'<img sizes="(min-width: 300px) 200px, 100px">',
{
sortAttributesWithLists: 'alphabetical',
}
);
});

it('frequency', () => {
return init(
'<div class="foo baz bar"></div><div class="bar foo"></div>',
Expand Down

0 comments on commit e4eedd0

Please sign in to comment.