Skip to content

Commit

Permalink
fix: edge case error handling on ie 11 (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonocasey committed Nov 17, 2020
1 parent 1dc9090 commit 23040c1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
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');
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') {
return result;
}

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

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

0 comments on commit 23040c1

Please sign in to comment.