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) {
80
80
var start = node . childNodes [ 0 ] . __location . start
81
81
var end = node . childNodes [ node . childNodes . length - 1 ] . __location . end
82
82
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
84
86
var map = new SourceMapGenerator ( )
85
87
map . setSourceContent ( filenameWithHash , content )
86
88
87
- result . split ( splitRE ) . forEach ( function ( line , index ) {
89
+ trimmedResult . split ( splitRE ) . forEach ( function ( line , index ) {
88
90
map . addMapping ( {
89
91
source : filenameWithHash ,
90
92
original : {
@@ -101,7 +103,7 @@ module.exports = function (content, filename) {
101
103
output [ type ] . push ( {
102
104
lang : lang ,
103
105
scoped : scoped ,
104
- content : result ,
106
+ content : trimmedResult ,
105
107
map : map . toJSON ( )
106
108
} )
107
109
} )
Original file line number Diff line number Diff line change @@ -152,11 +152,10 @@ describe('vue-loader', function () {
152
152
getFile ( 'test.build.js' , function ( code ) {
153
153
var line
154
154
var col
155
- var lines = code . split ( '\n' )
156
- lines . some ( function ( l , i ) {
155
+ code . split ( '\n' ) . some ( function ( l , i ) {
157
156
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
160
159
return true
161
160
}
162
161
} )
@@ -208,7 +207,7 @@ describe('vue-loader', function () {
208
207
} ) , function ( err ) {
209
208
expect ( err ) . to . be . null
210
209
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}' )
212
211
done ( )
213
212
} )
214
213
} )
You can’t perform that action at this time.
0 commit comments