-
-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add attribute scrubbing to documentation for blazor:elementreference #373
Comments
shouldnt this be scrubbed by default? |
I would vote yes |
Given i faced the same problem there are 2 scrubbers i found helpful: VerifierSettings.ScrubInlineGuids(); will replace the second one is remove noise when you don't care about event's or those special blazor attributes at all (but just passing down some parameters to a child component and make sure they got propagated: Thanks ChatGPT for the solution: // Add custom scrubber for blazor:xxx attributes
VerifierSettings.ScrubLinesWithReplace(s =>
{
if(!s.Contains("blazor:"))
{
return s;
}
// Use regex to match and remove any blazor:oninput attribute
// For example, it will match 'blazor:oninput="some value"' and remove it.
// Remove all blazor event attributes (e.g., blazor:onclick, blazor:oninput, etc.)
var scrubbed = Regex.Replace(s, @"(\s*)blazor:[a-zA-Z]+\s*=\s*""[^""]*""", "");
return scrubbed;
}); which would be equivalent to HtmlPrettyPrint.All(nodes => nodes.ScrubAttributes(a => a.Name.StartsWith("blazor:"))); Because it depends on your testing scenario i would vote for several extension methods:
|
I am trying to render Blazor components, but Blazor adds the "blazor:elementreference" attribute which changes every time we run the tests using bUnit.
Generated code:
In this case, this result is rendered by the following code:
Before submitting a potential PR to update the docs, would you be interested in this?
The text was updated successfully, but these errors were encountered: