[whatwg] JavaScript function for closing tags

Roger Hågensen rh_whatwg at skuldwyrm.no
Mon Oct 16 10:08:57 PDT 2017

On 2017-10-14 10:13, Michael A. Peters wrote:
> I use TextTrack API but it's documention does not specify that it closes 
> open tags within a cue, in fact I'm fairly certain it doesn't because 
> some people use it for json and other related none tag related content.
Looking at https://www.html5rocks.com/en/tutorials/track/basics/
it seems JSON can be used, no idea if content type is different or not 
for that.

> Some errors using the tracks in XML were solved by the innerHTML trick 
> where I create a separate html document, append the cue, and then grab 
> the innerHTML but that doesn't always work to close tags when html 
> entities are part of the cue string.

Mixing XML and HTML is not a good idea. Would it not be easier to have 
the server send out proper XML instead of hTML? Valid XML is also valid 
HTML (the reverse is not always true).
And if XML and HTML is giving you issues then use JSON instead.
I did not see JSON mentioned in the W3C spec though.

>>> There does not seem to be a JavaScript API for closing open tags.
>>> This is problematic when dealing with WebVTT which does not require 
>>> tags be
>>> closed.
>>> Where it is the biggest problem is when the document is being served as

If a XML document is being served with unclosed tags then it's not valid 
XML, so it's no wonder if that then causes issues.

Unless specified otherwise, anything I write publicly is considered 
Public Domain (CC0). My opinions are my own unless specified otherwise.
Roger Hågensen,
Freelancer, Norway.

More information about the whatwg mailing list