Skip to content

Instantly share code, notes, and snippets.

@Williammer
Created June 14, 2014 14:54
Show Gist options
  • Select an option

  • Save Williammer/013348af59acb3221479 to your computer and use it in GitHub Desktop.

Select an option

Save Williammer/013348af59acb3221479 to your computer and use it in GitHub Desktop.
jsPattern.wrapFnWithNewFn.js - to replace the function with a new function at certain situation.
function wrap(object, method, wrapper) {
var fn = object[method];
return object[method] = function () {
return wrapper.apply(this, [fn.bind(this)].concat(
Array.prototype.slice.call(arguments)));
};
}
if (Prototype.Browser.Opera) {
wrap(Element.Methods, "readAttribute",
function (original, elem, attr) {
return attr == "title" ? elem.title : original(elem, attr);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment