From f1f4fd7729009bafb438327ef13ba895708f04f5 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Wed, 27 Mar 2024 19:58:14 -0400 Subject: [PATCH] Proper fix without deleting tests -- thanks @chancancode! --- .../integration/components/curly-components-test.js | 2 +- .../lib/plugins/assert-against-attrs.ts | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/@ember/-internals/glimmer/tests/integration/components/curly-components-test.js b/packages/@ember/-internals/glimmer/tests/integration/components/curly-components-test.js index 93c34a8ccf6..c05f150d74c 100644 --- a/packages/@ember/-internals/glimmer/tests/integration/components/curly-components-test.js +++ b/packages/@ember/-internals/glimmer/tests/integration/components/curly-components-test.js @@ -1269,7 +1269,7 @@ moduleFor( ['@test non-block with properties on this.attrs']() { this.registerComponent('non-block', { - template: 'In layout - someProp: {{this.attrs.someProp}}{{log this.attrs}}', + template: 'In layout - someProp: {{this.attrs.someProp}}', }); this.render('{{non-block someProp=this.prop}}', { diff --git a/packages/ember-template-compiler/lib/plugins/assert-against-attrs.ts b/packages/ember-template-compiler/lib/plugins/assert-against-attrs.ts index e2372ba1da4..3f21d3d7296 100644 --- a/packages/ember-template-compiler/lib/plugins/assert-against-attrs.ts +++ b/packages/ember-template-compiler/lib/plugins/assert-against-attrs.ts @@ -80,6 +80,18 @@ function isAttrs(node: AST.PathExpression, symbols: string[]) { return false; } + if (name === 'this' && node.head.type === 'ThisHead' && node.tail.includes('attrs')) { + // node.tail will be attrs.foo + // this makes it just foo (this.foo for the passed in node) + node.tail.shift(); + + // Deliberately do not say this is an "attrs" node. + // See this Deprecation RFC: https://github.com/emberjs/rfcs/pull/1016 + // and this discussion here: + // https://github.com/emberjs/ember.js/pull/20671 + return false; + } + if (name === 'attrs') { if (node.head.type === 'ThisHead') { node.tail.shift();