diff --git a/src/generate/index.js b/src/generate/index.js index 877485939d..197e684262 100644 --- a/src/generate/index.js +++ b/src/generate/index.js @@ -137,8 +137,8 @@ export default function generate ( parsed, source, options, names ) { if ( isReference( node, parent ) ) { const { name } = flattenReference( node ); - if ( parent && parent.type === 'CallExpression' && node === parent.callee ) { - if ( generator.helpers[ name ] ) generator.code.prependRight( node.start, `template.helpers.` ); + if ( parent && parent.type === 'CallExpression' && node === parent.callee && generator.helpers[ name ] ) { + generator.code.prependRight( node.start, `template.helpers.` ); return; } diff --git a/test/generator/computed-function/_config.js b/test/generator/computed-function/_config.js new file mode 100644 index 0000000000..018eb9f3f0 --- /dev/null +++ b/test/generator/computed-function/_config.js @@ -0,0 +1,14 @@ +export default { + html: '
50
', + + test ( assert, component, target ) { + component.set({ range: [ 50, 100 ] }); + assert.htmlEqual( target.innerHTML, '75
' ); + + component.set({ range: [ 50, 60 ] }); + assert.htmlEqual( target.innerHTML, '55
' ); + + component.set({ x: 8 }); + assert.htmlEqual( target.innerHTML, '58
' ); + } +}; diff --git a/test/generator/computed-function/main.html b/test/generator/computed-function/main.html new file mode 100644 index 0000000000..f3fc14727d --- /dev/null +++ b/test/generator/computed-function/main.html @@ -0,0 +1,20 @@ +{{scale(x)}}
+ + diff --git a/test/generator/default-data-function/_config.js b/test/generator/default-data-function/_config.js new file mode 100644 index 0000000000..94658e5450 --- /dev/null +++ b/test/generator/default-data-function/_config.js @@ -0,0 +1,8 @@ +export default { + html: '