summaryrefslogtreecommitdiff
path: root/node_modules/svgo/plugins/inlineStyles.js
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2024-01-04 11:07:54 +0800
committerlittleblack111 <littleblack11111@gmail.com>2024-01-04 11:07:54 +0800
commit275f9dc0bdf3e58aa36b800f55f8648fbc55d8af (patch)
tree81c7cf120fb703cfd5e3162f2366033d9fe5c7f8 /node_modules/svgo/plugins/inlineStyles.js
parent2b4ab36917baef56c7ce1602966f941be15af785 (diff)
upgrade
Diffstat (limited to 'node_modules/svgo/plugins/inlineStyles.js')
-rw-r--r--node_modules/svgo/plugins/inlineStyles.js42
1 files changed, 23 insertions, 19 deletions
diff --git a/node_modules/svgo/plugins/inlineStyles.js b/node_modules/svgo/plugins/inlineStyles.js
index 1cdcebe7..e09988de 100644
--- a/node_modules/svgo/plugins/inlineStyles.js
+++ b/node_modules/svgo/plugins/inlineStyles.js
@@ -7,7 +7,6 @@
const csstree = require('css-tree');
const {
- // @ts-ignore internal api
syntax: { specificity },
} = require('csso');
const {
@@ -51,16 +50,16 @@ exports.fn = (root, params) => {
} = params;
/**
- * @type {Array<{ node: XastElement, parentNode: XastParent, cssAst: csstree.StyleSheet }>}
+ * @type {{ node: XastElement, parentNode: XastParent, cssAst: csstree.StyleSheet }[]}
*/
const styles = [];
/**
- * @type {Array<{
+ * @type {{
* node: csstree.Selector,
* item: csstree.ListItem<csstree.CssNode>,
* rule: csstree.Rule,
- * matchedElements?: Array<XastElement>
- * }>}
+ * matchedElements?: XastElement[]
+ * }[]}
*/
let selectors = [];
@@ -123,10 +122,10 @@ exports.fn = (root, params) => {
node.prelude.children.forEach((childNode, item) => {
if (childNode.type === 'Selector') {
/**
- * @type {Array<{
+ * @type {{
* item: csstree.ListItem<csstree.CssNode>,
* list: csstree.List<csstree.CssNode>
- * }>}
+ * }[]}
*/
const pseudos = [];
@@ -145,13 +144,13 @@ exports.fn = (root, params) => {
list: grandchildList,
});
}
- }
+ },
);
const pseudoSelectors = csstree.generate({
type: 'Selector',
children: new csstree.List().fromArray(
- pseudos.map((pseudo) => pseudo.item.data)
+ pseudos.map((pseudo) => pseudo.item.data),
),
});
@@ -187,7 +186,7 @@ exports.fn = (root, params) => {
for (const selector of sortedSelectors) {
// match selectors
const selectorText = csstree.generate(selector.item.data);
- /** @type {Array<XastElement>} */
+ /** @type {XastElement[]} */
const matchedElements = [];
try {
for (const node of querySelectorAll(root, selectorText)) {
@@ -216,7 +215,7 @@ exports.fn = (root, params) => {
{
context: 'declarationList',
parseValue: false,
- }
+ },
);
if (styleDeclarationList.type !== 'DeclarationList') {
continue;
@@ -247,9 +246,9 @@ exports.fn = (root, params) => {
const property = ruleDeclaration.property;
if (
- attrsGroups.presentation.includes(property) &&
+ attrsGroups.presentation.has(property) &&
!selectors.some((selector) =>
- includesAttrSelector(selector.item, property)
+ includesAttrSelector(selector.item, property),
)
) {
delete selectedEl.attributes[property];
@@ -261,7 +260,7 @@ exports.fn = (root, params) => {
if (matchedItem == null) {
styleDeclarationList.children.insert(
ruleDeclarationItem,
- firstListItem
+ firstListItem,
);
} else if (
matchedItem.data.important !== true &&
@@ -269,7 +268,7 @@ exports.fn = (root, params) => {
) {
styleDeclarationList.children.replace(
matchedItem,
- ruleDeclarationItem
+ ruleDeclarationItem,
);
styleDeclarationItems.set(property, ruleDeclarationItem);
}
@@ -314,14 +313,19 @@ exports.fn = (root, params) => {
const classList = new Set(
selectedEl.attributes.class == null
? null
- : selectedEl.attributes.class.split(' ')
+ : selectedEl.attributes.class.split(' '),
);
for (const child of selector.node.children) {
if (
child.type === 'ClassSelector' &&
!selectors.some((selector) =>
- includesAttrSelector(selector.item, 'class', child.name, true)
+ includesAttrSelector(
+ selector.item,
+ 'class',
+ child.name,
+ true,
+ ),
)
) {
classList.delete(child.name);
@@ -344,8 +348,8 @@ exports.fn = (root, params) => {
selector.item,
'id',
firstSubSelector.name,
- true
- )
+ true,
+ ),
)
) {
delete selectedEl.attributes.id;