Fix displaying comments in Polymer 2
slotToContent is code that should only be executed in Polymer 1.
It is weird that splitting up a CSS rule into two would help, but maybe
that has to do with ::slotted() descendants not being supported at all:
https://polymer-library.polymer-project.org/2.0/docs/upgrade#replace-content-selectors
"In shadow DOM v1, you cannot select a descendant of a top-level
distributed child. No selectors can follow the ::slotted() selector."
Bug: Issue 11067
Bug: Issue 11068
Change-Id: Ibb9ed9a5749a3bb94eff7736c3a9f746c83f37f9
diff --git a/polygerrit-ui/app/elements/diff/gr-diff/gr-diff.html b/polygerrit-ui/app/elements/diff/gr-diff/gr-diff.html
index 4ec460f..6ac6714 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff/gr-diff.html
+++ b/polygerrit-ui/app/elements/diff/gr-diff/gr-diff.html
@@ -35,7 +35,12 @@
:host(.no-left) .sideBySide ::content .right:not([data-value]) + td {
display: none;
}
- .thread-group, ::slotted(*) .thread-group {
+ ::slotted(*) .thread-group {
+ display: block;
+ max-width: var(--content-width, 80ch);
+ white-space: normal;
+ }
+ .thread-group {
display: block;
max-width: var(--content-width, 80ch);
white-space: normal;
diff --git a/polygerrit-ui/app/elements/diff/gr-diff/gr-diff.js b/polygerrit-ui/app/elements/diff/gr-diff/gr-diff.js
index d2f9214..633e081 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff/gr-diff.js
+++ b/polygerrit-ui/app/elements/diff/gr-diff/gr-diff.js
@@ -86,6 +86,9 @@
* implements the same behavior as the template parsing for imperative slots.
*/
Gerrit.slotToContent = function(slot) {
+ if (Polymer.Element) {
+ return slot;
+ }
const content = document.createElement('content');
content.name = slot.name;
content.setAttribute('select', `[slot='${slot.name}']`);