Skip to content

fix: set tagName on NgView for Angular 21 bootstrap compatibility#167

Closed
Copilot wants to merge 2 commits into
mainfrom
copilot/17173d2e3714d8bcb23d466557d34fd627f79a07-fix-tagna
Closed

fix: set tagName on NgView for Angular 21 bootstrap compatibility#167
Copilot wants to merge 2 commits into
mainfrom
copilot/17173d2e3714d8bcb23d466557d34fd627f79a07-fix-tagna

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 27, 2026

This PR isolates commit 17173d2e3714d8bcb23d466557d34fd627f79a07 into a standalone change.
It addresses Angular 21 bootstrap behavior where locateHostElement reads rootElement.tagName.toLowerCase(), which can throw when NativeScript root elements lack a string tagName.

  • Root-element compatibility guard

    • Updated selectRootElement in packages/angular/src/lib/nativescript-renderer.ts to normalize all return paths through a local ensureTagName(...) helper.
    • Ensures returned views expose a string tagName (derived from nodeName, selector fallback, or 'view').
  • Behavioral scope

    • Applies to all existing selectRootElement branches:
      • direct View input
      • #id lookup path
      • string selector that creates/appends a view
      • default fallback to rootView
    • No unrelated files are modified.
const ensureTagName = (view: any, fallback: string) => {
  if (view && typeof view.tagName !== 'string') {
    try {
      view.tagName = view.nodeName || fallback || 'view';
    } catch {}
  }
  return view;
};
Original prompt

Create a pull request in NativeScript/angular that contains only commit 17173d2e3714d8bcb23d466557d34fd627f79a07 (fix: set tagName on NgView for Angular 21 bootstrap compatibility).

Requirements:

  • The PR should cherry-pick or otherwise include exactly the changes from commit 17173d2e3714d8bcb23d466557d34fd627f79a07 and no unrelated changes.
  • Use the commit message as the basis for the PR title: fix: set tagName on NgView for Angular 21 bootstrap compatibility.
  • The PR should modify only packages/angular/src/lib/nativescript-renderer.ts with the changes from that commit.
  • Base the PR against the repository's appropriate default/base branch unless repository context indicates otherwise.
  • In the PR description, mention that this isolates commit 17173d2e3714d8bcb23d466557d34fd627f79a07 into a standalone PR.

Context from the commit:

  • Parent commit: d9d49dcb532e88555293ee6a892112f7821c0b25
  • File changed: packages/angular/src/lib/nativescript-renderer.ts
  • Intent: ensure selectRootElement always returns a View with a string tagName so Angular 21 bootstrap compatibility checks do not throw when calling rootElement.tagName.toLowerCase().

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: Could you post a pull request with just this commit?

Assistant: I’m waiting for your confirmation on the pull request action, and once you approve it I can continue.

This pull request was created from Copilot chat.

Copilot AI changed the title [WIP] Fix: set tagName on NgView for Angular 21 bootstrap compatibility fix: set tagName on NgView for Angular 21 bootstrap compatibility May 27, 2026
Copilot AI requested a review from NathanWalker May 27, 2026 17:09
@NathanWalker
Copy link
Copy Markdown
Contributor

This is missing files, closing in favor of: #168

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants