Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX] Ensure locals are used instead of scope everywhere #359

Merged
merged 1 commit into from
Mar 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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