postcss 5.0.10 → 5.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of postcss might be problematic. Click here for more details.
- package/CHANGELOG.md +16 -0
- package/README.md +178 -695
- package/d.ts/at-rule.d.ts +0 -2
- package/d.ts/css-syntax-error.d.ts +0 -1
- package/d.ts/parser.d.ts +0 -1
- package/docs/api.md +4 -4
- package/docs/guidelines/plugin.md +3 -3
- package/docs/plugins.md +572 -0
- package/docs/source-maps.md +68 -0
- package/docs/writing-a-plugin.md +27 -0
- package/lib/at-rule.js +36 -31
- package/lib/comment.js +33 -18
- package/lib/container.js +62 -36
- package/lib/css-syntax-error.js +13 -23
- package/lib/declaration.js +33 -18
- package/lib/input.js +17 -17
- package/lib/lazy-result.js +25 -20
- package/lib/list.js +1 -5
- package/lib/map-generator.js +34 -33
- package/lib/node.js +66 -44
- package/lib/parse.js +6 -6
- package/lib/parser.js +17 -39
- package/lib/postcss.js +14 -14
- package/lib/previous-map.js +20 -18
- package/lib/processor.js +9 -11
- package/lib/result.js +8 -8
- package/lib/root.js +22 -13
- package/lib/rule.js +25 -16
- package/lib/stringifier.js +2 -4
- package/lib/stringify.js +4 -5
- package/lib/tokenize.js +2 -3
- package/lib/vendor.js +1 -4
- package/lib/warn-once.js +3 -2
- package/lib/warning.js +7 -3
- package/package.json +21 -18
@@ -0,0 +1,68 @@
|
|
1
|
+
# PostCSS and Source Maps
|
2
|
+
|
3
|
+
PostCSS has great [source maps] support. It can read and interpret maps
|
4
|
+
from previous transformation steps, autodetect the format that you expect,
|
5
|
+
and output both external and inline maps.
|
6
|
+
|
7
|
+
To ensure that you generate an accurate source map, you must indicate the input
|
8
|
+
and output CSS file paths — using the options `from` and `to`, respectively.
|
9
|
+
|
10
|
+
To generate a new source map with the default options, simply set `map: true`.
|
11
|
+
This will generate an inline source map that contains the source content.
|
12
|
+
If you don’t want the map inlined, you can set `map.inline: false`.
|
13
|
+
|
14
|
+
```js
|
15
|
+
processor
|
16
|
+
.process(css, {
|
17
|
+
from: 'app.sass.css',
|
18
|
+
to: 'app.css',
|
19
|
+
map: { inline: false },
|
20
|
+
})
|
21
|
+
.then(function (result) {
|
22
|
+
result.map //=> '{ "version":3,
|
23
|
+
// "file":"app.css",
|
24
|
+
// "sources":["app.sass"],
|
25
|
+
// "mappings":"AAAA,KAAI" }'
|
26
|
+
});
|
27
|
+
```
|
28
|
+
|
29
|
+
If PostCSS finds source maps from a previous transformation,
|
30
|
+
it will automatically update that source map with the same options.
|
31
|
+
|
32
|
+
## Options
|
33
|
+
|
34
|
+
If you want more control over source map generation, you can define the `map`
|
35
|
+
option as an object with the following parameters:
|
36
|
+
|
37
|
+
* `inline` boolean: indicates that the source map should be embedded
|
38
|
+
in the output CSS as a Base64-encoded comment. By default, it is `true`.
|
39
|
+
But if all previous maps are external, not inline, PostCSS will not embed
|
40
|
+
the map even if you do not set this option.
|
41
|
+
|
42
|
+
If you have an inline source map, the `result.map` property will be empty,
|
43
|
+
as the source map will be contained within the text of `result.css`.
|
44
|
+
|
45
|
+
* `prev` string, object or boolean: source map content from
|
46
|
+
a previous processing step (for example, Sass compilation).
|
47
|
+
PostCSS will try to read the previous source map automatically
|
48
|
+
(based on comments within the source CSS), but you can use this option
|
49
|
+
to identify it manually. If desired, you can omit the previous map
|
50
|
+
with `prev: false`.
|
51
|
+
|
52
|
+
* `sourcesContent` boolean: indicates that PostCSS should set the origin
|
53
|
+
content (for example, Sass source) of the source map. By default,
|
54
|
+
it is `true`. But if all previous maps do not contain sources content,
|
55
|
+
PostCSS will also leave it out even if you do not set this option.
|
56
|
+
|
57
|
+
* `annotation` boolean or string: indicates that PostCSS should add annotation
|
58
|
+
comments to the CSS. By default, PostCSS will always add a comment with a path
|
59
|
+
to the source map. PostCSS will not add annotations to CSS files that
|
60
|
+
do not contain any comments.
|
61
|
+
|
62
|
+
By default, PostCSS presumes that you want to save the source map as
|
63
|
+
`opts.to + '.map'` and will use this path in the annotation comment.
|
64
|
+
A different path can be set by providing a string value for `annotation`.
|
65
|
+
|
66
|
+
If you have set `inline: true`, annotation cannot be disabled.
|
67
|
+
|
68
|
+
[source maps]: http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# Writing a PostCSS Plugin
|
2
|
+
|
3
|
+
## Getting Started
|
4
|
+
|
5
|
+
* [“Create Your Own Plugin” tutorial](http://webdesign.tutsplus.com/tutorials/postcss-deep-dive-create-your-own-plugin--cms-24605)
|
6
|
+
* [Plugin Boilerplate](https://github.com/postcss/postcss-plugin-boilerplate)
|
7
|
+
* [Plugin Guidelines](https://github.com/postcss/postcss/blob/master/docs/guidelines/plugin.md)
|
8
|
+
* [AST explorer with playground](http://astexplorer.net/#/np0DfVT78g/1)
|
9
|
+
|
10
|
+
## Documentation and Support
|
11
|
+
|
12
|
+
* [PostCSS API](https://github.com/postcss/postcss/blob/master/docs/api.md)
|
13
|
+
* [Ask questions](https://gitter.im/postcss/postcss)
|
14
|
+
* [PostCSS twitter](https://twitter.com/postcss) with latest updates.
|
15
|
+
|
16
|
+
## Tools
|
17
|
+
|
18
|
+
* [Selector parser](https://github.com/postcss/postcss-selector-parser)
|
19
|
+
* [Value parser](https://github.com/TrySound/postcss-value-parser)
|
20
|
+
* [Property resolver](https://github.com/jedmao/postcss-resolve-prop)
|
21
|
+
* [Font parser](https://github.com/jedmao/parse-css-font)
|
22
|
+
* [Dimension parser](https://github.com/jedmao/parse-css-dimension)
|
23
|
+
for `number`, `length` and `percentage`.
|
24
|
+
* [Sides parser](https://github.com/jedmao/parse-css-sides)
|
25
|
+
for `margin`, `padding` and `border` properties.
|
26
|
+
* [Font helpers](https://github.com/jedmao/postcss-font-helpers)
|
27
|
+
* [Margin helpers](https://github.com/jedmao/postcss-margin-helpers)
|
package/lib/at-rule.js
CHANGED
@@ -1,14 +1,8 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
6
|
-
|
7
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
3
|
+
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
8
4
|
|
9
|
-
|
10
|
-
|
11
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
5
|
+
exports.__esModule = true;
|
12
6
|
|
13
7
|
var _container = require('./container');
|
14
8
|
|
@@ -18,18 +12,28 @@ var _warnOnce = require('./warn-once');
|
|
18
12
|
|
19
13
|
var _warnOnce2 = _interopRequireDefault(_warnOnce);
|
20
14
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
16
|
+
|
17
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
18
|
+
|
19
|
+
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
20
|
+
|
21
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
22
|
+
|
21
23
|
var AtRule = (function (_Container) {
|
22
24
|
_inherits(AtRule, _Container);
|
23
25
|
|
24
26
|
function AtRule(defaults) {
|
25
27
|
_classCallCheck(this, AtRule);
|
26
28
|
|
27
|
-
_Container.call(this, defaults);
|
28
|
-
|
29
|
+
var _this = _possibleConstructorReturn(this, _Container.call(this, defaults));
|
30
|
+
|
31
|
+
_this.type = 'atrule';
|
32
|
+
return _this;
|
29
33
|
}
|
30
34
|
|
31
35
|
AtRule.prototype.append = function append() {
|
32
|
-
var _Container$prototype
|
36
|
+
var _Container$prototype$;
|
33
37
|
|
34
38
|
if (!this.nodes) this.nodes = [];
|
35
39
|
|
@@ -37,11 +41,11 @@ var AtRule = (function (_Container) {
|
|
37
41
|
children[_key] = arguments[_key];
|
38
42
|
}
|
39
43
|
|
40
|
-
return (_Container$prototype$
|
44
|
+
return (_Container$prototype$ = _Container.prototype.append).call.apply(_Container$prototype$, [this].concat(children));
|
41
45
|
};
|
42
46
|
|
43
47
|
AtRule.prototype.prepend = function prepend() {
|
44
|
-
var _Container$prototype$
|
48
|
+
var _Container$prototype$2;
|
45
49
|
|
46
50
|
if (!this.nodes) this.nodes = [];
|
47
51
|
|
@@ -49,43 +53,44 @@ var AtRule = (function (_Container) {
|
|
49
53
|
children[_key2] = arguments[_key2];
|
50
54
|
}
|
51
55
|
|
52
|
-
return (_Container$prototype$
|
56
|
+
return (_Container$prototype$2 = _Container.prototype.prepend).call.apply(_Container$prototype$2, [this].concat(children));
|
53
57
|
};
|
54
58
|
|
55
|
-
|
56
|
-
if (!this.nodes) this.nodes = [];
|
57
|
-
return _Container.prototype.insertBefore.call(this, exist, add);
|
58
|
-
};
|
59
|
-
|
60
|
-
AtRule.prototype.insertAfter = function insertAfter(exist, add) {
|
61
|
-
if (!this.nodes) this.nodes = [];
|
62
|
-
return _Container.prototype.insertAfter.call(this, exist, add);
|
63
|
-
};
|
59
|
+
/* istanbul ignore next */
|
64
60
|
|
65
61
|
_createClass(AtRule, [{
|
66
62
|
key: 'afterName',
|
67
63
|
get: function get() {
|
68
|
-
_warnOnce2
|
64
|
+
(0, _warnOnce2.default)('AtRule#afterName was deprecated. Use AtRule#raws.afterName');
|
69
65
|
return this.raws.afterName;
|
70
|
-
}
|
66
|
+
}
|
67
|
+
|
68
|
+
/* istanbul ignore next */
|
69
|
+
,
|
71
70
|
set: function set(val) {
|
72
|
-
_warnOnce2
|
71
|
+
(0, _warnOnce2.default)('AtRule#afterName was deprecated. Use AtRule#raws.afterName');
|
73
72
|
this.raws.afterName = val;
|
74
73
|
}
|
74
|
+
|
75
|
+
/* istanbul ignore next */
|
76
|
+
|
75
77
|
}, {
|
76
78
|
key: '_params',
|
77
79
|
get: function get() {
|
78
|
-
_warnOnce2
|
80
|
+
(0, _warnOnce2.default)('AtRule#_params was deprecated. Use AtRule#raws.params');
|
79
81
|
return this.raws.params;
|
80
|
-
}
|
82
|
+
}
|
83
|
+
|
84
|
+
/* istanbul ignore next */
|
85
|
+
,
|
81
86
|
set: function set(val) {
|
82
|
-
_warnOnce2
|
87
|
+
(0, _warnOnce2.default)('AtRule#_params was deprecated. Use AtRule#raws.params');
|
83
88
|
this.raws.params = val;
|
84
89
|
}
|
85
90
|
}]);
|
86
91
|
|
87
92
|
return AtRule;
|
88
|
-
})(_container2
|
93
|
+
})(_container2.default);
|
89
94
|
|
90
|
-
exports
|
95
|
+
exports.default = AtRule;
|
91
96
|
module.exports = exports['default'];
|
package/lib/comment.js
CHANGED
@@ -1,14 +1,8 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
6
|
-
|
7
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
3
|
+
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
8
4
|
|
9
|
-
|
10
|
-
|
11
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
5
|
+
exports.__esModule = true;
|
12
6
|
|
13
7
|
var _warnOnce = require('./warn-once');
|
14
8
|
|
@@ -18,40 +12,61 @@ var _node = require('./node');
|
|
18
12
|
|
19
13
|
var _node2 = _interopRequireDefault(_node);
|
20
14
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
16
|
+
|
17
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
18
|
+
|
19
|
+
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
20
|
+
|
21
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
22
|
+
|
21
23
|
var Comment = (function (_Node) {
|
22
24
|
_inherits(Comment, _Node);
|
23
25
|
|
24
26
|
function Comment(defaults) {
|
25
27
|
_classCallCheck(this, Comment);
|
26
28
|
|
27
|
-
_Node.call(this, defaults);
|
28
|
-
|
29
|
+
var _this = _possibleConstructorReturn(this, _Node.call(this, defaults));
|
30
|
+
|
31
|
+
_this.type = 'comment';
|
32
|
+
return _this;
|
29
33
|
}
|
30
34
|
|
35
|
+
/* istanbul ignore next */
|
36
|
+
|
31
37
|
_createClass(Comment, [{
|
32
38
|
key: 'left',
|
33
39
|
get: function get() {
|
34
|
-
_warnOnce2
|
40
|
+
(0, _warnOnce2.default)('Comment#left was deprecated. Use Comment#raws.left');
|
35
41
|
return this.raws.left;
|
36
|
-
}
|
42
|
+
}
|
43
|
+
|
44
|
+
/* istanbul ignore next */
|
45
|
+
,
|
37
46
|
set: function set(val) {
|
38
|
-
_warnOnce2
|
47
|
+
(0, _warnOnce2.default)('Comment#left was deprecated. Use Comment#raws.left');
|
39
48
|
this.raws.left = val;
|
40
49
|
}
|
50
|
+
|
51
|
+
/* istanbul ignore next */
|
52
|
+
|
41
53
|
}, {
|
42
54
|
key: 'right',
|
43
55
|
get: function get() {
|
44
|
-
_warnOnce2
|
56
|
+
(0, _warnOnce2.default)('Comment#right was deprecated. Use Comment#raws.right');
|
45
57
|
return this.raws.right;
|
46
|
-
}
|
58
|
+
}
|
59
|
+
|
60
|
+
/* istanbul ignore next */
|
61
|
+
,
|
47
62
|
set: function set(val) {
|
48
|
-
_warnOnce2
|
63
|
+
(0, _warnOnce2.default)('Comment#right was deprecated. Use Comment#raws.right');
|
49
64
|
this.raws.right = val;
|
50
65
|
}
|
51
66
|
}]);
|
52
67
|
|
53
68
|
return Comment;
|
54
|
-
})(_node2
|
69
|
+
})(_node2.default);
|
55
70
|
|
56
|
-
exports
|
71
|
+
exports.default = Comment;
|
57
72
|
module.exports = exports['default'];
|
package/lib/container.js
CHANGED
@@ -1,14 +1,8 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
6
|
-
|
7
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
3
|
+
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
8
4
|
|
9
|
-
|
10
|
-
|
11
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
5
|
+
exports.__esModule = true;
|
12
6
|
|
13
7
|
var _declaration = require('./declaration');
|
14
8
|
|
@@ -26,7 +20,13 @@ var _node = require('./node');
|
|
26
20
|
|
27
21
|
var _node2 = _interopRequireDefault(_node);
|
28
22
|
|
29
|
-
|
23
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
24
|
+
|
25
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
26
|
+
|
27
|
+
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
28
|
+
|
29
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
30
30
|
|
31
31
|
var Container = (function (_Node) {
|
32
32
|
_inherits(Container, _Node);
|
@@ -34,7 +34,7 @@ var Container = (function (_Node) {
|
|
34
34
|
function Container() {
|
35
35
|
_classCallCheck(this, Container);
|
36
36
|
|
37
|
-
_Node.apply(this, arguments);
|
37
|
+
return _possibleConstructorReturn(this, _Node.apply(this, arguments));
|
38
38
|
}
|
39
39
|
|
40
40
|
Container.prototype.push = function push(child) {
|
@@ -44,10 +44,11 @@ var Container = (function (_Node) {
|
|
44
44
|
};
|
45
45
|
|
46
46
|
Container.prototype.each = function each(callback) {
|
47
|
+
if (!this.lastEach) this.lastEach = 0;
|
47
48
|
if (!this.indexes) this.indexes = {};
|
48
49
|
|
49
|
-
lastEach += 1;
|
50
|
-
var id = lastEach;
|
50
|
+
this.lastEach += 1;
|
51
|
+
var id = this.lastEach;
|
51
52
|
this.indexes[id] = 0;
|
52
53
|
|
53
54
|
if (!this.nodes) return undefined;
|
@@ -63,7 +64,6 @@ var Container = (function (_Node) {
|
|
63
64
|
}
|
64
65
|
|
65
66
|
delete this.indexes[id];
|
66
|
-
if (Object.keys(this.indexes).length === 0) delete this.indexes;
|
67
67
|
|
68
68
|
if (result === false) return false;
|
69
69
|
};
|
@@ -330,8 +330,9 @@ var Container = (function (_Node) {
|
|
330
330
|
};
|
331
331
|
|
332
332
|
Container.prototype.remove = function remove(child) {
|
333
|
+
/* istanbul ignore if */
|
333
334
|
if (typeof child !== 'undefined') {
|
334
|
-
_warnOnce2
|
335
|
+
(0, _warnOnce2.default)('Container#remove is deprecated. ' + 'Use Container#removeChild');
|
335
336
|
this.removeChild(child);
|
336
337
|
} else {
|
337
338
|
_Node.prototype.remove.call(this);
|
@@ -407,7 +408,7 @@ var Container = (function (_Node) {
|
|
407
408
|
};
|
408
409
|
|
409
410
|
Container.prototype.normalize = function normalize(nodes, sample) {
|
410
|
-
var
|
411
|
+
var _this2 = this;
|
411
412
|
|
412
413
|
if (typeof nodes === 'string') {
|
413
414
|
var parse = require('./parse');
|
@@ -421,7 +422,7 @@ var Container = (function (_Node) {
|
|
421
422
|
if (typeof nodes.value === 'undefined') {
|
422
423
|
throw new Error('Value field is missed in node creation');
|
423
424
|
}
|
424
|
-
nodes = [new _declaration2
|
425
|
+
nodes = [new _declaration2.default(nodes)];
|
425
426
|
} else if (nodes.selector) {
|
426
427
|
var Rule = require('./rule');
|
427
428
|
nodes = [new Rule(nodes)];
|
@@ -429,29 +430,33 @@ var Container = (function (_Node) {
|
|
429
430
|
var AtRule = require('./at-rule');
|
430
431
|
nodes = [new AtRule(nodes)];
|
431
432
|
} else if (nodes.text) {
|
432
|
-
nodes = [new _comment2
|
433
|
+
nodes = [new _comment2.default(nodes)];
|
433
434
|
} else {
|
434
435
|
throw new Error('Unknown node type in node creation');
|
435
436
|
}
|
436
437
|
}
|
437
438
|
|
438
439
|
var processed = nodes.map(function (i) {
|
439
|
-
|
440
|
+
/* istanbul ignore if */
|
441
|
+
if (typeof i.raws === 'undefined') i = _this2.rebuild(i);
|
442
|
+
|
440
443
|
if (i.parent) i = i.clone();
|
441
444
|
if (typeof i.raws.before === 'undefined') {
|
442
445
|
if (sample && typeof sample.raws.before !== 'undefined') {
|
443
446
|
i.raws.before = sample.raws.before.replace(/[^\s]/g, '');
|
444
447
|
}
|
445
448
|
}
|
446
|
-
i.parent =
|
449
|
+
i.parent = _this2;
|
447
450
|
return i;
|
448
451
|
});
|
449
452
|
|
450
453
|
return processed;
|
451
454
|
};
|
452
455
|
|
456
|
+
/* istanbul ignore next */
|
457
|
+
|
453
458
|
Container.prototype.rebuild = function rebuild(node, parent) {
|
454
|
-
var
|
459
|
+
var _this3 = this;
|
455
460
|
|
456
461
|
var fix = undefined;
|
457
462
|
if (node.type === 'root') {
|
@@ -464,15 +469,15 @@ var Container = (function (_Node) {
|
|
464
469
|
var Rule = require('./rule');
|
465
470
|
fix = new Rule();
|
466
471
|
} else if (node.type === 'decl') {
|
467
|
-
fix = new _declaration2
|
472
|
+
fix = new _declaration2.default();
|
468
473
|
} else if (node.type === 'comment') {
|
469
|
-
fix = new _comment2
|
474
|
+
fix = new _comment2.default();
|
470
475
|
}
|
471
476
|
|
472
477
|
for (var i in node) {
|
473
478
|
if (i === 'nodes') {
|
474
479
|
fix.nodes = node.nodes.map(function (j) {
|
475
|
-
return
|
480
|
+
return _this3.rebuild(j, fix);
|
476
481
|
});
|
477
482
|
} else if (i === 'parent' && parent) {
|
478
483
|
fix.parent = parent;
|
@@ -484,31 +489,43 @@ var Container = (function (_Node) {
|
|
484
489
|
return fix;
|
485
490
|
};
|
486
491
|
|
492
|
+
/* istanbul ignore next */
|
493
|
+
|
487
494
|
Container.prototype.eachInside = function eachInside(callback) {
|
488
|
-
_warnOnce2
|
495
|
+
(0, _warnOnce2.default)('Container#eachInside is deprecated. ' + 'Use Container#walk instead.');
|
489
496
|
return this.walk(callback);
|
490
497
|
};
|
491
498
|
|
499
|
+
/* istanbul ignore next */
|
500
|
+
|
492
501
|
Container.prototype.eachDecl = function eachDecl(prop, callback) {
|
493
|
-
_warnOnce2
|
502
|
+
(0, _warnOnce2.default)('Container#eachDecl is deprecated. ' + 'Use Container#walkDecls instead.');
|
494
503
|
return this.walkDecls(prop, callback);
|
495
504
|
};
|
496
505
|
|
506
|
+
/* istanbul ignore next */
|
507
|
+
|
497
508
|
Container.prototype.eachRule = function eachRule(selector, callback) {
|
498
|
-
_warnOnce2
|
509
|
+
(0, _warnOnce2.default)('Container#eachRule is deprecated. ' + 'Use Container#walkRules instead.');
|
499
510
|
return this.walkRules(selector, callback);
|
500
511
|
};
|
501
512
|
|
513
|
+
/* istanbul ignore next */
|
514
|
+
|
502
515
|
Container.prototype.eachAtRule = function eachAtRule(name, callback) {
|
503
|
-
_warnOnce2
|
516
|
+
(0, _warnOnce2.default)('Container#eachAtRule is deprecated. ' + 'Use Container#walkAtRules instead.');
|
504
517
|
return this.walkAtRules(name, callback);
|
505
518
|
};
|
506
519
|
|
520
|
+
/* istanbul ignore next */
|
521
|
+
|
507
522
|
Container.prototype.eachComment = function eachComment(callback) {
|
508
|
-
_warnOnce2
|
523
|
+
(0, _warnOnce2.default)('Container#eachComment is deprecated. ' + 'Use Container#walkComments instead.');
|
509
524
|
return this.walkComments(callback);
|
510
525
|
};
|
511
526
|
|
527
|
+
/* istanbul ignore next */
|
528
|
+
|
512
529
|
_createClass(Container, [{
|
513
530
|
key: 'first',
|
514
531
|
get: function get() {
|
@@ -524,27 +541,36 @@ var Container = (function (_Node) {
|
|
524
541
|
}, {
|
525
542
|
key: 'semicolon',
|
526
543
|
get: function get() {
|
527
|
-
_warnOnce2
|
544
|
+
(0, _warnOnce2.default)('Node#semicolon is deprecated. Use Node#raws.semicolon');
|
528
545
|
return this.raws.semicolon;
|
529
|
-
}
|
546
|
+
}
|
547
|
+
|
548
|
+
/* istanbul ignore next */
|
549
|
+
,
|
530
550
|
set: function set(val) {
|
531
|
-
_warnOnce2
|
551
|
+
(0, _warnOnce2.default)('Node#semicolon is deprecated. Use Node#raws.semicolon');
|
532
552
|
this.raws.semicolon = val;
|
533
553
|
}
|
554
|
+
|
555
|
+
/* istanbul ignore next */
|
556
|
+
|
534
557
|
}, {
|
535
558
|
key: 'after',
|
536
559
|
get: function get() {
|
537
|
-
_warnOnce2
|
560
|
+
(0, _warnOnce2.default)('Node#after is deprecated. Use Node#raws.after');
|
538
561
|
return this.raws.after;
|
539
|
-
}
|
562
|
+
}
|
563
|
+
|
564
|
+
/* istanbul ignore next */
|
565
|
+
,
|
540
566
|
set: function set(val) {
|
541
|
-
_warnOnce2
|
567
|
+
(0, _warnOnce2.default)('Node#after is deprecated. Use Node#raws.after');
|
542
568
|
this.raws.after = val;
|
543
569
|
}
|
544
570
|
}]);
|
545
571
|
|
546
572
|
return Container;
|
547
|
-
})(_node2
|
573
|
+
})(_node2.default);
|
548
574
|
|
549
|
-
exports
|
575
|
+
exports.default = Container;
|
550
576
|
module.exports = exports['default'];
|
package/lib/css-syntax-error.js
CHANGED
@@ -1,14 +1,8 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
6
|
-
|
7
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
3
|
+
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
8
4
|
|
9
|
-
|
10
|
-
|
11
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
5
|
+
exports.__esModule = true;
|
12
6
|
|
13
7
|
var _supportsColor = require('supports-color');
|
14
8
|
|
@@ -18,14 +12,16 @@ var _warnOnce = require('./warn-once');
|
|
18
12
|
|
19
13
|
var _warnOnce2 = _interopRequireDefault(_warnOnce);
|
20
14
|
|
21
|
-
|
22
|
-
_inherits(CssSyntaxError, _SyntaxError);
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
23
16
|
|
17
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
18
|
+
|
19
|
+
var CssSyntaxError = (function () {
|
24
20
|
function CssSyntaxError(message, line, column, source, file, plugin) {
|
25
21
|
_classCallCheck(this, CssSyntaxError);
|
26
22
|
|
27
|
-
_SyntaxError.call(this, message);
|
28
23
|
this.name = 'CssSyntaxError';
|
24
|
+
|
29
25
|
this.reason = message;
|
30
26
|
|
31
27
|
if (file) this.file = file;
|
@@ -67,7 +63,7 @@ var CssSyntaxError = (function (_SyntaxError) {
|
|
67
63
|
mark += ' ';
|
68
64
|
}
|
69
65
|
|
70
|
-
if (typeof color === 'undefined') color = _supportsColor2
|
66
|
+
if (typeof color === 'undefined') color = _supportsColor2.default;
|
71
67
|
if (color) {
|
72
68
|
mark += '\x1B[1;31m^\x1B[0m';
|
73
69
|
} else {
|
@@ -77,28 +73,22 @@ var CssSyntaxError = (function (_SyntaxError) {
|
|
77
73
|
return '\n' + prev + broken + mark + next;
|
78
74
|
};
|
79
75
|
|
80
|
-
CssSyntaxError.prototype.setMozillaProps = function setMozillaProps() {
|
81
|
-
var sample = Error.call(this, this.message);
|
82
|
-
if (sample.columnNumber) this.columnNumber = this.column;
|
83
|
-
if (sample.description) this.description = this.message;
|
84
|
-
if (sample.lineNumber) this.lineNumber = this.line;
|
85
|
-
if (sample.fileName) this.fileName = this.file;
|
86
|
-
};
|
87
|
-
|
88
76
|
CssSyntaxError.prototype.toString = function toString() {
|
89
77
|
return this.name + ': ' + this.message + this.showSourceCode();
|
90
78
|
};
|
91
79
|
|
80
|
+
/* istanbul ignore next */
|
81
|
+
|
92
82
|
_createClass(CssSyntaxError, [{
|
93
83
|
key: 'generated',
|
94
84
|
get: function get() {
|
95
|
-
_warnOnce2
|
85
|
+
(0, _warnOnce2.default)('CssSyntaxError#generated is depreacted. Use input instead.');
|
96
86
|
return this.input;
|
97
87
|
}
|
98
88
|
}]);
|
99
89
|
|
100
90
|
return CssSyntaxError;
|
101
|
-
})(
|
91
|
+
})();
|
102
92
|
|
103
|
-
exports
|
93
|
+
exports.default = CssSyntaxError;
|
104
94
|
module.exports = exports['default'];
|