@@ -3,9 +3,7 @@ let Comment = require('postcss/lib/comment')
33let Parser = require ( 'postcss/lib/parser' )
44
55class SafeParser extends Parser {
6- createTokenizer ( ) {
7- this . tokenizer = tokenizer ( this . input , { ignoreErrors : true } )
8- }
6+ checkMissedSemicolon ( ) { }
97
108 comment ( token ) {
119 let node = new Comment ( )
@@ -14,9 +12,9 @@ class SafeParser extends Parser {
1412 this . input . fromOffset ( token [ 3 ] ) ||
1513 this . input . fromOffset ( this . input . css . length - 1 )
1614 node . source . end = {
17- offset : token [ 3 ] ,
15+ column : pos . col ,
1816 line : pos . line ,
19- column : pos . col
17+ offset : token [ 3 ] + 1
2018 }
2119
2220 let text = token [ 1 ] . slice ( 2 )
@@ -34,26 +32,29 @@ class SafeParser extends Parser {
3432 }
3533 }
3634
35+ createTokenizer ( ) {
36+ this . tokenizer = tokenizer ( this . input , { ignoreErrors : true } )
37+ }
38+
3739 decl ( tokens ) {
3840 if ( tokens . length > 1 && tokens . some ( i => i [ 0 ] === 'word' ) ) {
3941 super . decl ( tokens )
4042 }
4143 }
4244
43- unclosedBracket ( ) { }
44-
45- unknownWord ( tokens ) {
46- this . spaces += tokens . map ( i => i [ 1 ] ) . join ( '' )
47- }
48-
49- unexpectedClose ( ) {
50- this . current . raws . after += '}'
51- }
52-
5345 doubleColon ( ) { }
5446
55- unnamedAtrule ( node ) {
56- node . name = ''
47+ endFile ( ) {
48+ if ( this . current . nodes && this . current . nodes . length ) {
49+ this . current . raws . semicolon = this . semicolon
50+ }
51+ this . current . raws . after = ( this . current . raws . after || '' ) + this . spaces
52+
53+ while ( this . current . parent ) {
54+ this . current = this . current . parent
55+ this . current . raws . after = ''
56+ }
57+ this . root . source . end = this . getPosition ( this . tokenizer . position ( ) )
5758 }
5859
5960 precheckMissedSemicolon ( tokens ) {
@@ -81,18 +82,18 @@ class SafeParser extends Parser {
8182 this . decl ( other )
8283 }
8384
84- checkMissedSemicolon ( ) { }
85+ unclosedBracket ( ) { }
8586
86- endFile ( ) {
87- if ( this . current . nodes && this . current . nodes . length ) {
88- this . current . raws . semicolon = this . semicolon
89- }
90- this . current . raws . after = ( this . current . raws . after || '' ) + this . spaces
87+ unexpectedClose ( ) {
88+ this . current . raws . after += '}'
89+ }
9190
92- while ( this . current . parent ) {
93- this . current = this . current . parent
94- this . current . raws . after = ''
95- }
91+ unknownWord ( tokens ) {
92+ this . spaces += tokens . map ( i => i [ 1 ] ) . join ( '' )
93+ }
94+
95+ unnamedAtrule ( node ) {
96+ node . name = ''
9697 }
9798}
9899
0 commit comments