aboutsummaryrefslogtreecommitdiff
path: root/node_modules/stylus/lib/functions/selector-exists.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/stylus/lib/functions/selector-exists.js')
-rw-r--r--node_modules/stylus/lib/functions/selector-exists.js23
1 files changed, 23 insertions, 0 deletions
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__;
+};