Repository navigation
Parse IMSC1 TTML whose elements carry a namespace prefix - #8192
Open
SwastikTripathi wants to merge 1 commit into
Open
SwastikTripathi wants to merge 1 commit into
SwastikTripathi wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR will...
Find the TTML elements of an IMSC1 sample by local name, so documents that put their elements under a prefix are parsed:
Why is this Pull Request needed?
parseTTMLlooked up the root withgetElementsByTagName('tt'), which compares the qualified name. For<tt:tt>(the form EBU-TT-D uses) it finds nothing, so the whole sample fails with "Invalid ttml" and no subtitles show.styling,layoutandbodywere looked up the same way, and a line break was detected withnodeName === 'br', which istt:brthere.The lookups now use
getElementsByTagNameNS('*', name), which matches the local name in any namespace or none, and the line break check useslocalName. Documents with a default namespace, or with no namespace at all, are found exactly as before. Thestyle,regionand[begin]lookups go throughquerySelectorAll, whose type selectors already match the local name, so they didn't need a change.Are there any points in the code the reviewer needs to double check?
This keeps the current lenient handling of documents without the TTML namespace, which #8067 discusses changing. If that lands,
getElementsByLocalNameis the one place to switch to the TTML namespace.Resolves issues:
Fixes #8148
Checklist
Three new unit tests (a prefixed document, prefixed styles and regions, a prefixed
<tt:br/>) fail before the change and pass after.npm run test:unitpasses (1286 tests in headless Chrome), plus eslint, prettier andnpm run type-check.