JSFiddle - React, Tailwind, and code Playground
HTML
<div>
<div id="container">
<div align="right">child</div>
<div align="center">child</div>
<embed src="" width="0" height="0" />
<div align="center">child</div>
<div style="width: 40px">child</div>
<div style="font-size: 100px">child</div>
<div width="60%">child</div>
<embed src="" width="0" height="0"/>
<div width="60%">child</div>
</div>
</div>
JavaScript
var elm,
clone,
doc,
next,
fragment,
live = document.getElementById("container");
if (live !== null) {
fragment = document.createDocumentFragment();
clone = live.cloneNode(true);
next = clone.firstChild;
while(next !== null) {
if (next.nodeName !== "#text") {
next.removeAttribute('style');
next.removeAttribute('width');
next.removeAttribute('align');
if (next.tagName === 'EMBED') {
doc = document.createElement('div');
doc.setAttribute('class', 'video');
doc.innerHTML = "EMBED detected, adding div...";
fragment.appendChild(doc);
}
}
next = next.nextSibling;
}
clone.appendChild(fragment);
live.parentNode.replaceChild(clone, live);
}