diff --git a/src/generators/dom/index.js b/src/generators/dom/index.js index ebf478f5a2..c0541b8959 100644 --- a/src/generators/dom/index.js +++ b/src/generators/dom/index.js @@ -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 { diff --git a/src/utils/removeObjectKey.js b/src/utils/removeObjectKey.js index cbd75eb1f5..a78a5b6ab2 100644 --- a/src/utils/removeObjectKey.js +++ b/src/utils/removeObjectKey.js @@ -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 ); } diff --git a/test/generator/samples/imported-renamed-components/main.html b/test/generator/samples/imported-renamed-components/main.html index 7c25eaceab..a976830378 100644 --- a/test/generator/samples/imported-renamed-components/main.html +++ b/test/generator/samples/imported-renamed-components/main.html @@ -5,6 +5,6 @@ import ComponentTwo from './ComponentTwo.html'; export default { - components: { RenamedComponentOne: ComponentOne, RenamedComponentTwo: ComponentTwo } + components: { RenamedComponentOne: ComponentOne, RenamedComponentTwo: ComponentTwo }, };