W3C home > Mailing lists > Public > w3c-wai-ig@w3.org > October to December 2017

Re: JavaScript API for closing open tags

From: Michael A. Peters <mpeters@domblogger.net>
Date: Fri, 13 Oct 2017 23:35:01 -0700
To: "w3c-wai-ig@w3.org" <w3c-wai-ig@w3.org>
Message-ID: <6cd6421c-7699-4279-d0b5-7125c81e9617@domblogger.net>
My apologies, wrong list

On 10/13/2017 11:34 PM, Michael A. Peters wrote:
> 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
> I tried the following hack which seemed to be working:
> cleandoc = document.implementation.createHTMLDocument("FuBar");
> cleanbody = document.createElementNS("http://www.w3.org/1999/xhtml",
> "body");
> cleandoc.documentElement.appendChild(cleanbody);
> Then I could do the following when with a WebVTT cue:
> cleanbody.innerHTML = string;
> return (cleanbody.innerHTML);
> That *mostly* works but seems to sometimes fail when string contains
> entities, such as &#160;
> 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
> there was a pure JavaScript way to just add closing tags to a string
> 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.
> Any chance of getting a parser into JavaScript that at least would be
> capable of closing open tags in a string passed to it?
Received on Saturday, 14 October 2017 06:35:26 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 6 December 2017 16:04:47 UTC