AUR0757
Error Message
AUR0757: The compiled template is not aligned with the render instructions. There are <target-count> targets and <instruction-count> instructions.
Where <target-count> is the number of target markers found in the HTML template and <instruction-count> is the number of rendering instructions generated by the compiler.
Description
This error signals a critical internal inconsistency discovered during the rendering process. Aurelia's template compiler first processes the HTML template, inserting markers (au-m="<id>") at locations where dynamic behavior (like bindings, custom elements, or attributes) needs to occur. It then generates a corresponding list of rendering instructions. At runtime, the renderer expects to find exactly one instruction for each marker in the template. This error occurs when the number of markers found in the DOM does not match the number of instructions generated during compilation.
Cause
This error should generally not occur in standard application development and usually points to a problem in the compilation process or manipulation of the template after compilation. Potential causes include:
Manual DOM Manipulation: Modifying the DOM of a compiled template after it has been compiled but before Aurelia renders it. This could involve adding or removing elements or changing attributes containing the
au-mmarkers, thus desynchronizing the DOM structure from the compiled instructions. This is the most likely cause if encountered. Avoid manipulating DOM managed by Aurelia directly.Template Compiler Bug: A bug in the template compiler might incorrectly generate markers or instructions, leading to a mismatch.
Custom Build Process Issues: A non-standard build process or tool that interferes with Aurelia's template compilation could corrupt the output.
Issues with
processContentHook: Although less likely to cause this specific error, incorrect manipulation of the template definition within a@processContenthook could potentially lead to inconsistencies if not done carefully.
Solution
Avoid Post-Compilation DOM Manipulation: The most crucial step is to never manually modify the DOM structure (especially adding/removing elements or
au-mmarkers) of templates that Aurelia manages after they have been processed by the compiler. Perform necessary structural changes via data binding, template controllers (if.bind,repeat.for), or within component logic before the template is compiled.Check Custom Build Steps: If you have custom build tools or steps interacting with Aurelia templates, ensure they do not interfere with the standard compilation process or modify the
au-mmarkers.Review
processContentHooks: If using@processContent, double-check that the hook logic correctly manipulates the template definition (the object passed to the hook) and does not introduce structural inconsistencies that the compiler cannot handle.Update Aurelia Packages: Ensure you are using the latest compatible versions of Aurelia, as compiler bugs are fixed over time.
Isolate and Reproduce: Try to identify the specific template or component causing the error. Simplify it to its bare minimum to see if the error persists. This helps determine if it's a specific template structure or a broader issue.
Report the Issue: If you suspect a bug in the Aurelia compiler after ruling out manual DOM manipulation and build issues, please report it with a minimal reproduction on the Aurelia GitHub repository.
Debugging Tips
Inspect the DOM structure of the failing component in the browser's developer tools. Look for the
au-mmarkers and compare their count and placement with what you'd expect based on the original HTML template.Review any code (application code, scripts, third-party libraries) that might be interacting with the DOM within the Aurelia application's root element.
Temporarily remove bindings, custom elements, and attributes from the problematic template one by one to see if a specific feature triggers the mismatch during compilation/rendering.
Last updated
Was this helpful?