import { InjectDecoratorFactory , Injector , ParameterInjectInfoType , PropertyInjectInfoType } from '@indiv/di' ; import { ElementRef } from '../component' ; import { Renderer } from '../vnode' ; export const metadataOfAttribute = 'nvMetadataOfAttribute' ; export const metadataOfPropAttribute = 'nvMetadataOfPropAttribute' ; class extends InjectDecoratorFactory class AttributeDecorator extends InjectDecoratorFactory { constructor ( parameterName ? , propertyName ? ) { super ( parameterName , propertyName ) ; } Attribute param { ParameterInjectInfoType } injectInfo param { Injector } injector returns memberof public resolveParameterInject ( injectInfo , injector ) { const elementRef = injector . getInstance ( ElementRef ) ; const renderer = injector . getInstance ( Renderer ) ; return renderer . getAttribute ( elementRef . nativeElement , injectInfo . decoratorArgument ) ; } Attribute param { PropertyInjectInfoType } injectInfo param { Injector } injector returns memberof public resolvePropertyInject ( injectInfo , injector ) { const elementRef = injector . getInstance ( ElementRef ) ; const renderer = injector . getInstance ( Renderer ) ; return renderer . getAttribute ( elementRef . nativeElement , injectInfo . decoratorArgument ) ; } } export const Attribute = new AttributeDecorator ( metadataOfAttribute , metadataOfPropAttribute ) . createInjectDecoratorFactory ( ) ;