From f06956efd2dc4bf77244a9fcce2b883a00b925af Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Thu, 21 Dec 2023 22:46:53 +0800 Subject: updated node modules --- node_modules/svgo/plugins/inlineStyles.js | 270 +++++++++++++++--------------- 1 file changed, 135 insertions(+), 135 deletions(-) (limited to 'node_modules/svgo/plugins/inlineStyles.js') diff --git a/node_modules/svgo/plugins/inlineStyles.js b/node_modules/svgo/plugins/inlineStyles.js index e931b5f6..1cdcebe7 100644 --- a/node_modules/svgo/plugins/inlineStyles.js +++ b/node_modules/svgo/plugins/inlineStyles.js @@ -1,14 +1,13 @@ 'use strict'; /** - * @typedef {import('../lib/types').Specificity} Specificity * @typedef {import('../lib/types').XastElement} XastElement * @typedef {import('../lib/types').XastParent} XastParent */ const csstree = require('css-tree'); const { - // @ts-ignore not defined in @types/csso + // @ts-ignore internal api syntax: { specificity }, } = require('csso'); const { @@ -16,54 +15,32 @@ const { querySelectorAll, detachNodeFromParent, } = require('../lib/xast.js'); +const { compareSpecificity, includesAttrSelector } = require('../lib/style'); +const { attrsGroups, pseudoClasses } = require('./_collections'); exports.name = 'inlineStyles'; exports.description = 'inline styles (additional options)'; /** - * Compares two selector specificities. - * extracted from https://github.com/keeganstreet/specificity/blob/main/specificity.js#L211 + * Some pseudo-classes can only be calculated by clients, like :visited, + * :future, or :hover, but there are other pseudo-classes that we can evaluate + * during optimization. * - * @type {(a: Specificity, b: Specificity) => number} - */ -const compareSpecificity = (a, b) => { - for (var i = 0; i < 4; i += 1) { - if (a[i] < b[i]) { - return -1; - } else if (a[i] > b[i]) { - return 1; - } - } - return 0; -}; - -/** - * @type {(value: any) => any} + * The list of pseudo-classes that we can evaluate during optimization, and so + * shouldn't be toggled conditionally through the `usePseudos` parameter. + * + * @see https://developer.mozilla.org/docs/Web/CSS/Pseudo-classes */ -const toAny = (value) => value; +const preservedPseudos = [ + ...pseudoClasses.functional, + ...pseudoClasses.treeStructural, +]; /** - * Moves + merges styles from style elements to element styles - * - * Options - * onlyMatchedOnce (default: true) - * inline only selectors that match once - * - * removeMatchedSelectors (default: true) - * clean up matched selectors, - * leave selectors that hadn't matched - * - * useMqs (default: ['', 'screen']) - * what media queries to be used - * empty string element for styles outside media queries - * - * usePseudos (default: ['']) - * what pseudo-classes/-elements to be used - * empty string element for all non-pseudo-classes and/or -elements - * - * @author strarsis + * Merges styles from style nodes into inline styles. * * @type {import('./plugins-types').Plugin<'inlineStyles'>} + * @author strarsis */ exports.fn = (root, params) => { const { @@ -90,15 +67,12 @@ exports.fn = (root, params) => { return { element: { enter: (node, parentNode) => { - // skip content if (node.name === 'foreignObject') { return visitSkip; } - // collect only non-empty