js hook dom

var _appendChild = Node.prototype.appendChild;
Node.prototype.appendChild = function(){
    console.log("Hook appendChild");
    return _appendChild();
};
Node.prototype.appendChild = new Proxy(
    Node.prototype.appendChild,{
        apply:function(){
            var retval = Reflect.apply(trapTarget.thisArg,argumentList);
            console.log("appendChild retval:",retval);
            return retval;
         }
​
   }
);
原文地址:https://www.cnblogs.com/angdh/p/15780804.html