Skip to content

Commit f039c18

Browse files
committed
Avoid <caption>s inside <caption>s, since some browsers render that badly.
1 parent 365d26e commit f039c18

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

publish.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,17 @@ limitations under the License.
7373
});
7474
}
7575

76+
// Replaces <caption>s inside <caption>s with <spans>, so that Firefox doesn't
77+
// omit them from the rendering.
78+
function fixNestedCaptions(doc) {
79+
doc.querySelectorAll('caption caption').array().forEach(function(caption) {
80+
var span = doc.createElement('span');
81+
span.innerHTML = caption.innerHTML;
82+
caption.parentNode.insertBefore(span, caption);
83+
caption.remove();
84+
});
85+
}
86+
7687
function cloneStaticAndInline(doc) {
7788
// Inline the images on the source document instead of the copy
7889
// because the copy doesn't have time to load the images.
@@ -88,6 +99,8 @@ limitations under the License.
8899
removeAll(copy.querySelectorAll('template'));
89100
removeAll(copy.querySelectorAll('cxx-publish-button'));
90101

102+
fixNestedCaptions(copy);
103+
91104
// Inline all style sheets.
92105
var sheetUpdates = Array.prototype.map.call(
93106
copy.querySelectorAll('link[rel="stylesheet"]'),

0 commit comments

Comments
 (0)