mirror of https://github.com/sveltejs/svelte
parent
25a26613b3
commit
8e5c7ed21e
@ -1,9 +1,9 @@
|
|||||||
export default function removeObjectKey ( code, parsed, key ) {
|
export default function removeObjectKey ( generator, node, key ) {
|
||||||
if ( parsed.type !== 'ObjectExpression' ) return;
|
if ( node.type !== 'ObjectExpression' ) return;
|
||||||
const properties = parsed.properties;
|
const properties = node.properties;
|
||||||
const index = properties.findIndex( property => property.key.type === 'Identifier' && property.key.name === key );
|
const index = properties.findIndex( property => property.key.type === 'Identifier' && property.key.name === key );
|
||||||
if ( index === -1 ) return;
|
if ( index === -1 ) return;
|
||||||
const a = properties[ index ].start;
|
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 : properties[ index ].end;
|
||||||
code.remove( a, b );
|
generator.code.remove( a, b );
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in new issue