Skip to content

Commit 220fae9

Browse files
committed
Fixed possible NRE on MarkdownTextBlock.
1 parent eba3625 commit 220fae9

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

components/MarkdownTextBlock/src/MarkdownTextBlock.xaml.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ private static void OnTextChanged(DependencyObject d, DependencyPropertyChangedE
5454
{
5555
if (d is MarkdownTextBlock self && e.NewValue != null)
5656
{
57-
self.ApplyText(self.Text, true);
57+
self.ApplyText(true);
5858
}
5959
}
6060

@@ -87,16 +87,20 @@ private void ApplyConfig(MarkdownConfig config)
8787
}
8888
}
8989

90-
private void ApplyText(string text, bool rerender)
90+
private void ApplyText(bool rerender)
9191
{
92-
var markdown = Markdown.Parse(text, _pipeline);
9392
if (_renderer != null)
9493
{
9594
if (rerender)
9695
{
9796
_renderer.ReloadDocument();
9897
}
99-
_renderer.Render(markdown);
98+
99+
if (!string.IsNullOrEmpty(Text))
100+
{
101+
var markdown = Markdown.Parse(Text, _pipeline);
102+
_renderer.Render(markdown);
103+
}
100104
}
101105
}
102106

@@ -109,7 +113,7 @@ private void Build()
109113
_renderer = new WinUIRenderer(_document, Config);
110114
}
111115
_pipeline.Setup(_renderer);
112-
ApplyText(Text, false);
116+
ApplyText(false);
113117
}
114118
}
115119
}

0 commit comments

Comments
 (0)