Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix edge case error handling on ie 11 #112

Merged
merged 1 commit into from
Nov 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/stringToMpdXml.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,16 @@ export const stringToMpdXml = (manifestString) => {
}

const parser = new DOMParser();
const xml = parser.parseFromString(manifestString, 'application/xml');
const mpd = xml && xml.documentElement.tagName === 'MPD' ?
xml.documentElement : null;
let xml;
let mpd;

try {
xml = parser.parseFromString(manifestString, 'application/xml');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IE 11 throws on invalid xml - which isn't illogical - it's just not the error that we want to throw. We want our custom DASH_INVALID_XML error.

mpd = xml && xml.documentElement.tagName === 'MPD' ?
xml.documentElement : null;
} catch (e) {
// ie 11 throwsw on invalid xml
}

if (!mpd || mpd &&
mpd.getElementsByTagName('parsererror').length > 0) {
Expand Down
4 changes: 4 additions & 0 deletions src/utils/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ export const merge = (...objects) => {

return objects.reduce((result, source) => {

if (typeof source !== 'object') {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IE11 doesn't like when you call Object.keys on a non-object.

return result;
}

Object.keys(source).forEach(key => {

if (Array.isArray(result[key]) && Array.isArray(source[key])) {
Expand Down