作为视频字幕/ WebVTT polyfill Captionator的一部分,我正在编写一些代码作为<source>
元素的子节点的<track>
元素的存根支持。
不幸的是,标记最初是这样写的:
<video controls autobuffer autoplay loop id="videoTest" width="505" height="232">
<source src="video/arduino.m4v" type="video/mp4" />
<source src="video/arduino.webm" type="video/webm" />
<source src="video/arduino.ogv" type="video/ogg" />
<track kind="signlanguage" srclang="ja" label="Sign Language, Japanese">
<source src="video/signlanguage.m4v" type="video/mp4" />
<source src="video/signlanguage.webm" type="video/webm" />
<source src="video/signlanguage.ogv" type="video/ogg" />
</track>
</video>
...在浏览器解析时,变异为:
<video controls autobuffer autoplay loop id="videoTest" width="505" height="232">
<source src="video/arduino.m4v" type="video/mp4" />
<source src="video/arduino.webm" type="video/webm" />
<source src="video/arduino.ogv" type="video/ogg" />
<track kind="signlanguage" srclang="ja" label="Sign Language, Japanese" />
<source src="video/signlanguage.m4v" type="video/mp4" />
<source src="video/signlanguage.webm" type="video/webm" />
<source src="video/signlanguage.ogv" type="video/ogg" />
</video>
由于标记的浏览器内部DOM表示已经变平,因此<source>
标记是视频的直接子代,我无法再将其与所讨论的<track>
相关联。
有没有办法解析原始标记以增加对语法的支持,而不必执行多余的XHR来获取整个页面源?
提前致谢:)