Home General
Options

ClearResults removes styles from HtmlHead

Hello!

When using Util.HtmlHead.AddStyles, LINQPad will remember the injected HTML header content so that repeated calls with the same string will not result in duplicated injections. This is all good and works pretty well.

However, when using Util.ClearResults() to clear the results panel, these injected styles are also removed and even if you have calls to AddStyles, the styles are still not readded (since they are still cached).

Here’s a quick example:

Util.HtmlHead.AddStyles(".test { color: red; }");
Util.WithCssClass("Test!", "test").Dump();

Util.ClearResults();

Util.HtmlHead.AddStyles(".test { color: red; }");
Util.WithCssClass("Test!", "test").Dump();

It would be nice, if this could be modified that either ClearResults will readd the cached injected headers or that it will clear the cache so that later calls to AddStyle can readd the headers.

Comments

  • edited July 8

    Ctrl+Alt+X and F5 produce different results. Multiple F5s are inconsistent when executed after Ctrl+Alt+X. LINQPad 8 Windows beta.

    Util.HtmlHead.AddStyles(".test { color: red; }");
    Util.WithCssClass("Test!", "test").Dump();
    
    Util.ClearResults();
    
    "----".Dump(); // Added Dump to create HTML, without it multiple `Ctrl+Alt+X`s are inconsistent.
    
    Util.HtmlHead.AddStyles(".test { color: red; };"); // Appended ; to style, otherwise there is no effect.
    Util.WithCssClass("Test!", "test").Dump();
    
Sign In or Register to comment.