File tree Expand file tree Collapse file tree 4 files changed +85
-7
lines changed
__testfixtures__/slot-attribute Expand file tree Collapse file tree 4 files changed +85
-7
lines changed Original file line number Diff line number Diff line change @@ -77,11 +77,10 @@ export default function runTransformation(
77
77
descriptor . template . ast . children [
78
78
descriptor . template . ast . children . length - 1
79
79
] . loc . end . offset + 1
80
+ let astStart = descriptor . template . ast . loc . start . offset
81
+ let astEnd = descriptor . template . ast . loc . end . offset + 1
80
82
81
- fileInfo . source =
82
- source . slice ( 0 , contentStart ) +
83
- descriptor . template . content +
84
- source . slice ( contentEnd , contentEnd + 11 )
83
+ fileInfo . source = descriptor . template . ast . loc . source
85
84
86
85
const out = transformation ( fileInfo , params )
87
86
@@ -91,13 +90,13 @@ export default function runTransformation(
91
90
92
91
// need to reconstruct the .vue file from descriptor blocks
93
92
if ( extension === '.vue' ) {
94
- if ( out === fileInfo . source ) {
93
+ if ( out === descriptor ! . template ! . content ) {
95
94
return source // skipped, don't bother re-stringifying
96
95
}
97
96
// remove redundant <template> tag
98
97
descriptor ! . template ! . content = out . slice (
99
- contentStart ,
100
- descriptor . template . content . length - contentEnd
98
+ contentStart - astStart ,
99
+ contentEnd - astEnd
101
100
)
102
101
return stringifySFC ( descriptor ! )
103
102
}
Original file line number Diff line number Diff line change @@ -7,10 +7,19 @@ runTest(
7
7
'vue' ,
8
8
'vue'
9
9
)
10
+
10
11
runTest (
11
12
'template element replace slot="xxx" to v-slot:xxx' ,
12
13
'slot-attribute' ,
13
14
'template-slot-attribute' ,
14
15
'vue' ,
15
16
'vue'
16
17
)
18
+
19
+ runTest (
20
+ 'Template is between style and script' ,
21
+ 'slot-attribute' ,
22
+ 'template-tag-slice' ,
23
+ 'vue' ,
24
+ 'vue'
25
+ )
Original file line number Diff line number Diff line change
1
+ <style >
2
+ .mini-cover {
3
+ width : 50px ;
4
+ height : 50px ;
5
+ }
6
+ </style >
7
+
8
+
9
+ <template >
10
+ <div class =" img-list" ref =" box" >
11
+ <li v-for =" img in list" @click =" delMe(img)" >
12
+ <lazy-component @show =" tip" >
13
+ <img class =" mini-cover" :src =" img.src" width =" 100%" height =" 400" >
14
+ </lazy-component >
15
+ </li >
16
+ </div >
17
+ </template >
18
+
19
+
20
+ <script >
21
+ export default {
22
+ name: ' ListC' ,
23
+ props: {
24
+ list: Array
25
+ },
26
+ methods: {
27
+ tip (context ) {
28
+ console .log (context)
29
+ },
30
+ delMe (img ) {
31
+ this .$emit (' delete' , img)
32
+ }
33
+ }
34
+ }
35
+ </script >
Original file line number Diff line number Diff line change
1
+ <style >
2
+ .mini-cover {
3
+ width : 50px ;
4
+ height : 50px ;
5
+ }
6
+ </style >
7
+
8
+
9
+ <template >
10
+ <div class =" img-list" ref =" box" >
11
+ <li v-for =" img in list" @click =" delMe(img)" >
12
+ <lazy-component @show =" tip" >
13
+ <img class =" mini-cover" :src =" img.src" width =" 100%" height =" 400" >
14
+ </lazy-component >
15
+ </li >
16
+ </div >
17
+ </template >
18
+
19
+
20
+ <script >
21
+ export default {
22
+ name: ' ListC' ,
23
+ props: {
24
+ list: Array
25
+ },
26
+ methods: {
27
+ tip (context ) {
28
+ console .log (context)
29
+ },
30
+ delMe (img ) {
31
+ this .$emit (' delete' , img)
32
+ }
33
+ }
34
+ }
35
+ </script >
You can’t perform that action at this time.
0 commit comments