Fix for anonymousTemplate and nativeTemplateEngine#232
Conversation
fix) anonymousTemplate correction for typescript class porting
📝 WalkthroughWalkthroughReplaced IE-specific branching in template node retrieval with a direct call to Changes
Sequence Diagram(s)(omitted — changes are type/signature and branching simplifications without a multi-component control-flow that benefits from a sequence diagram) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (4)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/binding.template/src/nativeTemplateEngine.tspackages/binding.template/src/templateSources.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: testheadless (24, test-headless-ff)
🔇 Additional comments (3)
packages/binding.template/src/templateSources.ts (2)
33-34: LGTM! Anonymous template type properly defined.The new
templateAnonymousconstant establishes a distinct template type for anonymous templates, fixing the issue where they previously had undefinedtemplateTypevalues. This aligns with the PR objective of fixing anonymous template behavior.
59-60: No issues identified. The fields are internal implementation details with no external accesses detected, making the visibility restriction toprotecteda safe and beneficial encapsulation improvement.packages/binding.template/src/nativeTemplateEngine.ts (1)
17-24: LGTM! Template node retrieval now works correctly.The simplified logic properly fixes Case 1 from the PR objectives by:
- Using feature detection (
templateSource.nodes ? ...) instead of IE version checks- Actually calling
templateSource.nodes()when available, enabling thecloneNodepath (line 20) that was previously unreachable- Falling back to text-based parsing when nodes are unavailable (lines 22-23)
This modernization removes legacy IE-specific branching while restoring the intended behavior of preferring DOM nodes over text when available.
brianmhunt
left a comment
There was a problem hiding this comment.
Great spotting. It would be good to have tests that verify / prevent a regression, but that doesnt block here. Thank you!
Unfortunately, we made two mistakes during the TypeScript porting. Error 1 also masked error 2.
Case 1: nativeTemplateEngine -> The cloneNode function was never used in the native template engine.

Case 2: anonymousTemplate -> The old prototyp construct uses an empty-constructor from domElement, so templateType and element was 'undefined'. I had changed this, so after correcting Case 1, the anonymous templates tests no longer worked.

This all came to light when I started dismantling old IE switches. Here are the fixes.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.