Table of Contents

Class DocumentExtensions

Namespace
AngleSharp.Dom
Assembly
AngleSharp.dll

Useful methods for document objects.

public static class DocumentExtensions
Inheritance
DocumentExtensions
Inherited Members

Methods

AdoptNode(IDocument, INode)

Adopts the given node for the provided document context.

public static void AdoptNode(this IDocument document, INode node)

Parameters

document IDocument

The new owner of the node.

node INode

The node to change its owner.

CreateElement<TElement>(IDocument)

Creates an element of the given type or throws an exception, if there is no such type.

public static TElement CreateElement<TElement>(this IDocument document) where TElement : IElement

Parameters

document IDocument

The responsible document.

Returns

TElement

The created element.

Type Parameters

TElement

The type of the element.

GetDownloads(IDocument)

Gets all downloads associated with resources of the document.

public static IEnumerable<IDownload> GetDownloads(this IDocument document)

Parameters

document IDocument

The document hosting the downloads.

Returns

IEnumerable<IDownload>

The collection of elements hosting resources.

GetScriptDownloads(IDocument)

Checks if the document is waiting for a script to finish preparing.

public static IEnumerable<Task> GetScriptDownloads(this IDocument document)

Parameters

document IDocument

The document to use.

Returns

IEnumerable<Task>

Enumerable of awaitable tasks.

GetStyleSheetDownloads(IDocument)

Checks if the document has any active stylesheets that block the scripts. A style sheet is blocking scripts if the responsible element was created by that Document's parser, and the element is either a style element or a link element that was an external resource link that contributes to the styling processing model when the element was created by the parser, and the element's style sheet was enabled when the element was created by the parser, and the element's style sheet ready flag is not yet set. http://www.w3.org/html/wg/drafts/html/master/document-metadata.html#has-no-style-sheet-that-is-blocking-scripts

public static IEnumerable<Task> GetStyleSheetDownloads(this IDocument document)

Parameters

document IDocument

The document to use.

Returns

IEnumerable<Task>

Enumerable of awaitable tasks.

WaitForReadyAsync(IDocument)

Spins the event loop until all stylesheets are downloaded (if required) and all scripts are ready to be parser executed. http://www.w3.org/html/wg/drafts/html/master/syntax.html#the-end (bullet 3)

public static Task WaitForReadyAsync(this IDocument document)

Parameters

document IDocument

The document to use.

Returns

Task

Awaitable task.