[Feature] Util.HTMLHead.AddScriptFromUri and Util.HTMLHead.AddScript should support type=module
i.e. to enable scripts like this:
<script type="module"> import {a} from "./module.js"; alert(a); </script>
as it is now you have to roll your own injection of script element to get that
Note I tried:
var serverType = typeof(Util).Assembly.GetType("LINQPad.ExecutionModel.Server"); var server = serverType.GetProperty("CurrentServer").GetValue(null); server.Uncapsulate().InjectHtmlHeader($"<script type='module' src='{uri}'></script>\r\n");
but it seems to ignore the type attributes
so I had to write a javascript that added the script element to header
Comments
The problem is caused in the JavaScript that LINQPad generates to parse script attributes before adding them to the DOM - it only looks at specific attributes and hard-codes the type attribute. I'll fix this so that it enumerates over all attributes.
I'll also add a
AddScript (string type, string javaScript)
method and aAddRawHtml (string html)
method toHtmlHead
.This will appear in the LINQPad 8 preview, which should be out next week.
An early LINQPad 8 preview is now available:
https://www.linqpad.net/linqpad8.aspx
Let me know how you get on.