@@ -68,12 +68,12 @@ const standardCustomElement =
6868 *
6969 * @param tagName the name of the custom element to define
7070 */
71- export const customElement = ( tagName : string ) => (
72- classOrDescriptor : Constructor < HTMLElement > | ClassDescriptor ) =>
73- ( typeof classOrDescriptor === 'function' )
74- ? legacyCustomElement ( tagName ,
75- classOrDescriptor as Constructor < HTMLElement > )
76- : standardCustomElement ( tagName , classOrDescriptor as ClassDescriptor ) ;
71+ export const customElement = ( tagName : string ) =>
72+ ( classOrDescriptor : Constructor < HTMLElement > | ClassDescriptor ) =>
73+ ( typeof classOrDescriptor === 'function' ) ?
74+ legacyCustomElement (
75+ tagName , classOrDescriptor as Constructor < HTMLElement > ) :
76+ standardCustomElement ( tagName , classOrDescriptor as ClassDescriptor ) ;
7777
7878const standardProperty =
7979 ( options : PropertyDeclaration , element : ClassElement ) => {
@@ -93,10 +93,10 @@ const standardProperty =
9393 // must return some kind of descriptor, so return a descriptor for an
9494 // unused prototype field. The finisher calls createProperty().
9595 return {
96- kind : 'field' ,
97- key : Symbol ( ) ,
98- placement : 'own' ,
99- descriptor : { } ,
96+ kind : 'field' ,
97+ key : Symbol ( ) ,
98+ placement : 'own' ,
99+ descriptor : { } ,
100100 // When @babel /plugin-proposal-decorators implements initializers,
101101 // do this instead of the initializer below. See:
102102 // https://github.com/babel/babel/issues/9260 extras: [
@@ -118,10 +118,11 @@ const standardProperty =
118118 }
119119 } ;
120120
121- const legacyProperty = ( options : PropertyDeclaration , proto : Object ,
122- name : PropertyKey ) => {
123- ( proto . constructor as typeof UpdatingElement ) . createProperty ( name ! , options ) ;
124- } ;
121+ const legacyProperty =
122+ ( options : PropertyDeclaration , proto : Object , name : PropertyKey ) => {
123+ ( proto . constructor as typeof UpdatingElement )
124+ . createProperty ( name ! , options ) ;
125+ } ;
125126
126127/**
127128 * A property decorator which creates a LitElement property which reflects a
@@ -132,35 +133,36 @@ const legacyProperty = (options: PropertyDeclaration, proto: Object,
132133 */
133134export function property ( options ?: PropertyDeclaration ) {
134135 return ( protoOrDescriptor : Object | ClassElement , name ?: PropertyKey ) : any =>
135- ( name !== undefined )
136- ? legacyProperty ( options ! , protoOrDescriptor as Object , name )
137- : standardProperty ( options ! ,
138- protoOrDescriptor as ClassElement ) ;
136+ ( name !== undefined ) ?
137+ legacyProperty ( options ! , protoOrDescriptor as Object , name ) :
138+ standardProperty ( options ! , protoOrDescriptor as ClassElement ) ;
139139}
140140
141141/**
142142 * A property decorator that converts a class property into a getter that
143143 * executes a querySelector on the element's renderRoot.
144144 */
145- export const query = _query ( ( target : NodeSelector , selector : string ) =>
146- target . querySelector ( selector ) ) ;
145+ export const query = _query (
146+ ( target : NodeSelector , selector : string ) => target . querySelector ( selector ) ) ;
147147
148148/**
149149 * A property decorator that converts a class property into a getter
150150 * that executes a querySelectorAll on the element's renderRoot.
151151 */
152- export const queryAll = _query ( ( target : NodeSelector , selector : string ) =>
153- target . querySelectorAll ( selector ) ) ;
152+ export const queryAll = _query (
153+ ( target : NodeSelector , selector : string ) =>
154+ target . querySelectorAll ( selector ) ) ;
154155
155156const legacyQuery =
156- ( descriptor : PropertyDescriptor , proto : Object ,
157- name : PropertyKey ) => { Object . defineProperty ( proto , name , descriptor ) ; } ;
157+ ( descriptor : PropertyDescriptor , proto : Object , name : PropertyKey ) => {
158+ Object . defineProperty ( proto , name , descriptor ) ;
159+ } ;
158160
159161const standardQuery = ( descriptor : PropertyDescriptor , element : ClassElement ) =>
160162 ( {
161- kind : 'method' ,
162- placement : 'prototype' ,
163- key : element . key ,
163+ kind : 'method' ,
164+ placement : 'prototype' ,
165+ key : element . key ,
164166 descriptor,
165167 } ) ;
166168
@@ -173,33 +175,37 @@ const standardQuery = (descriptor: PropertyDescriptor, element: ClassElement) =>
173175 * element.
174176 */
175177function _query < T > ( queryFn : ( target : NodeSelector , selector : string ) => T ) {
176- return ( selector : string ) => ( protoOrDescriptor : Object | ClassElement ,
177- name ?: PropertyKey ) : any => {
178- const descriptor = {
179- get ( this : LitElement ) { return queryFn ( this . renderRoot ! , selector ) ; } ,
180- enumerable : true ,
181- configurable : true ,
182- } ;
183- return ( name !== undefined )
184- ? legacyQuery ( descriptor , protoOrDescriptor as Object , name )
185- : standardQuery ( descriptor , protoOrDescriptor as ClassElement ) ;
186- } ;
178+ return ( selector : string ) =>
179+ ( protoOrDescriptor : Object | ClassElement ,
180+ name ?: PropertyKey ) : any => {
181+ const descriptor = {
182+ get ( this : LitElement ) {
183+ return queryFn ( this . renderRoot ! , selector ) ;
184+ } ,
185+ enumerable : true ,
186+ configurable : true ,
187+ } ;
188+ return ( name !== undefined ) ?
189+ legacyQuery ( descriptor , protoOrDescriptor as Object , name ) :
190+ standardQuery ( descriptor , protoOrDescriptor as ClassElement ) ;
191+ } ;
187192}
188193
189194const standardEventOptions =
190195 ( options : AddEventListenerOptions , element : ClassElement ) => {
191196 return {
192197 ...element ,
193198 finisher ( clazz : typeof UpdatingElement ) {
194- Object . assign ( clazz . prototype [ element . key as keyof UpdatingElement ] ,
195- options ) ;
199+ Object . assign (
200+ clazz . prototype [ element . key as keyof UpdatingElement ] , options ) ;
196201 }
197202 } ;
198203 } ;
199204
200205const legacyEventOptions =
201- ( options : AddEventListenerOptions , proto : any ,
202- name : PropertyKey ) => { Object . assign ( proto [ name ] , options ) ; } ;
206+ ( options : AddEventListenerOptions , proto : any , name : PropertyKey ) => {
207+ Object . assign ( proto [ name ] , options ) ;
208+ } ;
203209
204210/**
205211 * Adds event listener options to a method used as an event listener in a
@@ -234,7 +240,7 @@ export const eventOptions = (options: AddEventListenerOptions) =>
234240 // TODO(kschaaf): unclear why it was only failing on this decorator and not
235241 // the others
236242 ( ( protoOrDescriptor : Object | ClassElement , name ?: string ) =>
237- ( name !== undefined )
238- ? legacyEventOptions ( options , protoOrDescriptor as Object , name )
239- : standardEventOptions ( options ,
240- protoOrDescriptor as ClassElement ) ) as any ;
243+ ( name !== undefined ) ?
244+ legacyEventOptions ( options , protoOrDescriptor as Object , name ) :
245+ standardEventOptions ( options , protoOrDescriptor as ClassElement ) ) as
246+ any ;
0 commit comments