File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ export const useChecker = (
26
26
}
27
27
28
28
// Clean up Vue scoped style attributes
29
- html = typeof html === 'string' ? html . replace ( / ? d a t a - v - [ - a - z 0 - 9 ] + \b / g, '' ) : html
29
+ html = typeof html === 'string' ? html . replace ( / ? d a t a - v - [ - a - z 0 - 9 ] + ( = [ " ' ] ( [ - a - z 0 - 9 ] | \/ | : | \. ) * [ " ' ] ) ? / g, '' ) : html
30
30
const { valid, results } = validator . validateString ( html )
31
31
32
32
if ( valid && ! results . length ) {
Original file line number Diff line number Diff line change @@ -122,6 +122,24 @@ describe('useChecker', () => {
122
122
expect ( console . error ) . not . toHaveBeenCalled ( )
123
123
} )
124
124
125
+ it ( 'ignores vite-plugin-inspect generated data attributes' , async ( ) => {
126
+ const mockValidator = vi . fn ( ) . mockImplementation ( ( ) => ( { valid : true , results : [ ] } ) )
127
+ const { checkHTML : checker } = useChecker ( { validateString : mockValidator } as any , false )
128
+
129
+ await checker (
130
+ 'https://test.com/' ,
131
+ '<a style="color:red" class="xxx" data-v-inspector="xxxx/xxx.vue:2:3">Link</a>'
132
+ )
133
+ expect ( mockValidator ) . toHaveBeenCalledWith (
134
+ '<a style="color:red" class="xxx">Link</a>'
135
+ )
136
+ expect ( console . log ) . toHaveBeenCalledWith (
137
+ `No HTML validation errors found for ${ chalk . bold ( 'https://test.com/' ) } `
138
+ )
139
+ expect ( console . warn ) . not . toHaveBeenCalled ( )
140
+ expect ( console . error ) . not . toHaveBeenCalled ( )
141
+ } )
142
+
125
143
it ( 'formats HTML with prettier when asked to do so' , async ( ) => {
126
144
const mockValidator = vi . fn ( ) . mockImplementation ( ( ) => ( { valid : false , results : [ ] } ) )
127
145
const { checkHTML : checker } = useChecker ( { validateString : mockValidator } as any , true )
You can’t perform that action at this time.
0 commit comments