Last change
on this file since 1ad8e64 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
530 bytes
|
Line | |
---|
1 |
|
---|
2 | /*!
|
---|
3 | * Stylus - Visitor
|
---|
4 | * Copyright (c) Automattic <developer.wordpress.com>
|
---|
5 | * MIT Licensed
|
---|
6 | */
|
---|
7 |
|
---|
8 | /**
|
---|
9 | * Initialize a new `Visitor` with the given `root` Node.
|
---|
10 | *
|
---|
11 | * @param {Node} root
|
---|
12 | * @api private
|
---|
13 | */
|
---|
14 |
|
---|
15 | var Visitor = module.exports = function Visitor(root) {
|
---|
16 | this.root = root;
|
---|
17 | };
|
---|
18 |
|
---|
19 | /**
|
---|
20 | * Visit the given `node`.
|
---|
21 | *
|
---|
22 | * @param {Node|Array} node
|
---|
23 | * @api public
|
---|
24 | */
|
---|
25 |
|
---|
26 | Visitor.prototype.visit = function(node, fn){
|
---|
27 | var method = 'visit' + node.constructor.name;
|
---|
28 | if (this[method]) return this[method](node);
|
---|
29 | return node;
|
---|
30 | };
|
---|
31 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.