Avoid adding DOM elements twice to the document / same parent.
Created by: yurydelendik
At setCueStyle [1], the same 'caption-style' element can be used several times in document.head.appendChild(styleElement);
operation. Some browser are non-compliant with the spec to do an optimization to not do anything if item is located in the same place, e.g. [2]. However, per spec, it shall remove element from the DOM tree, then put it back and, in this case, it might cause document to preform layout. It is recommended to place appendChild
just after the createElement('style')
[1] https://github.com/Dash-Industry-Forum/dash.js/blob/development/src/streaming/extensions/TextTrackExtensions.js#L393 [2] https://code.google.com/p/chromium/issues/detail?id=441355