aurelia / aurelia/templating

processContent( ) functor which injects a <template> results in a stack overflow.

Open
#460 19 comments 0 reactions 0 assignees View on GitHub
bug has-pr question
Dominant language
TypeScript
Stars
113
Forks
101
PR merge metrics
No merged PRs in 30d

Description

If using an @processContent decorator on a custom element, and the processContent functor injects a template tag, then returns true, then Aurelia will crash with a stack overflow.

Simple example:

```
@customElement( "my-widget" )
@processContent( MyWidget.processContent )
export class MyWidget
{
static processContent( compiler: ViewCompiler, resources: ViewResources, node: HTMLElement, instruction: ( BehaviorInstruction & any ) ): Boolean
{
// NOTE: createChildElement is a helper that calls document.createElement then parent.appendChild.

let child: HTMLElement = DOMHelper.createChildElement( "template", node );
let child2: HTMLElement = DOMHelper.createChildElement( "p", child );

child2.appendChild( document.createTextNode( "small message" ) );

return true;
}
```

I have also tried the alternate way of making the "child node" of the template element a DocumentFragment, because I have noticed that if I specify a template as content to my widget, then it appears with the "node" passed into the processContent functor, like a Document fragment. For example:

```


Hello


```

All help greatly appreciated.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the stack overflow with the @processContent decorator and the custom element example that injects a containing a

. Trace the processContent functor and template compilation entry points, including the DocumentFragment variant, and verify that the example completes without recursive processing or a stack overflow.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.