Skip to content

Commit 349df24

Browse files
committed
Refactor form method attribute insertion logic
Simplifies the logic for inserting the 'method' attribute into form tags by moving the assignment of newText outside the conditional branches.
1 parent c1abb73 commit 349df24

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

htmlhint-server/src/server.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2028,17 +2028,15 @@ function createFormMethodRequireFix(
20282028
const existingAttrs = formMatch[2] || ""; // existing attributes
20292029

20302030
// Calculate insertion position
2031+
const newText = ' method=""';
20312032
let insertPosition: number;
2032-
let newText: string;
20332033

20342034
if (existingAttrs.trim()) {
20352035
// There are existing attributes, add method after them
20362036
insertPosition = tagStart + beforeAttrs.length + existingAttrs.length;
2037-
newText = ' method=""';
20382037
} else {
20392038
// No existing attributes, add method right after "form"
20402039
insertPosition = tagStart + beforeAttrs.length;
2041-
newText = ' method=""';
20422040
}
20432041

20442042
const edit: TextEdit = {

0 commit comments

Comments
 (0)