Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

fix(element): Fix native_shim.js not implement adoptedCallback error. #1179

Merged
merged 1 commit into from
Jan 22, 2019

Conversation

JiaLiPassion
Copy link
Collaborator

To pass test in angular, we need to handle some of callbacks are not implemented by some polyfilles. @webcomponent/native_shim.js doesn't implement adopdatedCallback, zone.js will throw error, so we need to check this case.

@@ -26,7 +26,7 @@ function patchCallbacks(target: any, targetName: string, method: string, callbac
if (descriptor && descriptor.value) {
descriptor.value = wrapWithCurrentZone(descriptor.value, source);
_redefineProperty(opts.prototype, callback, descriptor);
} else {
} else if (prototype[callback]) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is already a check for prototype.hasOwnProperty(callback) a few lines above.
Does it mean that the properties exists, but are falsy? (That would be unexpected.)

Copy link
Collaborator Author

@JiaLiPassion JiaLiPassion Jan 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, hasOwnProperty return true, but prototype[call back] is undefined.
Some case like this.

var a = {
  key: undefined
};

console.log('hasOwnProperty', a.hasOwnProperty('key')); // output is true
console.log('prop', a.key);  // output is undefined.

@vikerman vikerman merged commit fd069db into angular:master Jan 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants