This commit is contained in:
Florian Rappl 2019-05-12 02:02:21 +02:00
Родитель a2902476de
Коммит 0ee93d6b1e
2 изменённых файлов: 13 добавлений и 10 удалений

Просмотреть файл

@ -64,7 +64,13 @@ namespace AngleSharp.Css
var factory = context.GetFactory<IDeclarationFactory>();
var info = factory.Create(name);
var value = info.Combine(factory, longhands);
return new CssProperty(name, info.Converter, info.Flags, value, important);
if (context.AllowsDeclaration(info))
{
return new CssProperty(name, info.Converter, info.Flags, value, important);
}
return null;
}
internal static ICssProperty[] CreateLonghands(this IBrowsingContext context, ICssProperty shorthand)
@ -78,9 +84,8 @@ namespace AngleSharp.Css
internal static CssProperty CreateProperty(this IBrowsingContext context, String propertyName)
{
var info = context.GetDeclarationInfo(propertyName);
var provider = context.GetProvider<CssParser>();
if (info.Flags != PropertyFlags.Unknown || context.IsAllowingUnknownDeclarations())
if (context.AllowsDeclaration(info))
{
return new CssProperty(propertyName, info.Converter, info.Flags);
}
@ -88,6 +93,9 @@ namespace AngleSharp.Css
return null;
}
private static Boolean AllowsDeclaration(this IBrowsingContext context, DeclarationInfo info) =>
info.Flags != PropertyFlags.Unknown || context.IsAllowingUnknownDeclarations();
private static Boolean IsAllowingUnknownDeclarations(this IBrowsingContext context)
{
var parser = context.GetProvider<CssParser>();

Просмотреть файл

@ -1680,10 +1680,7 @@ namespace AngleSharp.Css
/// </summary>
/// <param name="propertyName">The name of the property.</param>
/// <param name="converter">The converter to use.</param>
public void Register(String propertyName, DeclarationInfo converter)
{
_declarations.Add(propertyName, converter);
}
public void Register(String propertyName, DeclarationInfo converter) => _declarations.Add(propertyName, converter);
/// <summary>
/// Unregisters an existing declaration.
@ -1692,9 +1689,7 @@ namespace AngleSharp.Css
/// <returns>The registered declaration, if any.</returns>
public DeclarationInfo Unregister(String propertyName)
{
var info = default(DeclarationInfo);
if (_declarations.TryGetValue(propertyName, out info))
if (_declarations.TryGetValue(propertyName, out DeclarationInfo info))
{
_declarations.Remove(propertyName);
}