From a010778ac6a40e2430fefb91c31afe5377b92e58 Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Tue, 18 Apr 2017 08:31:48 -0400 Subject: [PATCH] =?UTF-8?q?helpers=20should=20not=20be=20considered=20depe?= =?UTF-8?q?ndencies=20=E2=80=94=20fixes=20#492?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/generators/Generator.js | 4 +++- test/runtime/samples/dev-warning-helper/_config.js | 13 +++++++++++++ test/runtime/samples/dev-warning-helper/main.html | 11 +++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 test/runtime/samples/dev-warning-helper/_config.js create mode 100644 test/runtime/samples/dev-warning-helper/main.html diff --git a/src/generators/Generator.js b/src/generators/Generator.js index e16d43da04..39569cc1da 100644 --- a/src/generators/Generator.js +++ b/src/generators/Generator.js @@ -156,6 +156,8 @@ export default class Generator { let scope = annotateWithScopes( expression ); const dependencies = []; + const generator = this; // can't use arrow functions, because of this.skip() + walk( expression, { enter ( node, parent ) { if ( node._scope ) { @@ -165,7 +167,7 @@ export default class Generator { if ( isReference( node, parent ) ) { const { name } = flattenReference( node ); - if ( scope.has( name ) ) return; + if ( scope.has( name ) || generator.helpers.has( name ) ) return; if ( contextDependencies.has( name ) ) { dependencies.push( ...contextDependencies.get( name ) ); diff --git a/test/runtime/samples/dev-warning-helper/_config.js b/test/runtime/samples/dev-warning-helper/_config.js new file mode 100644 index 0000000000..b562b70b9e --- /dev/null +++ b/test/runtime/samples/dev-warning-helper/_config.js @@ -0,0 +1,13 @@ +export default { + solo: true, + + dev: true, + + data: { + bar: 1 + }, + + html: '2', + + warnings: [] +}; diff --git a/test/runtime/samples/dev-warning-helper/main.html b/test/runtime/samples/dev-warning-helper/main.html new file mode 100644 index 0000000000..f86e8fb09c --- /dev/null +++ b/test/runtime/samples/dev-warning-helper/main.html @@ -0,0 +1,11 @@ +{{foo(bar)}} + + \ No newline at end of file