Group comment warnings in DOM so they don't break alternate colours

Change-Id: I0516a57a30a59ee6eac0ad2f23f05ad83c396391
This commit is contained in:
Ed Sanders 2020-11-16 23:32:56 +00:00
parent 4d0498853d
commit 2328a3cad0

View file

@ -1,6 +1,6 @@
'use strict';
var initialOffset, indentWidth;
var initialOffset, indentWidth, firstMarker;
function markTimestamp( parser, node, match ) {
var
@ -83,11 +83,17 @@ function markComment( comment ) {
marker.style.left = ( rect.left + scrollLeft ) + 'px';
marker.style.width = ( rect.width ) + 'px';
if ( !firstMarker ) {
firstMarker = marker;
}
if ( comment.warnings && comment.warnings.length ) {
markerWarnings = marker.cloneNode( false );
markerWarnings.className = 'detected-comment-warnings';
markerWarnings.innerText = comment.warnings.join( '\n' );
document.body.appendChild( markerWarnings );
// Group warnings at the top as we use nth-child selectors
// to alternate color of markers.
document.body.insertBefore( markerWarnings, firstMarker );
}
document.body.appendChild( marker );