JSFiddle - React, Tailwind, and code Playground

by Darby Rathbone

HTML

<div class='div'>div</div>
<table class='c'>cxcvxcv
    <input type="text" />
</table>

JavaScript

function functionAsArrayWithArgs(method) {
    var attrs1 = Array.prototype.slice.call(arguments, 1);
    if(attrs1[0] && Array.isArray(attrs1[0]))
        attrs1 =attrs1[0];
    return function (context) {
        if(context.length)
        return Array.prototype.map.call(context, function (e) {
            return method.apply(e, attrs1)
        });
        return method.apply(context,attrs1);
    };
}
var mapCall = function(aFunctions){
      var attr = [].slice.call(arguments,1),
          afun = aFunctions.length?[].slice.call(aFunctions):[aFunctions];

    
    return function (context) {
        if(context.length)
        return [].map.call(context, function (e) {
            return aFunctions.map(function(f,i){return f.apply(e,attr);})
        });
        return aFunctions.map(function(f,i){return f.apply(context,attr);});
    };
};

document.body.textContent = (mapCall([function(){return this.innerHTML},Element.prototype.getBoundingClientRect])(document.querySelectorAll('*')).join());