diff --git a/lib/text/ttml_text_parser.js b/lib/text/ttml_text_parser.js index 7981da5107..d652050374 100644 --- a/lib/text/ttml_text_parser.js +++ b/lib/text/ttml_text_parser.js @@ -199,6 +199,11 @@ shaka.text.TtmlTextParser = class { /** @type {Element} */ let parentElement = /** @type {Element} */(cueNode.parentNode); + if (cueNode.nodeType == Node.COMMENT_NODE) { + // The comments do not contain information that interests us here. + return null; + } + if (cueNode.nodeType == Node.TEXT_NODE) { // This should generate an "anonymous span" according to the TTML spec. // So pretend the element was a . parentElement was set above, so diff --git a/test/text/ttml_text_parser_unit.js b/test/text/ttml_text_parser_unit.js index 342a7f6b1e..a20c3ca67a 100644 --- a/test/text/ttml_text_parser_unit.js +++ b/test/text/ttml_text_parser_unit.js @@ -476,6 +476,15 @@ describe('TtmlTextParser', () => { {periodStart: 0, segmentStart: 0, segmentEnd: 0}); }); + it('supports comments in the body', () => { + verifyHelper( + [], + '
' + + '' + + '
', + {periodStart: 0, segmentStart: 0, segmentEnd: 0}); + }); + it('parses alignment from textAlign attribute of a region', () => { verifyHelper( [