-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make changes to declarative Shadow DOM getInnerHTML API
See [1] for more context, but this CL makes the following changes to the declarative Shadow DOM getInnerHTML API: 1. Rename getInnerHTML to getComposedInnerHTML 2. Rename includeShadowRoots to includeOpenShadowRoots 3. Rename closedRoots to shadowRoots 4. Change behavior so that the options are more independent, and either can be used without the other. Mostly, the above is a rename operation, with the exception of #4. There, the logic change is relatively minor, mostly happening in markup_accumulator.cc around line 564. Note: this also fixes the MeasureAs vs. RuntimeCallStats. [1] mfreed7/declarative-shadow-dom#9 (comment) Bug: 1042130 Change-Id: Ie4a0b18a2ef28f17b97eca33c018f7479fc20de8 Cq-Do-Not-Cancel-Tryjobs: true
- Loading branch information
1 parent
f37d80e
commit 77940fd
Showing
2 changed files
with
18 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<!DOCTYPE html> | ||
<title>getInnerHTML </title> | ||
<title>getComposedInnerHTML </title> | ||
<link rel='author' href='mailto:[email protected]'> | ||
<link rel='help' href='https://github.com/whatwg/dom/issues/831'> | ||
<script src='/resources/testharness.js'></script> | ||
|
@@ -35,24 +35,27 @@ | |
shadowRoot.appendChild(document.createElement('slot')); | ||
if (isOpen) { | ||
// We can only test this for open roots | ||
assert_equals(wrapper.getInnerHTML(),correctHtml,'The default for includeShadowRoots should be true'); | ||
assert_equals(wrapper.getComposedInnerHTML(),correctHtml,'The default for includeOpenShadowRoots should be true'); | ||
} else { | ||
// Closed shadow roots should not be returned unless closedRoots contains the shadow root: | ||
// Closed shadow roots should not be returned unless shadowRoots array contains the shadow root: | ||
const emptyElement = `<${elementType}></${elementType}>`; | ||
assert_equals(wrapper.getInnerHTML({includeShadowRoots: true}), emptyElement); | ||
assert_equals(wrapper.getInnerHTML({includeShadowRoots: true, closedRoots: []}), emptyElement); | ||
assert_equals(wrapper.getComposedInnerHTML({includeOpenShadowRoots: true}), emptyElement); | ||
assert_equals(wrapper.getComposedInnerHTML({includeOpenShadowRoots: true, shadowRoots: []}), emptyElement); | ||
} | ||
assert_equals(wrapper.getInnerHTML({includeShadowRoots: true, closedRoots: [shadowRoot]}),correctHtml); | ||
// If shadowRoots contains the shadow root, open or closed, it should be serialized. | ||
assert_equals(wrapper.getComposedInnerHTML({includeOpenShadowRoots: true, shadowRoots: [shadowRoot]}),correctHtml); | ||
assert_equals(wrapper.getComposedInnerHTML({includeOpenShadowRoots: false, shadowRoots: [shadowRoot]}),correctHtml); | ||
assert_equals(wrapper.getComposedInnerHTML({shadowRoots: [shadowRoot]}),correctHtml); | ||
} else { | ||
// For non-shadow hosts, getInnerHTML() should also match .innerHTML | ||
assert_equals(wrapper.getInnerHTML({includeShadowRoots: true}),wrapper.innerHTML); | ||
assert_equals(wrapper.getInnerHTML(),wrapper.innerHTML); | ||
// For non-shadow hosts, getComposedInnerHTML() should also match .innerHTML | ||
assert_equals(wrapper.getComposedInnerHTML({includeOpenShadowRoots: true}),wrapper.innerHTML); | ||
assert_equals(wrapper.getComposedInnerHTML(),wrapper.innerHTML); | ||
} | ||
|
||
// Either way, make sure getInnerHTML({includeShadowRoots: false}) matches .innerHTML | ||
assert_equals(wrapper.getInnerHTML({includeShadowRoots: false}),wrapper.innerHTML,'getInnerHTML() with includeShadowRoots false should return the same as .innerHTML'); | ||
// Either way, make sure getComposedInnerHTML({includeOpenShadowRoots: false}) matches .innerHTML | ||
assert_equals(wrapper.getComposedInnerHTML({includeOpenShadowRoots: false}),wrapper.innerHTML,'getComposedInnerHTML() with includeOpenShadowRoots false should return the same as .innerHTML'); | ||
|
||
}, `${applyToShadow ? 'ShadowRoot' : 'Element'}.getInnerHTML() on <${elementType}>${allowsShadowDom ? `, with mode=${mode}, delegatesFocus=${delegatesFocus}.` : ''}`); | ||
}, `${applyToShadow ? 'ShadowRoot' : 'Element'}.getComposedInnerHTML() on <${elementType}>${allowsShadowDom ? `, with mode=${mode}, delegatesFocus=${delegatesFocus}.` : ''}`); | ||
} | ||
|
||
function runAllTests() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters