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
vikerman merged 1 commit into
angular:masterfrom
JiaLiPassion:custom-element-1
Jan 22, 2019
Merged

fix(element): Fix native_shim.js not implement adoptedCallback error.#1179
vikerman merged 1 commit into
angular:masterfrom
JiaLiPassion:custom-element-1

Conversation

@JiaLiPassion

Copy link
Copy Markdown
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.

descriptor.value = wrapWithCurrentZone(descriptor.value, source);
_redefineProperty(opts.prototype, callback, descriptor);
} else {
} else if (prototype[callback]) {

Copy link
Copy Markdown
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.)

@JiaLiPassionJiaLiPassionJan 20, 2019

Copy link
Copy Markdown
CollaboratorAuthor

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:masterJan 22, 2019
Sign up for freeto 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

@JiaLiPassion@gkalpak@vikerman@googlebot