Skip to content

Commit

Permalink
Merge pull request #15586 from stefan-schweiger/15580-property-metadata
Browse files Browse the repository at this point in the history
Angular: Fix incomplete property metadata when using inheritance
  • Loading branch information
shilman committed Jul 28, 2021
2 parents 19f32e3 + e1963b1 commit cb09e54
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Expand Up @@ -107,13 +107,20 @@ export const isComponent = (component: any): component is Type<unknown> => {
*/
export const getComponentPropsDecoratorMetadata = (component: any) => {
const decoratorKey = '__prop__metadata__';
const propsDecorators: Record<string, (Input | Output)[]> =
let propsDecorators: Record<string, (Input | Output)[]> =
Reflect &&
Reflect.getOwnPropertyDescriptor &&
Reflect.getOwnPropertyDescriptor(component, decoratorKey)
? Reflect.getOwnPropertyDescriptor(component, decoratorKey).value
: component[decoratorKey];

const parent = Reflect && Reflect.getPrototypeOf && Reflect.getPrototypeOf(component);

if (parent) {
const parentPropsDecorators = getComponentPropsDecoratorMetadata(parent);
propsDecorators = { ...parentPropsDecorators, ...propsDecorators };
}

return propsDecorators;
};

Expand Down
Expand Up @@ -16,6 +16,7 @@ exports[`Storyshots Basics / Component / With Inheritance icon button 1`] = `
<storybook-wrapper>
<storybook-icon-button
ng-reflect-icon="this is icon"
ng-reflect-label="this is label"
>
<button>
this is label - this is icon
Expand Down

0 comments on commit cb09e54

Please sign in to comment.