diff --git a/src/print/index.ts b/src/print/index.ts index 8de00406..14cd52c0 100644 --- a/src/print/index.ts +++ b/src/print/index.ts @@ -177,6 +177,8 @@ export function print(path: FastPath, options: ParserOptions, print: PrintFn): D node.type !== 'Element' || selfClosingTags.indexOf(node.name) !== -1); + // Order important: print attributes first + const attributes = path.map((childPath) => childPath.call(print), 'attributes'); let body: Doc; if (isEmpty) { @@ -206,7 +208,7 @@ export function print(path: FastPath, options: ParserOptions, print: PrintFn): D close, ]) : '', - ...path.map((childPath) => childPath.call(print), 'attributes'), + ...attributes, options.svelteBracketNewLine ? dedent(isSelfClosingTag ? line : softline) : '', @@ -439,7 +441,7 @@ export function print(path: FastPath, options: ParserOptions, print: PrintFn): D case 'Comment': { /** * If there is no sibling node that starts right after us but the parent indicates - * that there used to be, that means that node was actually an embedded `