From 26105034da4fcce7ac883c899d781f016559310d Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 8 Nov 2018 00:38:48 +0800 Subject: switch to vuepress --- .../stylus/lib/functions/selector-exists.js | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 node_modules/stylus/lib/functions/selector-exists.js (limited to 'node_modules/stylus/lib/functions/selector-exists.js') diff --git a/node_modules/stylus/lib/functions/selector-exists.js b/node_modules/stylus/lib/functions/selector-exists.js new file mode 100644 index 00000000..68914af5 --- /dev/null +++ b/node_modules/stylus/lib/functions/selector-exists.js @@ -0,0 +1,23 @@ +var utils = require('../utils'); + +/** + * Returns true if the given selector exists. + * + * @param {String} sel + * @return {Boolean} + * @api public + */ + +module.exports = function selectorExists(sel) { + utils.assertString(sel, 'selector'); + + if (!this.__selectorsMap__) { + var Normalizer = require('../visitor/normalizer') + , visitor = new Normalizer(this.root.clone()); + visitor.visit(visitor.root); + + this.__selectorsMap__ = visitor.map; + } + + return sel.string in this.__selectorsMap__; +}; -- cgit v1.2.3