diff --git a/src/BootstrapBlazor.Server/Components/Components/Pre.razor.js b/src/BootstrapBlazor.Server/Components/Components/Pre.razor.js index 71bb71ce3b8..8e4e4323e77 100644 --- a/src/BootstrapBlazor.Server/Components/Components/Pre.razor.js +++ b/src/BootstrapBlazor.Server/Components/Components/Pre.razor.js @@ -55,7 +55,7 @@ export async function highlight(id) { if (el) { const invoke = () => { - hljs.highlightElement(el.querySelector('code')) + hljs.highlightElement(el.querySelector('code')); el.querySelector('.loading').classList.add('d-none') el.classList.remove('loaded') } @@ -64,6 +64,9 @@ export async function highlight(id) { const handler = setInterval(() => { const done = window.hljs !== void 0; if (done) { + hljs.configure({ + ignoreUnescapedHTML: true + }); clearInterval(handler) resolve() } diff --git a/src/BootstrapBlazor/Services/Serial/DefaultSerialService.cs b/src/BootstrapBlazor/Services/Serial/DefaultSerialService.cs index 0037cbd821e..09b6880ceca 100644 --- a/src/BootstrapBlazor/Services/Serial/DefaultSerialService.cs +++ b/src/BootstrapBlazor/Services/Serial/DefaultSerialService.cs @@ -27,8 +27,7 @@ public DefaultSerialService(IJSRuntime jsRuntime) private async Task LoadModule() { - var module = await _runtime.LoadModule("./_content/BootstrapBlazor/modules/serial.js") - ?? throw new InvalidOperationException("Load serial module failed"); + var module = await _runtime.LoadModule("./_content/BootstrapBlazor/modules/serial.js"); IsSupport = await module.InvokeAsync("init", _serialPortId); return module; diff --git a/test/UnitTest/Services/SerialServiceTest.cs b/test/UnitTest/Services/SerialServiceTest.cs index 625f8ed5c9c..bb936eb1efd 100644 --- a/test/UnitTest/Services/SerialServiceTest.cs +++ b/test/UnitTest/Services/SerialServiceTest.cs @@ -9,6 +9,7 @@ public class SerialServiceTest : BootstrapBlazorTestBase [Fact] public async Task GetPort_Ok() { + // https://itldg.github.io/web-serial-debug/?wt.mc_id=DT-MVP-5004174 网页串口调试工具 Context.JSInterop.Setup("init", matcher => matcher.Arguments.Count == 1 && (matcher.Arguments[0]?.ToString()?.StartsWith("bb_serial_") ?? false)).SetResult(true); Context.JSInterop.Setup("getPort", matcher => matcher.Arguments.Count == 1 && (matcher.Arguments[0]?.ToString()?.StartsWith("bb_serial_") ?? false)).SetResult(true); Context.JSInterop.Setup("open", matcher => matcher.Arguments.Count == 4 && (matcher.Arguments[0]?.ToString()?.StartsWith("bb_serial_") ?? false)).SetResult(true);