flow like the river
This commit is contained in:
commit
013fe673f3
42435 changed files with 5764238 additions and 0 deletions
32
BACK_BACK/node_modules/htmlnano/lib/modules/collapseAttributeWhitespace.js
generated
vendored
Executable file
32
BACK_BACK/node_modules/htmlnano/lib/modules/collapseAttributeWhitespace.js
generated
vendored
Executable file
|
|
@ -0,0 +1,32 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = collapseAttributeWhitespace;
|
||||
exports.attributesWithLists = void 0;
|
||||
const attributesWithLists = new Set(['class', 'rel', 'ping']);
|
||||
/** Collapse whitespaces inside list-like attributes (e.g. class, rel) */
|
||||
|
||||
exports.attributesWithLists = attributesWithLists;
|
||||
|
||||
function collapseAttributeWhitespace(tree) {
|
||||
tree.walk(node => {
|
||||
if (!node.attrs) {
|
||||
return node;
|
||||
}
|
||||
|
||||
Object.entries(node.attrs).forEach(([attrName, attrValue]) => {
|
||||
const attrNameLower = attrName.toLowerCase();
|
||||
|
||||
if (!attributesWithLists.has(attrNameLower)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const newAttrValue = attrValue.replace(/\s+/g, ' ').trim();
|
||||
node.attrs[attrName] = newAttrValue;
|
||||
});
|
||||
return node;
|
||||
});
|
||||
return tree;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue