mirror of
https://github.com/sveltejs/svelte.git
synced 2024-12-01 17:30:59 +01:00
Merge pull request #393 from sveltejs/removeobjectkey-fix
Fix removing last key in object when it has a trailing comma
This commit is contained in:
commit
b5c971cba4
@ -206,8 +206,8 @@ export default function dom ( parsed, source, options, names ) {
|
||||
}
|
||||
});
|
||||
if ( hasNonImportedComponent ) {
|
||||
// remove the specific components which were imported, as we'll refer to them directly
|
||||
Object.keys( generator.importedComponents ).forEach ( key => {
|
||||
// remove the specific components that were imported, as we'll refer to them directly
|
||||
Object.keys( generator.importedComponents ).forEach( key => {
|
||||
removeObjectKey( generator, templateProperties.components.value, key );
|
||||
});
|
||||
} else {
|
||||
|
@ -4,6 +4,6 @@ export default function removeObjectKey ( generator, node, key ) {
|
||||
const index = properties.findIndex( property => property.key.type === 'Identifier' && property.key.name === key );
|
||||
if ( index === -1 ) return;
|
||||
const a = properties[ index ].start;
|
||||
const b = index < properties.length - 1 ? properties[ index + 1 ].start : properties[ index ].end;
|
||||
const b = index < properties.length - 1 ? properties[ index + 1 ].start : node.end - 1;
|
||||
generator.code.remove( a, b );
|
||||
}
|
||||
|
@ -5,6 +5,6 @@
|
||||
import ComponentTwo from './ComponentTwo.html';
|
||||
|
||||
export default {
|
||||
components: { RenamedComponentOne: ComponentOne, RenamedComponentTwo: ComponentTwo }
|
||||
components: { RenamedComponentOne: ComponentOne, RenamedComponentTwo: ComponentTwo },
|
||||
};
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user