File tree Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -1293,7 +1293,7 @@ function createAttrWhitespaceFix(
12931293
12941294 // Find attributes with leading or trailing whitespace in their values
12951295 // This pattern matches: attrName=" value " or attrName=' value '
1296- const attrPattern = / ( \w + ) \s * = \s * ( " ( [ ^ " ] * ) " | ' ( [ ^ ' ] * ) ' ) / g;
1296+ const attrPattern = / ( [ a - z A - Z 0 - 9 - _ ] + ) \s * = \s * ( " ( [ ^ " ] * ) " | ' ( [ ^ ' ] * ) ' ) / g;
12971297 let match ;
12981298 const edits : TextEdit [ ] = [ ] ;
12991299
Original file line number Diff line number Diff line change 1+ <!doctype html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 " />
5+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
6+ < title > Attribute Whitespace Test</ title >
7+ </ head >
8+ < body >
9+ <!-- Test case 1: Leading space in attribute value (should become: <div title="a"></div>) -->
10+ < div title =" a "> </ div >
11+
12+ <!-- Test case 2: Trailing space in attribute value (should become: <div title="a"></div>) -->
13+ < div title ="a "> </ div >
14+
15+ <!-- Test case 3: Both leading and trailing spaces (should become: <div title="a"></div>) -->
16+ < div title =" a "> </ div >
17+
18+ <!-- Test case 4: Multiple spaces (should become: <div class="btn primary">Button</div>) -->
19+ < div class =" btn primary "> Button</ div >
20+
21+ <!-- Test case 5: No spaces - should not trigger -->
22+ < div title ="a "> </ div >
23+
24+ <!-- Test case 6: Single space in middle - should not trigger -->
25+ < div class ="btn primary "> Button</ div >
26+
27+ <!-- Test case 7: Mixed quotes (should become: <div data-test='value'></div>) -->
28+ < div data-test =' value '> </ div >
29+
30+ <!-- Test case 8: Multiple attributes with spaces (should become: <div id="main" class="container">Content</div>) -->
31+ < div id =" main " class =" container "> Content</ div >
32+
33+ <!-- Test case 9: Hyphenated attribute name with spaces (should become: <div data-test-id="value">Test</div>) -->
34+ < div data-test-id =" value "> Test</ div >
35+ </ body >
36+ </ html >
You can’t perform that action at this time.
0 commit comments