JSFiddle - React, Tailwind, and code Playground

by Pablo Leone

HTML

<div id="test" data-ng-controller="asdas" class="test" width="100" height="100" style="background: black; width:100px; height:100px;">
			<p class="test" width="100" height="100" data-ng-controller="asdas" style="background: black; width:100px; height:100px;">
				<p class="test" width="100" height="100" data-ng-controller="asdas" style="background: black; width:100px; height:100px;">
					<p class="test" width="100" height="100" data-ng-controller="asdas" style="background: black; width:100px; height:100px;"></p>
				</p>
			</p>
			<p class="test" width="100" height="100" data-ng-controller="asdas" style="background: black; width:100px; height:100px;"></p>
		</div>

JavaScript

var removeAllAttrs = function (element, pattern) {
    for (var i = element.attributes.length; i-->0;) {
        if (pattern && pattern !== '') {
            if (element.attributes[i].name.search(pattern) !== -1) {
                element.removeAttributeNode(element.attributes[i]);
            }
        } else {
            element.removeAttributeNode(element.attributes[i]);
        }
    }
    for (var i = element.children.length - 1; i >= 0; i--) {
        removeAllAttrs(element.children[i], pattern);
    };
};
removeAllAttrs(document.getElementById('test'), /data\-(.)*/g);