ShadowRoot Class
https://dom.spec.whatwg.org/#interface-shadowroot
public sealed class ShadowRoot : DocumentFragment- Inheritance
DocumentFragmentShadowRoot
Properties
| Name | Description |
|---|---|
| ActiveElement | https://html.spec.whatwg.org/multipage/interaction.html#dom-documentorshadowroot-activeelement: the focused element, retargeted against the shadow root. |
| AdoptedStyleSheets | Gets the list of the constructed style sheets adopted by the shadow root. |
| Clonable | Gets a value indicating whether the shadow root is copied when its host is cloned. |
| CustomElementRegistry | https://dom.spec.whatwg.org/#dom-documentorshadowroot-customelementregistry |
| DelegatesFocus | Gets a value indicating whether the shadow root delegates focus to its first focusable element. |
| FullscreenElement | Gets the fullscreen element of the shadow tree (https://fullscreen.spec.whatwg.org/#dom-document-fullscreenelement): the fullscreen element of the document retargeted against the shadow root, when it is in the shadow tree. |
| Host | Gets the element to which the shadow root is attached. |
| InnerHtml | https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-shadowroot-innerhtml |
| Mode | Gets the encapsulation mode of the shadow root. |
| OnSlotChange | Gets or sets the event handler of the slotchange event. |
| PointerLockElement | Gets the element the pointer is locked to when it is in the shadow tree (https://w3c.github.io/pointerlock/#dom-documentorshadowroot-pointerlockelement): the pointer-lock target retargeted against the shadow root. |
| Serializable | Gets a value indicating whether the shadow root is included when its host is serialized. |
| SlotAssignment | Gets how slottables are assigned to the slots of the shadow root. |
| StyleSheets | Gets the list of the style sheets of the shadow root. |
ActiveElement
Focus.cshttps://html.spec.whatwg.org/multipage/interaction.html#dom-documentorshadowroot-activeelement: the focused element, retargeted against the shadow root.
public Element? ActiveElement { get; }AdoptedStyleSheets
LinkStyle.csGets the list of the constructed style sheets adopted by the shadow root.
public IList<CssStyleSheet> AdoptedStyleSheets { get; set; }Clonable
ShadowRoot.csGets a value indicating whether the shadow root is copied when its host is cloned.
public bool Clonable { get; }CustomElementRegistry
ShadowRoot.cshttps://dom.spec.whatwg.org/#dom-documentorshadowroot-customelementregistry
public CustomElementRegistry? CustomElementRegistry { get; }DelegatesFocus
ShadowRoot.csGets a value indicating whether the shadow root delegates focus to its first focusable element.
public bool DelegatesFocus { get; }FullscreenElement
Fullscreen.csGets the fullscreen element of the shadow tree (https://fullscreen.spec.whatwg.org/#dom-document-fullscreenelement): the fullscreen element of the document retargeted against the shadow root, when it is in the shadow tree.
public Element? FullscreenElement { get; }Host
ShadowRoot.csGets the element to which the shadow root is attached.
public Element Host { get; }InnerHtml
DynamicMarkup.cshttps://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-shadowroot-innerhtml
public string InnerHtml { get; set; }Property value
Exceptions
TypeErrorException- Trusted Types are enforced and the default policy did not convert the value.
See also
Mode
ShadowRoot.csGets the encapsulation mode of the shadow root.
public ShadowRootMode Mode { get; }OnSlotChange
DynamicMarkup.csGets or sets the event handler of the slotchange event.
PointerLockElement
PointerLock.csGets the element the pointer is locked to when it is in the shadow tree (https://w3c.github.io/pointerlock/#dom-documentorshadowroot-pointerlockelement): the pointer-lock target retargeted against the shadow root.
public Element? PointerLockElement { get; }Property value
See also
Serializable
ShadowRoot.csGets a value indicating whether the shadow root is included when its host is serialized.
public bool Serializable { get; }SlotAssignment
ShadowRoot.csGets how slottables are assigned to the slots of the shadow root.
public SlotAssignmentMode SlotAssignment { get; }StyleSheets
LinkStyle.csGets the list of the style sheets of the shadow root.
public StyleSheetList StyleSheets { get; }Property value
See also
Methods
| Name | Description |
|---|---|
| AppendHtml(string, SetHtmlOptions?) | Parses the HTML and inserts the result after the last child. |
| AppendHtmlUnsafe(TrustedHtml, SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions?) | Parses the HTML and inserts the result after the last child, without the default sanitizer. |
| AppendHtmlUnsafe(string, SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions?) | Parses the HTML and inserts the result after the last child, without the default sanitizer. |
| ElementFromPoint(double, double) | Returns the topmost element at a point of the viewport, retargeted against the shadow root: as Document.ElementFromPoint, but the elements of the shadow tree (and of the shadow trees that contain it) are not replaced by their shadow hosts, so the result can be an element of the shadow tree, or an element outside of it (e.g. the shadow host, or an element of the document). The member was defined by the obsolete Shadow DOM specification and is implemented by the browsers, but CSSOM View only defines it for the documents (https://github.com/w3c/csswg-drafts/issues/556). |
| ElementsFromPoint(double, double) | Returns the elements at a point of the viewport, topmost first, retargeted against the shadow root: see ShadowRoot.ElementFromPoint and Document.ElementsFromPoint. |
| GetAnimations() | Returns the relevant animations of the elements of the shadow tree, sorted by their composite order (https://drafts.csswg.org/web-animations-1/#dom-documentorshadowroot-getanimations). |
| GetHtml(GetHtmlOptions?) | https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-shadowroot-gethtml |
| GetSelection() | Returns the selection of the node document. The member was defined by the obsolete Shadow DOM specification and is implemented by Blink and WebKit, but the Selection API does not define it. |
| PrependHtml(string, SetHtmlOptions?) | Parses the HTML and inserts the result before the first child. |
| PrependHtmlUnsafe(TrustedHtml, SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions?) | Parses the HTML and inserts the result before the first child, without the default sanitizer. |
| PrependHtmlUnsafe(string, SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions?) | Parses the HTML and inserts the result before the first child, without the default sanitizer. |
| SetHtml(string, SetHtmlOptions?) | https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-shadowroot-sethtml |
| SetHtmlUnsafe(TrustedHtml, SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions?) | https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-shadowroot-sethtmlunsafe |
| SetHtmlUnsafe(string, SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions?) | https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-shadowroot-sethtmlunsafe |
| SetInnerHtml(TrustedHtml) | The innerHTML setter with a TrustedHtml value (https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-shadowroot-innerhtml). |
| StreamAppendHtml(SetHtmlOptions?) | Returns a writer that parses HTML and inserts the result after the last child as it is parsed (proposed by https://github.com/whatwg/html/pull/12758). |
| StreamAppendHtmlUnsafe(SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions?) | Returns a writer that parses HTML and inserts the result after the last child as it is parsed, without the default sanitizer (proposed by https://github.com/whatwg/html/pull/12758). |
| StreamHtml(SetHtmlOptions?) | Returns a writer that parses HTML and replaces the children with the result as it is parsed (proposed by https://github.com/whatwg/html/pull/12758). |
| StreamHtmlUnsafe(SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions?) | Returns a writer that parses HTML and replaces the children with the result as it is parsed, without the default sanitizer (proposed by https://github.com/whatwg/html/pull/12758). |
| StreamPrependHtml(SetHtmlOptions?) | Returns a writer that parses HTML and inserts the result before the first child as it is parsed (proposed by https://github.com/whatwg/html/pull/12758). |
| StreamPrependHtmlUnsafe(SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions?) | Returns a writer that parses HTML and inserts the result before the first child as it is parsed, without the default sanitizer (proposed by https://github.com/whatwg/html/pull/12758). |
AppendHtml(string, SetHtmlOptions?)
DynamicMarkup.Insertion.csParses the HTML and inserts the result after the last child.
public void AppendHtml(string html, SetHtmlOptions? options = null)AppendHtmlUnsafe overloads
AppendHtmlUnsafe(TrustedHtml, SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions?)
DynamicMarkup.Insertion.csParses the HTML and inserts the result after the last child, without the default sanitizer.
public void AppendHtmlUnsafe(TrustedHtml html, SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions? options = null)AppendHtmlUnsafe(string, SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions?)
DynamicMarkup.Insertion.csParses the HTML and inserts the result after the last child, without the default sanitizer.
public void AppendHtmlUnsafe(string html, SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions? options = null)Parameters
Exceptions
TypeErrorException- Trusted Types are enforced and the options or the value are not trusted.
See also
ElementFromPoint(double, double)
CssomView.cs- Experimental (WEBPLATEXP0009)
Returns the topmost element at a point of the viewport, retargeted against the shadow root: as Document.ElementFromPoint, but the elements of the shadow tree (and of the shadow trees that contain it) are not replaced by their shadow hosts, so the result can be an element of the shadow tree, or an element outside of it (e.g. the shadow host, or an element of the document). The member was defined by the obsolete Shadow DOM specification and is implemented by the browsers, but CSSOM View only defines it for the documents (https://github.com/w3c/csswg-drafts/issues/556).
[Experimental("WEBPLATEXP0009", UrlFormat = "https://github.com/meziantou/Meziantou.Framework/blob/main/src/Meziantou.Framework.WebPlatform/docs/experimental-apis.md#{0}")]
public Element? ElementFromPoint(double x, double y)ElementsFromPoint(double, double)
CssomView.cs- Experimental (WEBPLATEXP0009)
Returns the elements at a point of the viewport, topmost first, retargeted against the shadow root: see ShadowRoot.ElementFromPoint and Document.ElementsFromPoint.
[Experimental("WEBPLATEXP0009", UrlFormat = "https://github.com/meziantou/Meziantou.Framework/blob/main/src/Meziantou.Framework.WebPlatform/docs/experimental-apis.md#{0}")]
public IReadOnlyList<Element> ElementsFromPoint(double x, double y)GetAnimations()
Document.Animations.csReturns the relevant animations of the elements of the shadow tree, sorted by their composite order (https://drafts.csswg.org/web-animations-1/#dom-documentorshadowroot-getanimations).
public IReadOnlyList<Animation> GetAnimations()GetHtml(GetHtmlOptions?)
DynamicMarkup.cshttps://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-shadowroot-gethtml
public string GetHtml(GetHtmlOptions? options = null)GetSelection()
Selection.cs- Experimental (WEBPLATEXP0009)
Returns the selection of the node document. The member was defined by the obsolete Shadow DOM specification and is implemented by Blink and WebKit, but the Selection API does not define it.
[Experimental("WEBPLATEXP0009", UrlFormat = "https://github.com/meziantou/Meziantou.Framework/blob/main/src/Meziantou.Framework.WebPlatform/docs/experimental-apis.md#{0}")]
public Selection? GetSelection()PrependHtml(string, SetHtmlOptions?)
DynamicMarkup.Insertion.csParses the HTML and inserts the result before the first child.
public void PrependHtml(string html, SetHtmlOptions? options = null)PrependHtmlUnsafe overloads
PrependHtmlUnsafe(TrustedHtml, SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions?)
DynamicMarkup.Insertion.csParses the HTML and inserts the result before the first child, without the default sanitizer.
public void PrependHtmlUnsafe(TrustedHtml html, SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions? options = null)PrependHtmlUnsafe(string, SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions?)
DynamicMarkup.Insertion.csParses the HTML and inserts the result before the first child, without the default sanitizer.
public void PrependHtmlUnsafe(string html, SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions? options = null)Parameters
Exceptions
TypeErrorException- Trusted Types are enforced and the options or the value are not trusted.
See also
SetHtml(string, SetHtmlOptions?)
DynamicMarkup.cshttps://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-shadowroot-sethtml
public void SetHtml(string html, SetHtmlOptions? options = null)SetHtmlUnsafe overloads
SetHtmlUnsafe(TrustedHtml, SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions?)
DynamicMarkup.cshttps://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-shadowroot-sethtmlunsafe
public void SetHtmlUnsafe(TrustedHtml html, SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions? options = null)Parameters
Exceptions
TypeErrorException- Trusted Types are enforced and the options are not trusted.
See also
SetHtmlUnsafe(string, SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions?)
DynamicMarkup.cshttps://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-shadowroot-sethtmlunsafe
public void SetHtmlUnsafe(string html, SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions? options = null)Parameters
Exceptions
TypeErrorException- Trusted Types are enforced and the options or the value are not trusted.
See also
SetInnerHtml(TrustedHtml)
DynamicMarkup.csThe innerHTML setter with a TrustedHtml value (https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-shadowroot-innerhtml).
public void SetInnerHtml(TrustedHtml html)StreamAppendHtml(SetHtmlOptions?)
DynamicMarkup.Streaming.cs- Experimental (WEBPLATEXP0002)
Returns a writer that parses HTML and inserts the result after the last child as it is parsed (proposed by https://github.com/whatwg/html/pull/12758).
[Experimental("WEBPLATEXP0002", UrlFormat = "https://github.com/meziantou/Meziantou.Framework/blob/main/src/Meziantou.Framework.WebPlatform/docs/experimental-apis.md#{0}")]
public HtmlStreamWriter StreamAppendHtml(SetHtmlOptions? options = null)StreamAppendHtmlUnsafe(SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions?)
DynamicMarkup.Streaming.cs- Experimental (WEBPLATEXP0002)
Returns a writer that parses HTML and inserts the result after the last child as it is parsed, without the default sanitizer (proposed by https://github.com/whatwg/html/pull/12758).
[Experimental("WEBPLATEXP0002", UrlFormat = "https://github.com/meziantou/Meziantou.Framework/blob/main/src/Meziantou.Framework.WebPlatform/docs/experimental-apis.md#{0}")]
public HtmlStreamWriter StreamAppendHtmlUnsafe(SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions? options = null)Parameters
Returns
Exceptions
TypeErrorException- Trusted Types are enforced, the options are not
TrustedHtmlParserOptionsand the default policy did not create them.
StreamHtml(SetHtmlOptions?)
DynamicMarkup.Streaming.cs- Experimental (WEBPLATEXP0002)
Returns a writer that parses HTML and replaces the children with the result as it is parsed (proposed by https://github.com/whatwg/html/pull/12758).
[Experimental("WEBPLATEXP0002", UrlFormat = "https://github.com/meziantou/Meziantou.Framework/blob/main/src/Meziantou.Framework.WebPlatform/docs/experimental-apis.md#{0}")]
public HtmlStreamWriter StreamHtml(SetHtmlOptions? options = null)StreamHtmlUnsafe(SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions?)
DynamicMarkup.Streaming.cs- Experimental (WEBPLATEXP0002)
Returns a writer that parses HTML and replaces the children with the result as it is parsed, without the default sanitizer (proposed by https://github.com/whatwg/html/pull/12758).
[Experimental("WEBPLATEXP0002", UrlFormat = "https://github.com/meziantou/Meziantou.Framework/blob/main/src/Meziantou.Framework.WebPlatform/docs/experimental-apis.md#{0}")]
public HtmlStreamWriter StreamHtmlUnsafe(SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions? options = null)Parameters
Returns
Exceptions
TypeErrorException- Trusted Types are enforced, the options are not
TrustedHtmlParserOptionsand the default policy did not create them.
StreamPrependHtml(SetHtmlOptions?)
DynamicMarkup.Streaming.cs- Experimental (WEBPLATEXP0002)
Returns a writer that parses HTML and inserts the result before the first child as it is parsed (proposed by https://github.com/whatwg/html/pull/12758).
[Experimental("WEBPLATEXP0002", UrlFormat = "https://github.com/meziantou/Meziantou.Framework/blob/main/src/Meziantou.Framework.WebPlatform/docs/experimental-apis.md#{0}")]
public HtmlStreamWriter StreamPrependHtml(SetHtmlOptions? options = null)StreamPrependHtmlUnsafe(SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions?)
DynamicMarkup.Streaming.cs- Experimental (WEBPLATEXP0002)
Returns a writer that parses HTML and inserts the result before the first child as it is parsed, without the default sanitizer (proposed by https://github.com/whatwg/html/pull/12758).
[Experimental("WEBPLATEXP0002", UrlFormat = "https://github.com/meziantou/Meziantou.Framework/blob/main/src/Meziantou.Framework.WebPlatform/docs/experimental-apis.md#{0}")]
public HtmlStreamWriter StreamPrependHtmlUnsafe(SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions? options = null)Parameters
Returns
Exceptions
TypeErrorException- Trusted Types are enforced, the options are not
TrustedHtmlParserOptionsand the default policy did not create them.