Merge pull request #121 from MartinWelsch/issue-120
Escape property name
This commit is contained in:
Коммит
286ebaf8ae
|
@ -83,5 +83,27 @@ namespace AngleSharp.Css.Tests.Library
|
|||
var css = styleSheet.ToCss();
|
||||
Assert.AreEqual("div { background: conic-gradient(rgba(255, 0, 0, 1), rgba(255, 255, 0, 1), rgba(0, 128, 0, 1)) }", css);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EscapePropertyNames_CustomProperty_Issue120()
|
||||
{
|
||||
var css = @".class { --\/\%\$\!: value }";
|
||||
var styleSheet = ParseStyleSheet(css);
|
||||
|
||||
var generatedCss = styleSheet.ToCss();
|
||||
|
||||
Assert.AreEqual(css, generatedCss);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EscapePropertyNames_UnknownDeclaration_Issue120()
|
||||
{
|
||||
var css = @".class { \/\%\$\!: value }";
|
||||
var styleSheet = ParseStyleSheet(css, new CssParserOptions{ IsIncludingUnknownDeclarations = true });
|
||||
|
||||
var generatedCss = styleSheet.ToCss();
|
||||
|
||||
Assert.AreEqual(css, generatedCss);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ namespace AngleSharp.Css.Dom
|
|||
|
||||
#region String Representation
|
||||
|
||||
public void ToCss(TextWriter writer, IStyleFormatter formatter) => writer.Write(formatter.Declaration(Name, Value, IsImportant));
|
||||
public void ToCss(TextWriter writer, IStyleFormatter formatter) => writer.Write(formatter.Declaration(CssUtilities.Escape(Name), Value, IsImportant));
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче