diff --git a/packages/@ember/template-compiler/lib/plugins/auto-import-builtins.ts b/packages/@ember/template-compiler/lib/plugins/auto-import-builtins.ts index d7b08d78cb4..f3b5d98e815 100644 --- a/packages/@ember/template-compiler/lib/plugins/auto-import-builtins.ts +++ b/packages/@ember/template-compiler/lib/plugins/auto-import-builtins.ts @@ -60,7 +60,7 @@ function rewriteKeyword( ) { if (env.meta?.jsutils) { node.original = env.meta.jsutils.bindImport(moduleSpecifier, name, node, { - name, + nameHint: `__keyword__${name}`, }); } else if (env.meta?.emberRuntime) { node.original = env.meta.emberRuntime.lookupKeyword(name); diff --git a/smoke-tests/scenarios/basic-test.ts b/smoke-tests/scenarios/basic-test.ts index d28ae960829..dbe3ac0effd 100644 --- a/smoke-tests/scenarios/basic-test.ts +++ b/smoke-tests/scenarios/basic-test.ts @@ -442,6 +442,39 @@ function basicTest(scenarios: Scenarios, appName: string) { }); }); `, + 'lte-js-scope-polution-test.gjs': ` + import { module, test } from 'qunit'; + import { setupRenderingTest } from 'ember-qunit'; + import { render } from '@ember/test-helpers'; + + module('Using {{lte}} in a template should not bleed into outer javascript scope', function(hooks) { + setupRenderingTest(hooks); + + test('it works - but it should not', async function(assert) { + let a = 1; + let b = 2; + + function localLteHelper() { + try { + // this should not be define because it is not imported + return lte(...arguments); + } catch { + return 'WE COULD NOT FIND IT' + } + } + + await render( + + ); + + assert.dom('[data-local-lte]').hasText('WE COULD NOT FIND IT'); + assert.dom('[data-lte]').hasText('true'); + }); + }); + `, 'lt-lte-gt-gte-as-keyword-test.gjs': ` import { module, test } from 'qunit'; import { setupRenderingTest } from 'ember-qunit';