Commit 39a419f3 authored by Mason Freed's avatar Mason Freed Committed by Commit Bot

Enable feature detection of declarative Shadow DOM

To enable feature detection, this CL enables this:

  HTMLTemplateElement.prototype.hasOwnProperty("shadowRoot")

This is as documented in the explainer, at [1].

[1] https://github.com/mfreed7/declarative-shadow-dom/blob/master/README.md#feature-detection-and-polyfilling

Bug: 1042130
Change-Id: I529af9ce952b4d2e162e099c7ca703af8f3c4791
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2166466
Commit-Queue: Mason Freed <masonfreed@chromium.org>
Auto-Submit: Mason Freed <masonfreed@chromium.org>
Reviewed-by: default avatarYuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#763495}
parent 6aca4c59
......@@ -34,4 +34,14 @@
HTMLConstructor
] interface HTMLTemplateElement : HTMLElement {
readonly attribute DocumentFragment content;
// This 'shadowRoot' attribute shadows Element.prototype.shadowRoot
// without changing any behavior. The existence of this attribute
// indicates support of Declarative Shadow DOM, so that this works:
// function supportsDeclarativeShadowDOM() {
// return HTMLTemplateElement.prototype.hasOwnProperty("shadowRoot");
// }
// See https://github.com/mfreed7/declarative-shadow-dom/blob/master/README.md#feature-detection-and-polyfilling
// for more detail.
[RuntimeEnabled=DeclarativeShadowDOM, Affects=Nothing, ImplementedAs=OpenShadowRoot] readonly attribute ShadowRoot? shadowRoot;
};
......@@ -26,6 +26,10 @@ test(() => {
assert_array_equals(s1.assignedNodes(), [c1]);
}, 'Declarative Shadow DOM: Basic test');
test(() => {
assert_true(HTMLTemplateElement.prototype.hasOwnProperty("shadowRoot"),'Unable to feature detect');
}, 'Declarative Shadow DOM: Feature detection');
test(() => {
const div = document.createElement('div');
div.innerHTML = `
......
......@@ -4181,6 +4181,7 @@ interface HTMLTableSectionElement : HTMLElement
interface HTMLTemplateElement : HTMLElement
attribute @@toStringTag
getter content
getter shadowRoot
method constructor
interface HTMLTextAreaElement : HTMLElement
attribute @@toStringTag
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment