diff options
Diffstat (limited to 'node_modules/tailwindcss/lib/util/applyImportantSelector.js')
| -rw-r--r-- | node_modules/tailwindcss/lib/util/applyImportantSelector.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/node_modules/tailwindcss/lib/util/applyImportantSelector.js b/node_modules/tailwindcss/lib/util/applyImportantSelector.js new file mode 100644 index 0000000..c53729d --- /dev/null +++ b/node_modules/tailwindcss/lib/util/applyImportantSelector.js @@ -0,0 +1,36 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { + value: true +}); +Object.defineProperty(exports, "applyImportantSelector", { + enumerable: true, + get: function() { + return applyImportantSelector; + } +}); +const _postcssselectorparser = /*#__PURE__*/ _interop_require_default(require("postcss-selector-parser")); +const _pseudoElements = require("./pseudoElements"); +function _interop_require_default(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; +} +function applyImportantSelector(selector, important) { + let sel = (0, _postcssselectorparser.default)().astSync(selector); + sel.each((sel)=>{ + // Wrap with :is if it's not already wrapped + let isWrapped = sel.nodes[0].type === "pseudo" && sel.nodes[0].value === ":is" && sel.nodes.every((node)=>node.type !== "combinator"); + if (!isWrapped) { + sel.nodes = [ + _postcssselectorparser.default.pseudo({ + value: ":is", + nodes: [ + sel.clone() + ] + }) + ]; + } + (0, _pseudoElements.movePseudos)(sel); + }); + return `${important} ${sel.toString()}`; +} |