AUR0762

Error Message

AUR0762: Trying to retrieve a custom element controller from a node, but the provided node <{{nodeName}} /> is not a custom element or containerless host.

Where {{nodeName}} is the tag name (or #comment for comment nodes) of the provided DOM node.

Description

This error occurs when calling CustomElement.for(node) (or an API that uses it) with a DOM node that is not the host element (or containerless marker) of an Aurelia custom element instance.

Example Trigger

import { CustomElement } from '@aurelia/runtime-html';

// ❌ Passing a normal element instead of a custom element host
const div = document.querySelector('div')!;
CustomElement.for(div); // throws AUR0762

Correct Usage

  • Pass the actual host element of the custom element instance (for example the <my-component> element).

  • For containerless custom elements, the host is a comment marker node; prefer alternative access patterns (DI, parent/child relationships) rather than trying to locate the marker manually.

Troubleshooting

  • Verify you are not passing a node inside a component’s template (use the component host instead).

  • Ensure the node is part of the Aurelia-managed DOM tree for the app instance you are querying.

  • If you are calling this too early, wait until attached() (or after composition completes).

Last updated

Was this helpful?