Skip to content

Commit 3c03ad4

Browse files
authored
fix(material/schematics): add undefined check (#26081)
* potential fix for issue #26038
1 parent 936741c commit 3c03ad4

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/material/schematics/ng-generate/mdc-migration/rules/tree-traversal.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,13 @@ export function updateAttribute(
164164
}
165165

166166
const attr = node.attributes[0];
167-
const ctx = attr.sourceSpan.start.getContext(attr.sourceSpan.start.col + 1, 1)!;
168-
const indentation = ctx.before;
167+
if (attr) {
168+
const ctx = attr.sourceSpan.start.getContext(attr.sourceSpan.start.col + 1, 1)!;
169+
const indentation = ctx.before;
170+
return prefix + indentation + attrText + suffix;
171+
}
169172

170-
return prefix + indentation + attrText + suffix;
173+
return prefix + attrText + suffix;
171174
}
172175

173176
/**

0 commit comments

Comments
 (0)