Skip to content

Commit

Permalink
Merge pull request #359 from ember-cli/bugfix/ensure-locals-are-used-…
Browse files Browse the repository at this point in the history
…everywher

[BUGFIX] Ensure locals are used instead of scope everywhere
  • Loading branch information
Chris Garrett committed Mar 21, 2021
2 parents e79b770 + dae410e commit 07c1a2f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion __tests__/template-literal-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ describe('htmlbars-inline-precompile: useTemplateLiteralProposalSemantics', func
expect(optionsReceived).toEqual({
contents: source,
isProduction: undefined,
scope: ['baz', 'foo', 'bar'],
locals: ['baz', 'foo', 'bar'],
strictMode: true,
});
});
Expand Down
2 changes: 1 addition & 1 deletion __tests__/template-tag-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ describe('htmlbars-inline-precompile: useTemplateTagProposalSemantics', function
expect(optionsReceived).toEqual({
contents: source,
isProduction: undefined,
scope: ['baz', 'foo', 'bar'],
locals: ['baz', 'foo', 'bar'],
strictMode: true,
});
});
Expand Down
6 changes: 3 additions & 3 deletions __tests__/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ describe('htmlbars-inline-precompile', function () {

ensureModuleApiPolyfill: false,
isProduction: true,
scope: null,
locals: null,
},
],
];
Expand Down Expand Up @@ -195,7 +195,7 @@ describe('htmlbars-inline-precompile', function () {
expect(optionsReceived).toEqual({
contents: source,
isProduction: true,
scope: null,
locals: null,
strictMode: false,
});
});
Expand Down Expand Up @@ -310,7 +310,7 @@ describe('htmlbars-inline-precompile', function () {
expect(optionsReceived).toEqual({
contents: source,
isProduction: undefined,
scope: null,
locals: null,
strictMode: false,
});
});
Expand Down
10 changes: 7 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,15 +383,19 @@ module.exports = function (babel) {
let template = path.node.quasi.quasis.map((quasi) => quasi.value.cooked).join('');

let { isProduction } = state.opts;
let scope = shouldUseAutomaticScope(options) ? getScope(path.scope) : null;
let locals = shouldUseAutomaticScope(options) ? getScope(path.scope) : null;
let strictMode = shouldUseStrictMode(options);

let emberIdentifier = state.ensureImport('createTemplateFactory', '@ember/template-factory');

replacePath(
path,
state,
compileTemplate(precompile, template, emberIdentifier, { isProduction, scope, strictMode }),
compileTemplate(precompile, template, emberIdentifier, {
isProduction,
locals,
strictMode,
}),
options
);
},
Expand Down Expand Up @@ -475,7 +479,7 @@ module.exports = function (babel) {
if (shouldUseAutomaticScope(options)) {
// If using the transform semantics, then users are not expected to pass
// options, so we override any existing scope
compilerOptions.scope = getScope(path.scope);
compilerOptions.locals = getScope(path.scope);
}

if (shouldUseStrictMode(options)) {
Expand Down

0 comments on commit 07c1a2f

Please sign in to comment.