From 8427bde679133a2b1556cb24d4cb73a0fb5efb1c Mon Sep 17 00:00:00 2001 From: Conduitry Date: Thu, 3 Jan 2019 13:20:56 -0500 Subject: [PATCH] preserve attributes during preprocess (#1873) --- src/preprocess/index.ts | 2 +- test/preprocess/index.js | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/preprocess/index.ts b/src/preprocess/index.ts index 5abde887dc..5537b30ea1 100644 --- a/src/preprocess/index.ts +++ b/src/preprocess/index.ts @@ -60,7 +60,7 @@ export default async function preprocess( attributes: parseAttributes(attributes), filename: options.filename, })); - return processed ? `<${type}>${processed.code}` : match; + return processed ? `<${type}${attributes}>${processed.code}` : match; } ); } diff --git a/test/preprocess/index.js b/test/preprocess/index.js index 14b483ce51..10661efd39 100644 --- a/test/preprocess/index.js +++ b/test/preprocess/index.js @@ -151,6 +151,10 @@ describe('preprocess', () => { `; + const expected = ` + + `; + return svelte.preprocess(source, { style: ({ attributes }) => { assert.deepEqual(attributes, { @@ -158,7 +162,10 @@ describe('preprocess', () => { 'data-foo': 'bar', bool: true }); + return { code: 'PROCESSED' }; } + }).then(processed => { + assert.equal(processed.toString(), expected); }); });