Closed alestoya closed 1 year ago
Single quotes are not valid characters for HTML 5 attributes - https://www.w3.org/TR/2011/WD-html5-20110525/syntax.html#attributes-0 - "Attribute names must consist of one or more characters other than the space characters, U+0000 NULL, U+0022 QUOTATION MARK ("), U+0027 APOSTROPHE ('), U+003E GREATER-THAN SIGN (>), U+002F SOLIDUS (/), and U+003D EQUALS SIGN (=) characters, the control characters, and any characters that are not defined by Unicode."
If quotes should be present in the attributes the correct syntax would be:
.Columns(columns =>
{
columns.Bound(p => p.UnitsInStock).HtmlAttributes(new { @class = "#= UnitsInStock == 39 ? `\"test\"` : `\"a\"` #" });
})
Original bug was not related to single quotes but to french letters. Ticket number 1584947
var arr = new char[]{(char)68, (char)233, (char)116, (char)97, (char)105, (char)108 }; var strCreated = new string(arr); //"Détail" - get from localization from french x.Template(string.Empty) .HtmlAttributes(new {title = strCreated});
With the fix, the HtmlAttributes, HeaderHtmlAttributes and FooterHtmlAttributes methods will accept an additional optional Boolean parameter that would indicate whether the attributes should be encoded or not. By default, the attributes passed are encoded using the default HTML encoder.
The following configuration will NOT encode the passed attributes:
.Columns(columns =>
{
columns.Bound(p => p.UnitsInStock).HtmlAttributes(new {title = "Détail"}, false);
})
Bug report
Reproduction of the problem
Current behavior
Having a grid with a similar column setup will result in an error.
Expected/desired behavior
Having a grid with a similar column setup should not result in an error.
Environment