-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Description
How important is this feature to you?
zero to low priority, mostly cosmetic. browsers ignore extra attributes like <script lang="ts">
Is your feature request related to a problem? Please describe.
currently, preprocessors can not change tag attributes
for example
<script lang="ts">export let name: string</script>
can only be transformed to
<script lang="ts">export let name</script>
but not to
<script>export let name</script>
because preprocessors can only read attributes, but not change them
Describe the solution you'd like
allow preprocessors to to modify attributes
by returning the new attributes in result.attributes
for example, the typescript preprocessor could do
if (attributes.lang != 'ts') return;
delete attributes.lang;
code = compile(code);
return { code, map, attributes };
Describe alternatives you've considered
do nothing, and let browsers ignore extra attributes
related code
svelte/src/compiler/preprocess/index.ts
Lines 274 to 285 in 32775a6
const processed = await preprocessor({ | |
content, | |
attributes: parse_attributes(attributes), | |
filename | |
}); | |
if (processed && processed.dependencies) { | |
dependencies.push(...processed.dependencies); | |
} | |
if (!processed || !processed.map && processed.code === content) { | |
return no_change(); | |
} | |
return get_replacement(file_basename, offset, get_location, content, processed, `<${tag_name}${attributes}>`, `</${tag_name}>`); |