Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Land: fixes for DOMAttrModified mutation events (Felix Gnass)
- Loading branch information
Showing
4 changed files
with
77 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* Intercepts a method by replacing the prototype's implementation | ||
* with a wrapper that invokes the given interceptor instead. | ||
* | ||
* utils.intercept(core.Element, 'inserBefore', | ||
* function(_super, args, newChild, refChild) { | ||
* console.log('insertBefore', newChild, refChild); | ||
* return _super.apply(this, args); | ||
* } | ||
* ); | ||
*/ | ||
exports.intercept = function(clazz, method, interceptor) { | ||
var proto = clazz.prototype, | ||
_super = proto[method], | ||
unwrapArgs = interceptor.length > 2; | ||
|
||
proto[method] = function() { | ||
if (unwrapArgs) { | ||
var args = Array.prototype.slice.call(arguments); | ||
args.unshift(_super, arguments); | ||
return interceptor.apply(this, args); | ||
} | ||
else { | ||
return interceptor.call(this, _super, arguments); | ||
} | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters