Skip to content

Commit cda5c86

Browse files
committed
fix: preserve bind:... mapping on elements for better source maps
else an error like "X is not assignable to bind:Y" is shown on the previous attribute, if there is one
1 parent be44125 commit cda5c86

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

packages/svelte2tsx/src/htmlxtojsx_v2/nodes/Binding.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,7 @@ export function handleBinding(
114114
? // HTML typings - preserve the bind: prefix
115115
isShorthand
116116
? [`"${str.original.substring(attr.start, attr.end)}"`]
117-
: [
118-
`"${str.original.substring(
119-
attr.start,
120-
str.original.lastIndexOf('=', attr.expression.start)
121-
)}"`
122-
]
117+
: ['"', [attr.start, str.original.lastIndexOf('=', attr.expression.start)], '"']
123118
: // Other typings - remove the bind: prefix
124119
isShorthand
125120
? [[attr.expression.start, attr.expression.end]]

packages/svelte2tsx/test/htmlx2jsx/samples/binding/expected-svelte5.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)