0
0
mirror of https://github.com/sveltejs/svelte.git synced 2024-12-01 17:30:59 +01:00

Merge pull request #1954 from sveltejs/gh-1873

preserve attributes during preprocess
This commit is contained in:
Rich Harris 2019-01-03 14:03:26 -05:00 committed by GitHub
commit 09b21fdba3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -60,7 +60,7 @@ export default async function preprocess(
attributes: parseAttributes(attributes),
filename: options.filename,
}));
return processed ? `<${type}>${processed.code}</${type}>` : match;
return processed ? `<${type}${attributes}>${processed.code}</${type}>` : match;
}
);
}

View File

@ -151,6 +151,10 @@ describe('preprocess', () => {
<style type='text/scss' data-foo="bar" bool></style>
`;
const expected = `
<style type='text/scss' data-foo="bar" bool>PROCESSED</style>
`;
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);
});
});