Skip to content

Commit

Permalink
Fetch descriptor from prototype chain
Browse files Browse the repository at this point in the history
  • Loading branch information
kingcody committed Apr 5, 2015
1 parent 3a3dae4 commit 8caeda7
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions zone.js
Original file line number Diff line number Diff line change
Expand Up @@ -644,11 +644,18 @@ Zone.patchRegisterElement = function () {
'detachedCallback',
'attributeChangedCallback'
];
var getPropertyDescriptor = function(obj, prop) {
var descriptor;
while (obj && !(descriptor = Object.getOwnPropertyDescriptor(obj, prop))) {
obj = obj.__proto__;
}
return descriptor;
};
document.registerElement = function (name, opts) {
callbacks.forEach(function (callback) {
if (opts.prototype[callback]) {
var descriptor = Object.getOwnPropertyDescriptor(opts.prototype, callback);
if (descriptor.value) {
var descriptor = getPropertyDescriptor(opts.prototype, callback);
if (descriptor && descriptor.value) {
descriptor.value = zone.bind(descriptor.value || opts.prototype[callback]);
Zone._redefineProperty(opts.prototype, callback, descriptor);
}
Expand Down

0 comments on commit 8caeda7

Please sign in to comment.