From 9ebc646db10723fcff9f865b9a71cc87688d87eb Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Fri, 29 Dec 2023 10:30:31 -0500 Subject: [PATCH 1/2] 'this' is undefined --- test-projects/gts/src/await.gts | 49 +++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 test-projects/gts/src/await.gts diff --git a/test-projects/gts/src/await.gts b/test-projects/gts/src/await.gts new file mode 100644 index 0000000..ac78c1e --- /dev/null +++ b/test-projects/gts/src/await.gts @@ -0,0 +1,49 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { isDestroyed, isDestroying } from '@ember/destroyable'; +import { waitForPromise } from '@ember/test-waiters'; + +import type { ComponentLike } from '@glint/template'; + +interface Args { + promise: Promise; +} + +export class Await extends Component { + @tracked resolved?: ComponentLike; + @tracked error?: Error; + + constructor(owner: unknown, args: Args) { + super(owner, args); + + let promise = args.promise + .then((resolved) => { + if (isDestroying(this) || isDestroyed(this)) return; + + this.resolved = resolved; + }) + .catch((error) => { + if (isDestroying(this) || isDestroyed(this)) return; + + this.error = error; + this.resolved = undefined; + }); + + waitForPromise(promise); + } + + get isPending() { + return !this.resolved; + } + + +} From 1c7f53842f1dd70ee138b79867cc938fdaf5dcc9 Mon Sep 17 00:00:00 2001 From: Patrick Pircher Date: Fri, 29 Dec 2023 16:47:06 +0100 Subject: [PATCH 2/2] do not check scope for `this` --- src/parser/transforms.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/parser/transforms.js b/src/parser/transforms.js index 54d65f7..130cd60 100644 --- a/src/parser/transforms.js +++ b/src/parser/transforms.js @@ -437,6 +437,7 @@ module.exports.convertAst = function convertAst(result, preprocessedResult, visi * it's NOT a standard html tag, it should have a referenced variable */ if ( + n.name !== 'this' && !n.name.startsWith(':') && scope && (variable ||