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