diff --git a/src/generators/dom/index.js b/src/generators/dom/index.js index 91c1085082..ebf478f5a2 100644 --- a/src/generators/dom/index.js +++ b/src/generators/dom/index.js @@ -191,7 +191,7 @@ export default function dom ( parsed, source, options, names ) { const ns = templateProperties.namespace.value.value; namespace = namespaces[ ns ] || ns; - removeObjectKey( generator.code, defaultExport.declaration, 'namespace' ); + removeObjectKey( generator, defaultExport.declaration, 'namespace' ); } if ( templateProperties.components ) { @@ -208,11 +208,11 @@ 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 => { - removeObjectKey( generator.code, templateProperties.components.value, key ); + removeObjectKey( generator, templateProperties.components.value, key ); }); } else { // remove the entire components portion of the export - removeObjectKey( generator.code, defaultExport.declaration, 'components' ); + removeObjectKey( generator, defaultExport.declaration, 'components' ); } } diff --git a/src/utils/removeObjectKey.js b/src/utils/removeObjectKey.js index 7399a6a2bb..cbd75eb1f5 100644 --- a/src/utils/removeObjectKey.js +++ b/src/utils/removeObjectKey.js @@ -1,9 +1,9 @@ -export default function removeObjectKey ( code, parsed, key ) { - if ( parsed.type !== 'ObjectExpression' ) return; - const properties = parsed.properties; +export default function removeObjectKey ( generator, node, key ) { + if ( node.type !== 'ObjectExpression' ) return; + const properties = node.properties; 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; - code.remove( a, b ); + generator.code.remove( a, b ); }