File tree Expand file tree Collapse file tree 2 files changed +9
-8
lines changed Expand file tree Collapse file tree 2 files changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -80,11 +80,13 @@ module.exports = function (content, filename) {
8080 var start = node . childNodes [ 0 ] . __location . start
8181 var end = node . childNodes [ node . childNodes . length - 1 ] . __location . end
8282 var result = content . slice ( start , end )
83- var lineOffset = content . slice ( 0 , start ) . split ( splitRE ) . length - 1
83+ var trimmedResult = result . trim ( ) + '\n'
84+ var trimmed = trimmedResult . length - result . length
85+ var lineOffset = content . slice ( 0 , start + trimmed ) . split ( splitRE ) . length
8486 var map = new SourceMapGenerator ( )
8587 map . setSourceContent ( filenameWithHash , content )
8688
87- result . split ( splitRE ) . forEach ( function ( line , index ) {
89+ trimmedResult . split ( splitRE ) . forEach ( function ( line , index ) {
8890 map . addMapping ( {
8991 source : filenameWithHash ,
9092 original : {
@@ -101,7 +103,7 @@ module.exports = function (content, filename) {
101103 output [ type ] . push ( {
102104 lang : lang ,
103105 scoped : scoped ,
104- content : result ,
106+ content : trimmedResult ,
105107 map : map . toJSON ( )
106108 } )
107109 } )
Original file line number Diff line number Diff line change @@ -152,11 +152,10 @@ describe('vue-loader', function () {
152152 getFile ( 'test.build.js' , function ( code ) {
153153 var line
154154 var col
155- var lines = code . split ( '\n' )
156- lines . some ( function ( l , i ) {
155+ code . split ( '\n' ) . some ( function ( l , i ) {
157156 if ( l . indexOf ( 'Hello from Component A' ) > - 1 ) {
158- line = i
159- col = lines [ i - 1 ] . length
157+ line = i + 1
158+ col = l . length
160159 return true
161160 }
162161 } )
@@ -208,7 +207,7 @@ describe('vue-loader', function () {
208207 } ) , function ( err ) {
209208 expect ( err ) . to . be . null
210209 getFile ( 'test.output.css' , function ( data ) {
211- expect ( data ) . to . contain ( 'h1 {\n color: #f00;\n}\n\ nh2 {\n color: green;\n}' )
210+ expect ( data ) . to . contain ( 'h1 {\n color: #f00;\n}\nh2 {\n color: green;\n}' )
212211 done ( )
213212 } )
214213 } )
You can’t perform that action at this time.
0 commit comments