-
Notifications
You must be signed in to change notification settings - Fork 1
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
Use native DOMParser and XMLSerializer #26
base: main
Are you sure you want to change the base?
Use native DOMParser and XMLSerializer #26
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some changes of yours can violate VMAP / VAST's schemas
const newAdBreak = new AdBreak( | ||
adBreak._attributes.timeOffset, | ||
adBreak._attributes.breakType, | ||
adBreak.getAttribute('timeOffset') || '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
timeOffset
from VMAP 1.0 Schema is required and cannot be ''
.
adBreak._attributes.timeOffset, | ||
adBreak._attributes.breakType, | ||
adBreak.getAttribute('timeOffset') || '', | ||
adBreak.getAttribute('breakType') || '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
breakType
from VMAP 1.0 Schema is required.
adSources, | ||
adBreak._attributes.breakId, | ||
adBreak._attributes.repeatAfter, | ||
adBreak.getAttribute('breakId') || '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
breakId
should be optional, but should not be an empty string.
minBitrate, | ||
maxBitrate, | ||
url || '', | ||
delivery || '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delivery
from VAST 4.x is required and must be either "progressive"
or "streaming"
maxBitrate, | ||
url || '', | ||
delivery || '', | ||
type || '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type
from VAST 4.x is required and should not be an empty string
type || '', | ||
width ? parseInt(width) : 0, | ||
height ? parseInt(height) : 0, | ||
codec || '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
codec
from VAST 4.x takes values as specified by RFC
4281: http://tools.ietf.org/html/rfc4281
width ? parseInt(width) : 0, | ||
height ? parseInt(height) : 0, | ||
codec || '', | ||
id || '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
id
should not be an empty string
const trackingEvents = mapArrayOrElem(trackingNodes, tracking => { | ||
if (tracking.parentNode?.nodeName.toLowerCase() !== 'trackingevents') return null; | ||
|
||
const event = tracking.getAttribute('event') || ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
event
should not be an empty string
}); | ||
const inLine = new InLine('', '', impressions, creatives, void 0, void 0, void 0, void 0, void 0, errors, extensions); | ||
const newAd = new Ad(ad._attributes?.id, ad._attributes?.sequence ? parseInt(ad._attributes.sequence) : void 0, inLine); | ||
const adId = ad.getAttribute('id') || ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
id
should not be an empty string
return newAd; | ||
}); | ||
const newVast = new VAST(vastObj._attributes.version, ads); | ||
const newVast = new VAST(vastRoot.getAttribute('version') || '', ads); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
version
should not be an empty string
Thank you for the pull request. I will pick this request over #25 after the review is done since the main use case of OMAP is assumed to run it on a Web browser for now, and the request is to optimize performance in that. |
After #25, I've made a further progress in the direction of removing
xml-js
, migrating from a xml library that provides their original interface, to Web standard DOMParser and XMLSerializer.With this change the package size with required dependencies will be reduced by ~128KB.
While DOMParser and XMLSerializer are supported since Chrome 4, for environments that don't support DOMParser and/or XMLSerializer, there are polyfills like
xmldom
andjsdom
.xmldom
is a lightweight (30KB) pure JS implementation of DOMParser and XMLSerializer with no dependencies on Node.js standard modules, so I use it in the updated tests to verify that our vast/vmap parsers will work well withxmldom
.