Merge pull request #1954 from sveltejs/gh-1873

preserve attributes during preprocess
pull/1956/head
Rich Harris 6 years ago committed by GitHub
commit 09b21fdba3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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

@ -151,6 +151,10 @@ describe('preprocess', () => {
<style type='text/scss' data-foo="bar" bool></style> <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, { return svelte.preprocess(source, {
style: ({ attributes }) => { style: ({ attributes }) => {
assert.deepEqual(attributes, { assert.deepEqual(attributes, {
@ -158,7 +162,10 @@ describe('preprocess', () => {
'data-foo': 'bar', 'data-foo': 'bar',
bool: true bool: true
}); });
return { code: 'PROCESSED' };
} }
}).then(processed => {
assert.equal(processed.toString(), expected);
}); });
}); });

Loading…
Cancel
Save