@nativescript/angular 21.0.1-alpha.7 → 21.0.1-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -22,6 +22,7 @@ class InvisibleNode extends View {
|
|
|
22
22
|
this.name = name;
|
|
23
23
|
this.nodeType = 1;
|
|
24
24
|
this.nodeName = getClassName(this);
|
|
25
|
+
this.tagName = this.nodeName;
|
|
25
26
|
}
|
|
26
27
|
toString() {
|
|
27
28
|
return `${this.nodeName}(${this.id})-${this.name}`;
|
|
@@ -3144,6 +3145,12 @@ class ViewUtil {
|
|
|
3144
3145
|
}
|
|
3145
3146
|
const ngView = view;
|
|
3146
3147
|
ngView.nodeName = name;
|
|
3148
|
+
// Angular 21+ reads `rootElement.tagName.toLowerCase()` during component bootstrap
|
|
3149
|
+
// (`locateHostElement`) to reject `<script>` host elements. Native Views have no
|
|
3150
|
+
// intrinsic `tagName`, so without this assignment the boot throws
|
|
3151
|
+
// `Cannot read properties of undefined (reading 'toLowerCase')`. Mirror DOM
|
|
3152
|
+
// conventions where `tagName` equals `nodeName` for element nodes.
|
|
3153
|
+
ngView.tagName = name;
|
|
3147
3154
|
ngView.meta = getViewMeta(name);
|
|
3148
3155
|
// we're setting the node type of the view
|
|
3149
3156
|
// to 'element' because of checks done in the
|
|
@@ -3545,22 +3552,35 @@ class NativeScriptRenderer {
|
|
|
3545
3552
|
if (NativeScriptDebug.enabled) {
|
|
3546
3553
|
NativeScriptDebug.rendererLog(`NativeScriptRenderer.selectRootElement: ${selectorOrNode}`);
|
|
3547
3554
|
}
|
|
3555
|
+
// Angular 21+ reads `rootElement.tagName.toLowerCase()` after this call
|
|
3556
|
+
// (`locateHostElement`) to reject `<script>` hosts. Guarantee every return
|
|
3557
|
+
// path produces a View with a non-empty string `tagName`; otherwise the
|
|
3558
|
+
// bootstrap throws `Cannot read properties of undefined (reading 'toLowerCase')`.
|
|
3559
|
+
const ensureTagName = (view, fallback) => {
|
|
3560
|
+
if (view && typeof view.tagName !== 'string') {
|
|
3561
|
+
try {
|
|
3562
|
+
view.tagName = view.nodeName || fallback || 'view';
|
|
3563
|
+
}
|
|
3564
|
+
catch { }
|
|
3565
|
+
}
|
|
3566
|
+
return view;
|
|
3567
|
+
};
|
|
3548
3568
|
if (selectorOrNode instanceof View) {
|
|
3549
|
-
return selectorOrNode;
|
|
3569
|
+
return ensureTagName(selectorOrNode, '');
|
|
3550
3570
|
}
|
|
3551
3571
|
if (selectorOrNode && selectorOrNode[0] === '#') {
|
|
3552
3572
|
const result = getViewById(this.rootView, selectorOrNode.slice(1));
|
|
3553
|
-
return (result || this.rootView);
|
|
3573
|
+
return ensureTagName((result || this.rootView), selectorOrNode);
|
|
3554
3574
|
}
|
|
3555
3575
|
if (typeof selectorOrNode === 'string') {
|
|
3556
3576
|
const view = this.viewUtil.createView(selectorOrNode);
|
|
3557
3577
|
if (getFirstNativeLikeView(view) === view) {
|
|
3558
3578
|
// view is nativelike!
|
|
3559
3579
|
this.appendChild(this.rootView, view);
|
|
3560
|
-
return view;
|
|
3580
|
+
return ensureTagName(view, selectorOrNode);
|
|
3561
3581
|
}
|
|
3562
3582
|
}
|
|
3563
|
-
return this.rootView;
|
|
3583
|
+
return ensureTagName(this.rootView, '');
|
|
3564
3584
|
}
|
|
3565
3585
|
parentNode(node) {
|
|
3566
3586
|
if (NativeScriptDebug.enabled) {
|