1 | 'use strict';
|
2 |
|
3 | exports.__esModule = true;
|
4 |
|
5 | var _parser = require('postcss/lib/parser');
|
6 |
|
7 | var _parser2 = _interopRequireDefault(_parser);
|
8 |
|
9 | var _safeTokenize = require('./safe-tokenize');
|
10 |
|
11 | var _safeTokenize2 = _interopRequireDefault(_safeTokenize);
|
12 |
|
13 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
14 |
|
15 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
16 |
|
17 | 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; }
|
18 |
|
19 | 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; }
|
20 |
|
21 | var SafeParser = function (_Parser) {
|
22 | _inherits(SafeParser, _Parser);
|
23 |
|
24 | function SafeParser() {
|
25 | _classCallCheck(this, SafeParser);
|
26 |
|
27 | return _possibleConstructorReturn(this, _Parser.apply(this, arguments));
|
28 | }
|
29 |
|
30 | SafeParser.prototype.tokenize = function tokenize() {
|
31 | this.tokens = (0, _safeTokenize2.default)(this.input);
|
32 | };
|
33 |
|
34 | SafeParser.prototype.unclosedBracket = function unclosedBracket() {};
|
35 |
|
36 | SafeParser.prototype.unknownWord = function unknownWord(start) {
|
37 | var buffer = this.tokens.slice(start, this.pos + 1);
|
38 | this.spaces += buffer.map(function (i) {
|
39 | return i[1];
|
40 | }).join('');
|
41 | };
|
42 |
|
43 | SafeParser.prototype.unexpectedClose = function unexpectedClose() {
|
44 | this.current.raws.after += '}';
|
45 | };
|
46 |
|
47 | SafeParser.prototype.doubleColon = function doubleColon() {};
|
48 |
|
49 | SafeParser.prototype.unnamedAtrule = function unnamedAtrule(node) {
|
50 | node.name = '';
|
51 | };
|
52 |
|
53 | SafeParser.prototype.precheckMissedSemicolon = function precheckMissedSemicolon(tokens) {
|
54 | var colon = this.colon(tokens);
|
55 | if (colon === false) return;
|
56 |
|
57 | var split = undefined;
|
58 | for (split = colon - 1; split >= 0; split--) {
|
59 | if (tokens[split][0] === 'word') break;
|
60 | }
|
61 | for (split -= 1; split >= 0; split--) {
|
62 | if (tokens[split][0] !== 'space') {
|
63 | split += 1;
|
64 | break;
|
65 | }
|
66 | }
|
67 | var other = tokens.splice(split, tokens.length - split);
|
68 | this.decl(other);
|
69 | };
|
70 |
|
71 | SafeParser.prototype.checkMissedSemicolon = function checkMissedSemicolon() {};
|
72 |
|
73 | SafeParser.prototype.endFile = function endFile() {
|
74 | if (this.current.nodes && this.current.nodes.length) {
|
75 | this.current.raws.semicolon = this.semicolon;
|
76 | }
|
77 | this.current.raws.after = (this.current.raws.after || '') + this.spaces;
|
78 |
|
79 | while (this.current.parent) {
|
80 | this.current = this.current.parent;
|
81 | this.current.raws.after = '';
|
82 | }
|
83 | };
|
84 |
|
85 | return SafeParser;
|
86 | }(_parser2.default);
|
87 |
|
88 | exports.default = SafeParser;
|
89 | module.exports = exports['default']; |
\ | No newline at end of file |