diff --git a/.changeset/metal-numbers-brush.md b/.changeset/metal-numbers-brush.md
new file mode 100644
index 000000000..7f0e820d6
--- /dev/null
+++ b/.changeset/metal-numbers-brush.md
@@ -0,0 +1,6 @@
+---
+'svelte-language-server': patch
+'svelte2tsx': patch
+---
+
+fix: improve diagnostics mapping for bind/transition directive
diff --git a/packages/language-server/src/plugins/typescript-go/features/DiagnosticsProvider.ts b/packages/language-server/src/plugins/typescript-go/features/DiagnosticsProvider.ts
index a78b0f815..cff0cf966 100644
--- a/packages/language-server/src/plugins/typescript-go/features/DiagnosticsProvider.ts
+++ b/packages/language-server/src/plugins/typescript-go/features/DiagnosticsProvider.ts
@@ -26,6 +26,7 @@ import { FileMap, FileSet } from '../../../lib/documents/fileCollection';
import { Logger } from '../../../logger';
import {
clamp,
+ isPositionEqual,
memoize,
normalizePath,
passMap,
@@ -55,6 +56,7 @@ import {
isInReactiveStatement,
isReactiveStatement
} from './utils';
+import { getAttributeContextAtPosition } from '../../../lib/documents/parseHtml';
const VIRTUAL_SUFFIX = '_virtual__';
const SVELTE_EXT_LENGTH = '.svelte'.length;
@@ -837,6 +839,9 @@ function mapAndFilterDiagnostics(
if (!hasNoNegativeLines(diagnostic) || !noFalsePositive(diagnostic)) {
continue;
}
+ if (isPositionEqual(diagnostic.range.start, diagnostic.range.end)) {
+ adjustDirectiveRange(diagnostic, document);
+ }
diagnostic = adjustIfNecessary(diagnostic, tsDoc.isSvelte5Plus);
diagnostic = swapDiagRangeStartEndIfNecessary(diagnostic);
@@ -846,6 +851,29 @@ function mapAndFilterDiagnostics(
return converted;
}
+function adjustDirectiveRange(diagnostic: Diagnostic, document: Document) {
+ const attributeContext = getAttributeContextAtPosition(document, diagnostic.range.start);
+ if (!attributeContext || attributeContext.inValue) {
+ return;
+ }
+
+ const colonIndex = attributeContext.name.indexOf(':');
+ if (colonIndex === -1) {
+ return;
+ }
+
+ const attributeStart = document
+ .getText()
+ .lastIndexOf(attributeContext.name, document.offsetAt(diagnostic.range.start));
+ const end = attributeStart + attributeContext.name.length;
+ const start = attributeContext.name.startsWith('bind:')
+ ? attributeStart
+ : attributeStart + colonIndex + 1;
+
+ diagnostic.range.start = document.positionAt(start);
+ diagnostic.range.end = document.positionAt(end);
+}
+
function flattenDiagnosticMessage(diag: tsApiSync.Diagnostic, level = 0): string {
if (!diag.messageChain) {
return diag.text;
diff --git a/packages/language-server/src/plugins/typescript/features/DiagnosticsProvider.ts b/packages/language-server/src/plugins/typescript/features/DiagnosticsProvider.ts
index 188eebcee..21282c172 100644
--- a/packages/language-server/src/plugins/typescript/features/DiagnosticsProvider.ts
+++ b/packages/language-server/src/plugins/typescript/features/DiagnosticsProvider.ts
@@ -27,10 +27,17 @@ import {
isStoreVariableIn$storeDeclaration,
get$storeOffsetOf$storeDeclaration
} from './utils';
-import { not, passMap, swapRangeStartEndIfNecessary, memoize } from '../../../utils';
+import {
+ not,
+ passMap,
+ swapRangeStartEndIfNecessary,
+ memoize,
+ isPositionEqual
+} from '../../../utils';
import { LSConfigManager } from '../../../ls-config';
import { isAttributeName, isEventHandler } from '../svelte-ast-utils';
import { internalHelpers } from 'svelte2tsx';
+import { getAttributeContextAtPosition } from '../../../lib/documents/parseHtml';
export enum DiagnosticCode {
MODIFIERS_CANNOT_APPEAR_HERE = 1184, // "Modifiers cannot appear here."
@@ -220,6 +227,10 @@ export function mapAndFilterDiagnostics(
continue;
}
+ if (isPositionEqual(diagnostic.range.start, diagnostic.range.end)) {
+ adjustDirectiveRange(diagnostic, document);
+ }
+
diagnostic = adjustIfNecessary(diagnostic, tsDoc.isSvelte5Plus);
diagnostic = swapDiagRangeStartEndIfNecessary(diagnostic);
converted.push(diagnostic);
@@ -228,6 +239,29 @@ export function mapAndFilterDiagnostics(
return converted;
}
+function adjustDirectiveRange(diagnostic: Diagnostic, document: Document) {
+ const attributeContext = getAttributeContextAtPosition(document, diagnostic.range.start);
+ if (!attributeContext || attributeContext.inValue) {
+ return;
+ }
+
+ const colonIndex = attributeContext.name.indexOf(':');
+ if (colonIndex === -1) {
+ return;
+ }
+
+ const attributeStart = document
+ .getText()
+ .lastIndexOf(attributeContext.name, document.offsetAt(diagnostic.range.start));
+ const end = attributeStart + attributeContext.name.length;
+ const start = attributeContext.name.startsWith('bind:')
+ ? attributeStart
+ : attributeStart + colonIndex + 1;
+
+ diagnostic.range.start = document.positionAt(start);
+ diagnostic.range.end = document.positionAt(end);
+}
+
function moveBindingErrorMessage(
tsDiag: ts.Diagnostic,
tsDoc: SvelteDocumentSnapshot,
diff --git a/packages/language-server/test/plugins/typescript-go/features/diagnostics/content-mapper-overrides.md b/packages/language-server/test/plugins/typescript-go/features/diagnostics/content-mapper-overrides.md
index 6d28098cd..6b03450e2 100644
--- a/packages/language-server/test/plugins/typescript-go/features/diagnostics/content-mapper-overrides.md
+++ b/packages/language-server/test/plugins/typescript-go/features/diagnostics/content-mapper-overrides.md
@@ -7,7 +7,6 @@
## By design
- `fixtures/parser-error`, `fixtures/svelte-element-error`: the Svelte plugin reports the compiler error, the middleware drops the mapper's duplicate. TS6 reported it as a TS diagnostic, too.
-- `fixtures/actions-animations-transitions-typechecks`: an element that doesn't fit a `transition:`/`use:` function is reported on the directive name, instead of TS6's empty range next to it.
## Not handled yet
diff --git a/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/actions-animations-transitions-typechecks/expected_tsgo.json b/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/actions-animations-transitions-typechecks/expected_tsgo.json
index 0f868c944..d6f218827 100644
--- a/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/actions-animations-transitions-typechecks/expected_tsgo.json
+++ b/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/actions-animations-transitions-typechecks/expected_tsgo.json
@@ -1,6 +1,6 @@
[
{
- "range": { "start": { "line": 9, "character": 19 }, "end": { "line": 9, "character": 19 } },
+ "range": { "start": { "line": 9, "character": 16 }, "end": { "line": 9, "character": 20 } },
"severity": 1,
"source": "ts",
"message": "Argument of type 'HTMLDivElement' is not assignable to parameter of type 'SVGElement & { getTotalLength(): number; }'.\n Type 'HTMLDivElement' is missing the following properties from type 'SVGElement': ownerSVGElement, viewportElement",
@@ -9,8 +9,8 @@
},
{
"range": {
- "start": { "line": 14, "character": 12 },
- "end": { "line": 14, "character": 12 }
+ "start": { "line": 14, "character": 7 },
+ "end": { "line": 14, "character": 13 }
},
"severity": 1,
"source": "ts",
diff --git a/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/actions-animations-transitions-typechecks/expected_tsgo_content_mapper.json b/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/actions-animations-transitions-typechecks/expected_tsgo_content_mapper.json
deleted file mode 100644
index d6f218827..000000000
--- a/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/actions-animations-transitions-typechecks/expected_tsgo_content_mapper.json
+++ /dev/null
@@ -1,21 +0,0 @@
-[
- {
- "range": { "start": { "line": 9, "character": 16 }, "end": { "line": 9, "character": 20 } },
- "severity": 1,
- "source": "ts",
- "message": "Argument of type 'HTMLDivElement' is not assignable to parameter of type 'SVGElement & { getTotalLength(): number; }'.\n Type 'HTMLDivElement' is missing the following properties from type 'SVGElement': ownerSVGElement, viewportElement",
- "code": 2345,
- "tags": []
- },
- {
- "range": {
- "start": { "line": 14, "character": 7 },
- "end": { "line": 14, "character": 13 }
- },
- "severity": 1,
- "source": "ts",
- "message": "Type 'HTMLParagraphElement' is missing the following properties from type 'HTMLInputElement': accept, alt, autocomplete, capture, and 55 more.",
- "code": 2740,
- "tags": []
- }
-]
diff --git a/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/actions-animations-transitions-typechecks/expectedv2.json b/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/actions-animations-transitions-typechecks/expectedv2.json
index eb27e43d0..55016e7a3 100644
--- a/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/actions-animations-transitions-typechecks/expectedv2.json
+++ b/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/actions-animations-transitions-typechecks/expectedv2.json
@@ -1,6 +1,6 @@
[
{
- "range": { "start": { "line": 9, "character": 19 }, "end": { "line": 9, "character": 19 } },
+ "range": { "start": { "line": 9, "character": 16 }, "end": { "line": 9, "character": 20 } },
"severity": 1,
"source": "ts",
"message": "Argument of type 'HTMLDivElement' is not assignable to parameter of type 'SVGElement & { getTotalLength(): number; }'.\n Type 'HTMLDivElement' is missing the following properties from type 'SVGElement': ownerSVGElement, viewportElement",
@@ -9,8 +9,8 @@
},
{
"range": {
- "start": { "line": 14, "character": 12 },
- "end": { "line": 14, "character": 12 }
+ "start": { "line": 14, "character": 7 },
+ "end": { "line": 14, "character": 13 }
},
"severity": 1,
"source": "ts",
diff --git a/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/element-binding/expectedv2.json b/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/element-binding/expectedv2.json
new file mode 100644
index 000000000..1d8d3d27b
--- /dev/null
+++ b/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/element-binding/expectedv2.json
@@ -0,0 +1,43 @@
+[
+ {
+ "range": { "start": { "line": 8, "character": 1 }, "end": { "line": 8, "character": 13 } },
+ "severity": 1,
+ "source": "ts",
+ "message": "Type 'string' is not assignable to type 'boolean | null | undefined'.",
+ "code": 2322,
+ "tags": []
+ },
+ {
+ "range": {
+ "start": { "line": 13, "character": 9 },
+ "end": { "line": 13, "character": 18 }
+ },
+ "severity": 1,
+ "source": "ts",
+ "message": "Type 'string' is not assignable to type 'boolean | null | undefined'.",
+ "code": 2322,
+ "tags": []
+ },
+ {
+ "range": {
+ "start": { "line": 14, "character": 23 },
+ "end": { "line": 14, "character": 35 }
+ },
+ "severity": 1,
+ "source": "ts",
+ "message": "Type 'string' is not assignable to type 'boolean | null | undefined'.",
+ "code": 2322,
+ "tags": []
+ },
+ {
+ "range": {
+ "start": { "line": 15, "character": 7 },
+ "end": { "line": 15, "character": 19 }
+ },
+ "severity": 1,
+ "source": "ts",
+ "message": "Type 'string' is not assignable to type 'boolean | null | undefined'.",
+ "code": 2322,
+ "tags": []
+ }
+]
diff --git a/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/element-binding/input.svelte b/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/element-binding/input.svelte
new file mode 100644
index 000000000..4c3639f65
--- /dev/null
+++ b/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/element-binding/input.svelte
@@ -0,0 +1,16 @@
+
+
+
+
+
text
+
+text
+
+
\ No newline at end of file
diff --git a/packages/svelte2tsx/src/htmlxtojsx_v2/index.ts b/packages/svelte2tsx/src/htmlxtojsx_v2/index.ts
index 9ed188605..6db386554 100644
--- a/packages/svelte2tsx/src/htmlxtojsx_v2/index.ts
+++ b/packages/svelte2tsx/src/htmlxtojsx_v2/index.ts
@@ -483,7 +483,8 @@ export function convertHtmlxToJsx(
options.typingsNamespace === 'svelteHTML',
options.svelte5Plus,
emitJsDoc,
- isTsFile
+ isTsFile,
+ options.spanMapGenerator
);
break;
case 'Class':
diff --git a/packages/svelte2tsx/src/htmlxtojsx_v2/nodes/Binding.ts b/packages/svelte2tsx/src/htmlxtojsx_v2/nodes/Binding.ts
index 03f4e7723..9f833849d 100644
--- a/packages/svelte2tsx/src/htmlxtojsx_v2/nodes/Binding.ts
+++ b/packages/svelte2tsx/src/htmlxtojsx_v2/nodes/Binding.ts
@@ -11,6 +11,7 @@ import { InlineComponent } from './InlineComponent';
import { surroundWithIgnoreComments } from '../../utils/ignore';
import { SequenceExpression } from 'estree';
import { getLeadingCommentTransformation, getTrailingCommentTransformation } from './Comment';
+import { mapGenerated, SpanMapGenerator } from '../../utils/spanMap';
/**
* List of binding names that are transformed to sth like `binding = variable`.
@@ -60,7 +61,8 @@ export function handleBinding(
preserveBind: boolean,
isSvelte5Plus: boolean,
emitJsDoc: boolean,
- isTsFile: boolean
+ isTsFile: boolean,
+ spanMapGenerator: SpanMapGenerator | undefined
): void {
const isGetSetBinding = attr.expression.type === 'SequenceExpression';
const [get, set] = isGetSetBinding ? (attr.expression as SequenceExpression).expressions : [];
@@ -148,27 +150,36 @@ export function handleBinding(
// other bindings which are transformed to normal attributes/props
const isShorthand = attr.expression.start === attr.start + 'bind:'.length;
- const name: TransformationArray =
- preserveBind && element instanceof Element
- ? // HTML typings - preserve the bind: prefix
- isShorthand
- ? [...leadingComments, `"${str.original.substring(attr.start, attr.end)}"`]
- : [
- ...leadingComments,
- '"',
- [attr.start, str.original.lastIndexOf('=', attr.expression.start)],
- '"'
+ let name: TransformationArray;
+ if (preserveBind && element instanceof Element) {
+ // HTML typings - preserve the bind: prefix
+ if (isShorthand) {
+ const withQuote = mapGenerated(
+ spanMapGenerator,
+ `"${str.original.substring(attr.start, attr.end)}"`,
+ [attr.start, attr.end]
+ );
+ name = [...leadingComments, withQuote];
+ } else {
+ const endIndex = str.original.lastIndexOf('=', attr.expression.start);
+ name = [...leadingComments, [attr.start, endIndex], '"'];
+ str.overwrite(attr.start, attr.start + 1, '"' + str.original.charAt(attr.start), {
+ contentOnly: true
+ });
+ spanMapGenerator?.addSourceSpan(attr.start, endIndex);
+ }
+ } else {
+ // Other typings - remove the bind: prefix
+ name = isShorthand
+ ? [...leadingComments, [attr.expression.start, attr.expression.end]]
+ : [
+ ...leadingComments,
+ [
+ attr.start + 'bind:'.length,
+ str.original.lastIndexOf('=', attr.expression.start)
]
- : // Other typings - remove the bind: prefix
- isShorthand
- ? [...leadingComments, [attr.expression.start, attr.expression.end]]
- : [
- ...leadingComments,
- [
- attr.start + 'bind:'.length,
- str.original.lastIndexOf('=', attr.expression.start)
- ]
- ];
+ ];
+ }
const value: TransformationArray | undefined = isShorthand
? preserveBind && element instanceof Element
diff --git a/packages/svelte2tsx/src/utils/spanMap.ts b/packages/svelte2tsx/src/utils/spanMap.ts
index 5a2864f6f..18a0a1f52 100644
--- a/packages/svelte2tsx/src/utils/spanMap.ts
+++ b/packages/svelte2tsx/src/utils/spanMap.ts
@@ -185,6 +185,7 @@ export class SpanMapGenerator {
const originalStart = original[segmentIndex];
const generatedStart = generated[segmentIndex];
if (this.ignoreMappings.has(originalStart)) {
+ current = undefined;
continue;
}
const sourceSpan = sourceSpanMap.get(originalStart);
diff --git a/packages/svelte2tsx/test/sourcemaps/samples/element-attributes/input.svelte b/packages/svelte2tsx/test/sourcemaps/samples/element-attributes/input.svelte
index 9c0ba7c4e..f4e77c6c4 100644
--- a/packages/svelte2tsx/test/sourcemaps/samples/element-attributes/input.svelte
+++ b/packages/svelte2tsx/test/sourcemaps/samples/element-attributes/input.svelte
@@ -22,4 +22,8 @@
+
+
\ No newline at end of file
diff --git a/packages/svelte2tsx/test/sourcemaps/samples/element-attributes/mappings.jsx b/packages/svelte2tsx/test/sourcemaps/samples/element-attributes/mappings.jsx
index 0ff7ce0f0..ddda147cf 100644
--- a/packages/svelte2tsx/test/sourcemaps/samples/element-attributes/mappings.jsx
+++ b/packages/svelte2tsx/test/sourcemaps/samples/element-attributes/mappings.jsx
@@ -133,25 +133,50 @@ async•()•=>•{•{•svelteHTML.createElement("element",•{"foo":true,});}
↲
/>↲ [original] line 21 (rest generated at line 13)
------------------------------------------------------------------------------------------------------------------------------------------------------ */}
- { svelteHTML.createElement("element", { "bind:foo":bar,});/*Ωignore_startΩ*/() => bar = __sveltets_2_any(null);/*Ωignore_endΩ*/}}; {/**
-•{•svelteHTML.createElement("element",•{•••"bind:foo":bar,});/*Ωignore_startΩ*/()•=>•bar•=•__sveltets_2_any(null);/*Ωignore_endΩ*/}};↲ [generated] line 15
-•{•svelteHTML.createElement("element",•{ " [generated] subset
-< element ↲
- bar = __sveltets_2_any(null);/*Ωignore_endΩ*/} {/**
+•{•svelteHTML.createElement("element",•{•••"bind:foo":bar,});/*Ωignore_startΩ*/()•=>•bar•=•__sveltets_2_any(null);/*Ωignore_endΩ*/}↲ [generated] line 15
+•{•svelteHTML.createElement("element",•{ [generated] subset
+< element
+•bar•=•__sveltets_2_any(null);/*Ωignore_endΩ*/}};↲ [generated] line 15
- •• bind:foo":bar,});/*Ωignore_startΩ*/()•=>•bar•=•__sveltets_2_any(null);/*Ωignore_endΩ*/}};↲ [generated] subset
- •{ bind:foo= bar}
- #== Order-breaking mappings
+•{•svelteHTML.createElement("element",•{•••"bind:foo":bar,});/*Ωignore_startΩ*/()•=>•bar•=•__sveltets_2_any(null);/*Ωignore_endΩ*/}↲ [generated] line 15
+ •• "bind:foo":bar,});/*Ωignore_startΩ*/()•=>•bar•=•__sveltets_2_any(null);/*Ωignore_endΩ*/} [generated] subset
+ •{ b ind:foo= bar}
+ #= Order-breaking mappings
• bind:foo={bar}
-••••bind:foo={bar}↲ [original] line 24
+••••bind:foo={bar}↲ [original] line 24
+
+•{•svelteHTML.createElement("element",•{•••"bind:foo":bar,});/*Ωignore_startΩ*/()•=>•bar•=•__sveltets_2_any(null);/*Ωignore_endΩ*/}↲ [generated] line 15
+ • ↲ [generated] subset
+ / ↲
+/ ↲
+/>↲ [original] line 25 (rest generated at line 16)
+------------------------------------------------------------------------------------------------------------------------------------------------------ */}
+ {/**
+↲ [generated] line 16
+ ↲
+/>↲ [original] line 25 (rest generated at line 15)
+------------------------------------------------------------------------------------------------------------------------------------------------------ */}
+ { svelteHTML.createElement("input", { "bind:checked":v,});/*Ωignore_startΩ*/() => v = __sveltets_2_any(null);/*Ωignore_endΩ*/}}; {/**
+•{•svelteHTML.createElement("input",•{••"bind:checked":v,});/*Ωignore_startΩ*/()•=>•v•=•__sveltets_2_any(null);/*Ωignore_endΩ*/}};↲ [generated] line 17
+•{•svelteHTML.createElement("input",•{ [generated] subset
+< input
+•v•=•__sveltets_2_any(null);/*Ωignore_endΩ*/}};↲ [generated] line 17
+ • "bind:checked":v,});/*Ωignore_startΩ*/()•=>•v•=•__sveltets_2_any(null);/*Ωignore_endΩ*/}};↲ [generated] subset
+ { b ind:checked= v}
+ #= Order-breaking mappings
+ bind:checked={v}
+╚bind:checked={v}↲ [original] line 28
-•{•svelteHTML.createElement("element",•{•••"bind:foo":bar,});/*Ωignore_startΩ*/()•=>•bar•=•__sveltets_2_any(null);/*Ωignore_endΩ*/}};↲ [generated] line 15
- • [generated] subset
- /
+•{•svelteHTML.createElement("input",•{••"bind:checked":v,});/*Ωignore_startΩ*/()•=>•v•=•__sveltets_2_any(null);/*Ωignore_endΩ*/}};↲ [generated] line 17
+ • [generated] subset
+ /
/
-/> [original] line 25
+/> [original] line 29
------------------------------------------------------------------------------------------------------------------------------------------------------ */}
return { props: /** @type {Record} */ ({}), slots: {}, events: {} }}
diff --git a/packages/svelte2tsx/test/sourcemaps/samples/element-attributes/span_mapping.txt b/packages/svelte2tsx/test/sourcemaps/samples/element-attributes/span_mapping.txt
index 5bbaad0c7..9f714f2fd 100644
--- a/packages/svelte2tsx/test/sourcemaps/samples/element-attributes/span_mapping.txt
+++ b/packages/svelte2tsx/test/sourcemaps/samples/element-attributes/span_mapping.txt
@@ -122,6 +122,8 @@
- •
# ^ [Atom] => 141-142
- /
+# ^^^^^^^^^^ [Atom],[None] => 131-139
+- bind:foo
# ^^^ [Verbatim] => 136-139
- foo
#
@@ -130,7 +132,7 @@
-
-
#
-> { svelteHTML.createElement("element", { "bind:foo":bar,});/*Ωignore_startΩ*/() => bar = __sveltets_2_any(null);/*Ωignore_endΩ*/}};
+> { svelteHTML.createElement("element", { "bind:foo":bar,});/*Ωignore_startΩ*/() => bar = __sveltets_2_any(null);/*Ωignore_endΩ*/}
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Ignore]
# [Verbatim] => 143-144
-
@@ -145,10 +147,37 @@
- {
# ^ [Atom] => 174-175
- /
+# ^ [Atom] => 159-159
+-
# ^^^^^^^^ [Verbatim] => 159-167
- bind:foo
# ^^^ [Verbatim] => 169-172
- bar
+#
+>
+# [Verbatim] => 176-177
+-
+-
+#
+> { svelteHTML.createElement("input", { "bind:checked":v,});/*Ωignore_startΩ*/() => v = __sveltets_2_any(null);/*Ωignore_endΩ*/}};
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Ignore]
+# [Verbatim] => 176-177
+-
+-
+#^ [Atom] => 178-179
+-<
+# ^^^^^ [Verbatim] => 179-184
+- input
+# ^ [Atom] => 199-200
+- {
+# ^ [Atom] => 203-204
+- /
+# ^ [Atom] => 186-186
+-
+# ^^^^^^^^^^^^ [Verbatim] => 186-198
+- bind:checked
+# ^ [Verbatim] => 200-201
+- v
>return { props: /** @type {Record} */ ({}), slots: {}, events: {} }}
>
>export default class Input__SvelteComponent_ extends __sveltets_2_createSvelte2TsxComponent(__sveltets_2_partial(__sveltets_2_with_any_event($$render()))) {
diff --git a/packages/svelte2tsx/test/sourcemaps/samples/element-attributes/test.jsx b/packages/svelte2tsx/test/sourcemaps/samples/element-attributes/test.jsx
index 82dd6d33c..66fd70cf0 100644
--- a/packages/svelte2tsx/test/sourcemaps/samples/element-attributes/test.jsx
+++ b/packages/svelte2tsx/test/sourcemaps/samples/element-attributes/test.jsx
@@ -1,23 +1,43 @@
-/** tested-ranges: [[80,3,"foo"],[107,3,"foo"],[136,3,"foo"],[169,3,"bar"]] */ {/**
+/** tested-ranges: [[9,3,"foo"],[30,3,"foo"],[52,3,"foo"],[57,4,"leet"],[80,3,"foo"],[84,3,"bar"],[107,3,"foo"],[136,3,"foo"],[159,8,"bind:foo"],[169,3,"bar"],[186,12,"bind:checked"],[200,1,"v"]] */{/**
------------------------------------------------------------------------------------------------------------------------------------------------------ */}
- foo={foo}bar {/**
- #== [generated] line 14 */}
+async () => { { svelteHTML.createElement("element", {"foo":true,});} {/**
+ #== [generated] line 3 */}
+ {/**
+ #== [original] line 1
+------------------------------------------------------------------------------------------------------------------------------------------------------ */}
+ { svelteHTML.createElement("element", { "foo":true,});} {/**
+ #== [generated] line 5 */}
+ foo {/**
+ #== [original] line 4
+------------------------------------------------------------------------------------------------------------------------------------------------------ */}
+ { svelteHTML.createElement("element", { "foo":`leet`,});} {/**
+ 1== 2=== [generated] line 7 */}
+ foo="leet" {/**
+ 1== 2=== [original] line 8
+------------------------------------------------------------------------------------------------------------------------------------------------------ */}
+ { svelteHTML.createElement("element", { foo,"bar":true,});} {/**
+ 1== 2== [generated] line 9 */}
{foo}bar {/**
- #== [original] line 12
+ 1== 2== [original] line 12
------------------------------------------------------------------------------------------------------------------------------------------------------ */}
- foo={foo} {/**
- #== [generated] line 18 */}
+ { svelteHTML.createElement("element", { foo,});} {/**
+ #== [generated] line 11 */}
{foo} {/**
- #== [original] line 16
+ #== [original] line 16
------------------------------------------------------------------------------------------------------------------------------------------------------ */}
- foo={foo} {/**
- #== [generated] line 22 */}
+ { svelteHTML.createElement("element", { "bind:foo":foo,});/*Ωignore_startΩ*/() => foo = __sveltets_2_any(null);/*Ωignore_endΩ*/} {/**
+ #== [generated] line 13 */}
bind:foo {/**
- #== [original] line 20
+ #== [original] line 20
------------------------------------------------------------------------------------------------------------------------------------------------------ */}
- foo={bar} {/**
- #== [generated] line 26 */}
+ { svelteHTML.createElement("element", { "bind:foo":bar,});/*Ωignore_startΩ*/() => bar = __sveltets_2_any(null);/*Ωignore_endΩ*/} {/**
+ 1======= 2== [generated] line 15 */}
bind:foo={bar} {/**
- #== [original] line 24
+ 1======= 2== [original] line 24
+------------------------------------------------------------------------------------------------------------------------------------------------------ */}
+ { svelteHTML.createElement("input", { "bind:checked":v,});/*Ωignore_startΩ*/() => v = __sveltets_2_any(null);/*Ωignore_endΩ*/}}; {/**
+ 1=========== 2 [generated] line 17 */}
+ bind:checked={v} {/**
+ 1=========== 2 [original] line 28
------------------------------------------------------------------------------------------------------------------------------------------------------ */}
-/** origin-hash: qds4w3 */
\ No newline at end of file
+/** origin-hash: 1n540c */
\ No newline at end of file
diff --git a/packages/svelte2tsx/test/sourcemaps/samples/large-sample-1/mappings.jsx b/packages/svelte2tsx/test/sourcemaps/samples/large-sample-1/mappings.jsx
index d3acd35a1..5379811c6 100644
--- a/packages/svelte2tsx/test/sourcemaps/samples/large-sample-1/mappings.jsx
+++ b/packages/svelte2tsx/test/sourcemaps/samples/large-sample-1/mappings.jsx
@@ -301,8 +301,8 @@ s ↲
------------------------------------------------------------------------------------------------------------------------------------------------------ */}
{ svelteHTML.createElement("svelte:window", { "bind:innerWidth":width,});/*Ωignore_startΩ*/() => width = __sveltets_2_any(null);/*Ωignore_endΩ*/} {/**
••{•svelteHTML.createElement("svelte:window",•{•"bind:innerWidth":width,});/*Ωignore_startΩ*/()•=>•width•=•__sveltets_2_any(null);/*Ωignore_endΩ*/}↲ [generated] line 126
-<> { bind:innerWidth= width} ↲
- #=============================================#= Order-breaking mappings
+<> {b ind:innerWidth= width} ↲
+ #=============================================# Order-breaking mappings
< bind:innerWidth={width} >↲
↲ [original] line 269 (rest generated at line 127)
------------------------------------------------------------------------------------------------------------------------------------------------------ */}
diff --git a/packages/svelte2tsx/test/sourcemaps/samples/large-sample-1/span_mapping.txt b/packages/svelte2tsx/test/sourcemaps/samples/large-sample-1/span_mapping.txt
index b9fbef798..effe75093 100644
--- a/packages/svelte2tsx/test/sourcemaps/samples/large-sample-1/span_mapping.txt
+++ b/packages/svelte2tsx/test/sourcemaps/samples/large-sample-1/span_mapping.txt
@@ -567,6 +567,8 @@
- >
# ^ [Atom] => 5618-5619
- {
+# ^ [Atom] => 5602-5602
+-
# ^^^^^^^^^^^^^^^ [Verbatim] => 5602-5617
- bind:innerWidth
# ^^^^^ [Verbatim] => 5619-5624