Respect unknown decl rule
This commit is contained in:
Родитель
a2902476de
Коммит
0ee93d6b1e
|
@ -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);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче