Merge pull request #2332 from sveltejs/preprocess-partial-names

don't preprocess tags whose names begin with script/style
pull/2341/head
Rich Harris 6 years ago committed by GitHub
commit 9e4775704a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -95,8 +95,8 @@ export default async function preprocess(
for (const fn of script) { for (const fn of script) {
source = await replace_async( source = await replace_async(
source, source,
/<script([^]*?)>([^]*?)<\/script>/gi, /<script(\s[^]*?)?>([^]*?)<\/script>/gi,
async (match, attributes, content) => { async (match, attributes = '', content) => {
const processed: Processed = await fn({ const processed: Processed = await fn({
content, content,
attributes: parse_attributes(attributes), attributes: parse_attributes(attributes),
@ -111,8 +111,8 @@ export default async function preprocess(
for (const fn of style) { for (const fn of style) {
source = await replace_async( source = await replace_async(
source, source,
/<style([^]*?)>([^]*?)<\/style>/gi, /<style(\s[^]*?)?>([^]*?)<\/style>/gi,
async (match, attributes, content) => { async (match, attributes = '', content) => {
const processed: Processed = await fn({ const processed: Processed = await fn({
content, content,
attributes: parse_attributes(attributes), attributes: parse_attributes(attributes),

@ -0,0 +1,6 @@
export default {
preprocess: {
script: () => ({ code: '' }),
style: () => ({ code: '' })
}
};

@ -0,0 +1,12 @@
<script-foo>
foo
</script-foo>
<script>
// bar
</script>
<style-foo>
foo
</style-foo>
<style>
bar {}
</style>

@ -0,0 +1,8 @@
<script-foo>
foo
</script-foo>
<script></script>
<style-foo>
foo
</style-foo>
<style></style>
Loading…
Cancel
Save