w3c / webvtt

WebVTT Standard
https://w3c.github.io/webvtt/
Other
103 stars 40 forks source link

Expose the fallback language in the API #258

Open zcorpan opened 8 years ago

zcorpan commented 8 years ago

In #257 I made it possible for the "List of WebVTT Node Objects" object to have an "applicable language", but this can't be exposed in getCueAsHTML() since that object maps to a DocumentFragment, which can't have a lang attribute.

One way to make this work is to change from DocumentFragment to an HTML div or span element, and set lang on it if is has an "applicable language".

Existing scripts that just insert whatever comes out of getCueAsHTML() to the document should continue to work, it would just get an extra element. I suppose span is a bit more versatile than div because it is allowed in more places (e.g. in a p element). OTOH, just dumping all cues and have them be separated from each other by default could be nice.

An alternative could be to have the fallback language be a property of TextTrack, and have JS be responsible for setting a lang attribute on a container element in which it inserts cues with getCueAsHTML().

zcorpan commented 8 years ago

Hmm TextTrack already exposes the "fallback" language in https://html.spec.whatwg.org/multipage/embedded-content.html#dom-texttrack-language

silviapfeiffer commented 8 years ago

DocumentFragment has the advantage of being able to be cloned and handed around more cheaply. Maybe make a div node inside the DocumentFragment that all the rest is appended to?