diff options
Diffstat (limited to 'node_modules/stylus/lib/functions/current-media.js')
| -rw-r--r-- | node_modules/stylus/lib/functions/current-media.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/node_modules/stylus/lib/functions/current-media.js b/node_modules/stylus/lib/functions/current-media.js new file mode 100644 index 00000000..e88e3e81 --- /dev/null +++ b/node_modules/stylus/lib/functions/current-media.js @@ -0,0 +1,22 @@ +var nodes = require('../nodes'); + +/** + * Returns the @media string for the current block + * + * @return {String} + * @api public + */ + +module.exports = function currentMedia(){ + var self = this; + return new nodes.String(lookForMedia(this.closestBlock.node) || ''); + + function lookForMedia(node){ + if ('media' == node.nodeName) { + node.val = self.visit(node.val); + return node.toString(); + } else if (node.block.parent.node) { + return lookForMedia(node.block.parent.node); + } + } +}; |
