Skip to content

Proxying components causes template to not render #243

@evoactivity

Description

@evoactivity

With a co-located component it's possible to proxy the component and everything works as it should.

import Component from '@glimmer/component';

class MyComponent extends Component {
  world = 'World';
}

const ProxiedComponent = new Proxy(MyComponent, {});

export default ProxiedComponent;

When using a template tag, the template fails to render, no errors are logged.

import Component from "@glimmer/component";

class MyComponent extends Component {
  world = "World";
  <template>
    Hello {{this.world}}
  </template>
}

const ProxiedComponent = new Proxy(MyComponent, {});

export default ProxiedComponent;

In the generated code for the colocated component the setComponentTemplate is applied to the proxy.

export default setComponentTemplate(TEMPLATE, ProxiedComponent);

This doesn't appear to be the case for a template tag component.

static {
    setComponentTemplate(createTemplateFactory(
    /*
      
        <div class={{this.classList}}>
          <h1>Tests {{this.count}}</h1>
          <button type="button" {{on "click" this.handleClick}}>Click me</button>
        </div>
      
    */
    {
      "id": "Hg3FL3Xg",
      "block": "[[[1,\"\\n    \"],[10,0],[15,0,[30,0,[\"classList\"]]],[12],[1,\"\\n      \"],[10,\"h1\"],[12],[1,\"Tests \"],[1,[30,0,[\"count\"]]],[13],[1,\"\\n      \"],[11,\"button\"],[24,4,\"button\"],[4,[32,0,[\"on\"]],[\"click\",[30,0,[\"handleClick\"]]],null],[12],[1,\"Click me\"],[13],[1,\"\\n    \"],[13],[1,\"\\n  \"]],[],false,[]]",
      "moduleName": "/Users/liam/Work/ember-vite/my-fancy-app/app/components/my-component.gjs",
      "scope": () => [template__imports__],
      "isStrictMode": true
    }), this);
  }

Reproduction repo https://github.com/evoactivity/ember-proxy-template-tag/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions