UNPKG

1.54 kBJavaScriptView Raw
1
2/*!
3 * Stylus - Keyframes
4 * Copyright (c) Automattic <developer.wordpress.com>
5 * MIT Licensed
6 */
7
8/**
9 * Module dependencies.
10 */
11
12var Atrule = require('./atrule');
13
14/**
15 * Initialize a new `Keyframes` with the given `segs`,
16 * and optional vendor `prefix`.
17 *
18 * @param {Array} segs
19 * @param {String} prefix
20 * @api public
21 */
22
23var Keyframes = module.exports = function Keyframes(segs, prefix){
24 Atrule.call(this, 'keyframes');
25 this.segments = segs;
26 this.prefix = prefix || 'official';
27};
28
29/**
30 * Inherit from `Atrule.prototype`.
31 */
32
33Keyframes.prototype.__proto__ = Atrule.prototype;
34
35/**
36 * Return a clone of this node.
37 *
38 * @return {Node}
39 * @api public
40 */
41
42Keyframes.prototype.clone = function(parent){
43 var clone = new Keyframes;
44 clone.lineno = this.lineno;
45 clone.column = this.column;
46 clone.filename = this.filename;
47 clone.segments = this.segments.map(function(node) { return node.clone(parent, clone); });
48 clone.prefix = this.prefix;
49 clone.block = this.block.clone(parent, clone);
50 return clone;
51};
52
53/**
54 * Return a JSON representation of this node.
55 *
56 * @return {Object}
57 * @api public
58 */
59
60Keyframes.prototype.toJSON = function(){
61 return {
62 __type: 'Keyframes',
63 segments: this.segments,
64 prefix: this.prefix,
65 block: this.block,
66 lineno: this.lineno,
67 column: this.column,
68 filename: this.filename
69 };
70};
71
72/**
73 * Return `@keyframes name`.
74 *
75 * @return {String}
76 * @api public
77 */
78
79Keyframes.prototype.toString = function(){
80 return '@keyframes ' + this.segments.join('');
81};