add support for self-closing style tags

pull/5082/head
lukasmoellerch 5 years ago
parent db0b3b3dfc
commit a1d6b79ffc

@ -114,8 +114,8 @@ export default async function preprocess(
for (const fn of style) {
source = await replace_async(
source,
/<!--[^]*?-->|<style(\s[^]*?)?>([^]*?)<\/style>/gi,
async (match, attributes = '', content) => {
/<!--[^]*?-->|<style(\s[^]*?)?(?:>([^]*?)<\/style>|\/>)/gi,
async (match, attributes = '', content = '') => {
if (!attributes && !content) {
return match;
}

@ -0,0 +1,12 @@
import * as assert from "assert";
export default {
preprocess: {
style: ({ content, attributes: { color } }) => {
assert.equal(content, "");
return {
code: `div { color: ${color}; }`
};
}
}
};

@ -0,0 +1,3 @@
<div class='brand-color'>$brand</div>
<style color="red"/>

@ -0,0 +1,3 @@
<div class='brand-color'>$brand</div>
<style color="red">div { color: red; }</style>
Loading…
Cancel
Save