Conform more code to strict null checking (#10169)
* Conform more code to strict null checking * delint * Iterate * delint * Fix bad test
This commit is contained in:
parent
5123d7e641
commit
e8b92b308b
85 changed files with 283 additions and 287 deletions
|
@ -190,6 +190,8 @@ function getTextAndOffsetToNode(editor: HTMLDivElement, selectionNode: Node): {
|
|||
// get text value of text node, ignoring ZWS if it's a caret node
|
||||
function getTextNodeValue(node: Node): string {
|
||||
const nodeText = node.nodeValue;
|
||||
if (!nodeText) return "";
|
||||
|
||||
// filter out ZWS for caret nodes
|
||||
if (isCaretNode(node.parentElement)) {
|
||||
// typed in the caret node, so there is now something more in it than the ZWS
|
||||
|
@ -200,9 +202,9 @@ function getTextNodeValue(node: Node): string {
|
|||
// only contains ZWS, which is ignored, so return empty string
|
||||
return "";
|
||||
}
|
||||
} else {
|
||||
return nodeText;
|
||||
}
|
||||
|
||||
return nodeText;
|
||||
}
|
||||
|
||||
export function getRangeForSelection(editor: HTMLDivElement, model: EditorModel, selection: Selection): Range {
|
||||
|
|
|
@ -424,7 +424,7 @@ class RoomPillPart extends PillPart {
|
|||
let initialLetter = "";
|
||||
let avatarUrl = Avatar.avatarUrlForRoom(this.room, 16, 16, "crop");
|
||||
if (!avatarUrl) {
|
||||
initialLetter = Avatar.getInitialLetter(this.room?.name || this.resourceId);
|
||||
initialLetter = Avatar.getInitialLetter(this.room?.name || this.resourceId) ?? "";
|
||||
avatarUrl = Avatar.defaultAvatarUrlForString(this.room?.roomId ?? this.resourceId);
|
||||
}
|
||||
this.setAvatarVars(node, avatarUrl, initialLetter);
|
||||
|
@ -478,7 +478,7 @@ class UserPillPart extends PillPart {
|
|||
const avatarUrl = Avatar.avatarUrlForMember(this.member, 16, 16, "crop");
|
||||
let initialLetter = "";
|
||||
if (avatarUrl === defaultAvatarUrl) {
|
||||
initialLetter = Avatar.getInitialLetter(name);
|
||||
initialLetter = Avatar.getInitialLetter(name) ?? "";
|
||||
}
|
||||
this.setAvatarVars(node, avatarUrl, initialLetter);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue