MutationRecord
Represents a recording of DOM changes.
using AngleSharp.Text;
using System.Runtime.CompilerServices;
namespace AngleSharp.Dom
{
[System.Runtime.CompilerServices.NullableContext(2)]
[System.Runtime.CompilerServices.Nullable(0)]
internal sealed class MutationRecord : IMutationRecord
{
[System.Runtime.CompilerServices.Nullable(1)]
private static readonly string CharacterDataType = "characterData";
[System.Runtime.CompilerServices.Nullable(1)]
private static readonly string AttributesType = "attributes";
[System.Runtime.CompilerServices.Nullable(1)]
private static readonly string ChildListType = "childList";
public bool IsAttribute => Type.Is(AttributesType);
public bool IsCharacterData => Type.Is(CharacterDataType);
public bool IsChildList => Type.Is(ChildListType);
[System.Runtime.CompilerServices.Nullable(1)]
[field: System.Runtime.CompilerServices.Nullable(1)]
public string Type {
[System.Runtime.CompilerServices.NullableContext(1)]
get;
[System.Runtime.CompilerServices.NullableContext(1)]
private set;
}
[System.Runtime.CompilerServices.Nullable(1)]
[field: System.Runtime.CompilerServices.Nullable(1)]
public INode Target {
[System.Runtime.CompilerServices.NullableContext(1)]
get;
[System.Runtime.CompilerServices.NullableContext(1)]
private set;
}
public INodeList Added { get; set; }
public INodeList Removed { get; set; }
public INode PreviousSibling { get; set; }
public INode NextSibling { get; set; }
public string AttributeName { get; set; }
public string AttributeNamespace { get; set; }
public string PreviousValue { get; set; }
private MutationRecord()
{
}
[System.Runtime.CompilerServices.NullableContext(1)]
public static MutationRecord CharacterData(INode target, [System.Runtime.CompilerServices.Nullable(2)] string previousValue = null)
{
return new MutationRecord {
Type = CharacterDataType,
Target = target,
PreviousValue = previousValue
};
}
[return: System.Runtime.CompilerServices.Nullable(1)]
public static MutationRecord ChildList([System.Runtime.CompilerServices.Nullable(1)] INode target, INodeList addedNodes = null, INodeList removedNodes = null, INode previousSibling = null, INode nextSibling = null)
{
return new MutationRecord {
Type = ChildListType,
Target = target,
Added = addedNodes,
Removed = removedNodes,
PreviousSibling = previousSibling,
NextSibling = nextSibling
};
}
[return: System.Runtime.CompilerServices.Nullable(1)]
public static MutationRecord Attributes([System.Runtime.CompilerServices.Nullable(1)] INode target, string attributeName = null, string attributeNamespace = null, string previousValue = null)
{
return new MutationRecord {
Type = AttributesType,
Target = target,
AttributeName = attributeName,
AttributeNamespace = attributeNamespace,
PreviousValue = previousValue
};
}
[System.Runtime.CompilerServices.NullableContext(1)]
public MutationRecord Copy(bool clearPreviousValue)
{
return new MutationRecord {
Type = Type,
Target = Target,
PreviousSibling = PreviousSibling,
NextSibling = NextSibling,
AttributeName = AttributeName,
AttributeNamespace = AttributeNamespace,
PreviousValue = (clearPreviousValue ? null : PreviousValue),
Added = Added,
Removed = Removed
};
}
}
}