Michael A. Peters
mpeters at domblogger.net
Fri Oct 13 23:36:00 PDT 2017
This is problematic when dealing with WebVTT which does not require tags
Where it is the biggest problem is when the document is being served as
I tried the following hack which seemed to be working:
cleandoc = document.implementation.createHTMLDocument("FuBar");
cleanbody = document.createElementNS("http://www.w3.org/1999/xhtml",
Then I could do the following when with a WebVTT cue:
cleanbody.innerHTML = string;
That *mostly* works but seems to sometimes fail when string contains
entities, such as
What happens is it returns an empty string.
Given that WebVTT is part of HTML5 and browser native html5 audio
players don't support caption tracks forcing us to write our own
implementations if we want captions with audio, it sure would be nice if
because there is never a guarantee valid WebVTT cue has closed tags
which are required for XHTML sent as XML.
Seems to me that a JS native function to add missing closing tags would
have more application than just WebVTT cues.
I looked for a jQuery filter that does it, but could not find one.
It also could be of benefit in emulating document.write() as many of
Google's tools *still* require document.write() despite the issues with
document.write() and XML having been known for 15+ years now.
capable of closing open tags in a string passed to it?
More information about the whatwg