@@ -151,37 +151,37 @@ export class BaseCustomWebComponentNoAttachedTemplate extends HTMLElement {
151
151
if ( ! node )
152
152
node = this . shadowRoot . childNodes . length > 0 ? this . shadowRoot : this . _rootDocumentFragment ;
153
153
if ( node instanceof Element ) { //node.nodeType === 1
154
- let attributes = Array . from ( node . attributes ) ;
154
+ const attributes = Array . from ( node . attributes ) ;
155
155
for ( let a of attributes ) {
156
156
if ( a . name . startsWith ( 'css:' ) && a . value . startsWith ( '[[' ) && a . value . endsWith ( ']]' ) ) {
157
- let value = a . value . substring ( 2 , a . value . length - 2 ) . replaceAll ( '&' , '&' ) ;
158
- let camelCased = a . name . substring ( 4 , a . name . length ) . replace ( / - ( [ a - z ] ) / g, ( g ) => g [ 1 ] . toUpperCase ( ) ) ;
157
+ const value = a . value . substring ( 2 , a . value . length - 2 ) . replaceAll ( '&' , '&' ) ;
158
+ const camelCased = a . name . substring ( 4 , a . name . length ) . replace ( / - ( [ a - z ] ) / g, ( g ) => g [ 1 ] . toUpperCase ( ) ) ;
159
159
this . _bindings . push ( ( ) => this . _bindingSetElementCssValue ( < HTMLElement | SVGElement > node , camelCased , value , repeatBindingItems , host , context ) ) ;
160
160
this . _bindings [ this . _bindings . length - 1 ] ( true ) ;
161
161
} else if ( a . name . startsWith ( 'class:' ) && a . value . startsWith ( '[[' ) && a . value . endsWith ( ']]' ) ) {
162
- let value = a . value . substring ( 2 , a . value . length - 2 ) . replaceAll ( '&' , '&' ) ;
163
- let camelCased = a . name . substring ( 6 , a . name . length ) . replace ( / - ( [ a - z ] ) / g, ( g ) => g [ 1 ] . toUpperCase ( ) ) ;
162
+ const value = a . value . substring ( 2 , a . value . length - 2 ) . replaceAll ( '&' , '&' ) ;
163
+ const camelCased = a . name . substring ( 6 , a . name . length ) . replace ( / - ( [ a - z ] ) / g, ( g ) => g [ 1 ] . toUpperCase ( ) ) ;
164
164
this . _bindings . push ( ( ) => this . _bindingSetElementClass ( < HTMLElement | SVGElement > node , camelCased , value , repeatBindingItems , host , context ) ) ;
165
165
this . _bindings [ this . _bindings . length - 1 ] ( true ) ;
166
166
} else if ( a . name == 'repeat-changed-item-callback' ) {
167
167
//do nothing
168
168
} else if ( a . name . startsWith ( 'repeat:' ) && a . value . startsWith ( '[[' ) && a . value . endsWith ( ']]' ) ) {
169
- let value = a . value . substring ( 2 , a . value . length - 2 ) . replaceAll ( '&' , '&' ) ;
170
- let bindingItemVariableName = a . name . substring ( 7 , a . name . length ) . replace ( / - ( [ a - z ] ) / g, ( g ) => g [ 1 ] . toUpperCase ( ) ) ;
171
- let elementsCache : Node [ ] = [ ] ;
169
+ const value = a . value . substring ( 2 , a . value . length - 2 ) . replaceAll ( '&' , '&' ) ;
170
+ const bindingItemVariableName = a . name . substring ( 7 , a . name . length ) . replace ( / - ( [ a - z ] ) / g, ( g ) => g [ 1 ] . toUpperCase ( ) ) ;
171
+ const elementsCache : Node [ ] = [ ] ;
172
172
let bindingIndexname = 'index' ;
173
173
let changeItemCallback = null ;
174
- let indexNameAttribute = attributes . find ( x => x . name == 'repeat-index' ) ;
174
+ const indexNameAttribute = attributes . find ( x => x . name == 'repeat-index' ) ;
175
175
if ( indexNameAttribute )
176
176
bindingIndexname = indexNameAttribute . value ;
177
- let changeItemCallbackAttribute = attributes . find ( x => x . name == 'repeat-changed-item-callback' ) ;
177
+ const changeItemCallbackAttribute = attributes . find ( x => x . name == 'repeat-changed-item-callback' ) ;
178
178
if ( changeItemCallbackAttribute )
179
179
changeItemCallback = changeItemCallbackAttribute . value ;
180
180
this . _bindings . push ( ( ) => this . _bindingRepeat ( < HTMLTemplateElement > node , bindingItemVariableName , bindingIndexname , value , changeItemCallback , repeatBindingItems , elementsCache , host , context ) ) ;
181
181
this . _bindings [ this . _bindings . length - 1 ] ( true ) ;
182
182
} else if ( a . name . startsWith ( '@' ) && a . value . startsWith ( '[[' ) && a . value . endsWith ( ']]' ) ) { //todo remove events on repeat refresh
183
- let value = a . value . substring ( 2 , a . value . length - 2 ) . replaceAll ( '&' , '&' ) ;
184
- let camelCased = a . name . substring ( 1 , a . name . length ) . replace ( / - ( [ a - z ] ) / g, ( g ) => g [ 1 ] . toUpperCase ( ) ) ;
183
+ const value = a . value . substring ( 2 , a . value . length - 2 ) . replaceAll ( '&' , '&' ) ;
184
+ const camelCased = a . name . substring ( 1 , a . name . length ) . replace ( / - ( [ a - z ] ) / g, ( g ) => g [ 1 ] . toUpperCase ( ) ) ;
185
185
if ( a . name == "@touch:contextmenu" )
186
186
addTouchFriendlyContextMenu ( node , ( e ) => this . _bindingRunEval ( value , repeatBindingItems , e , host , context ) ) ;
187
187
else {
@@ -193,7 +193,7 @@ export class BaseCustomWebComponentNoAttachedTemplate extends HTMLElement {
193
193
}
194
194
} else if ( a . value . startsWith ( '[[' ) && a . value . endsWith ( ']]' ) ) {
195
195
let value = a . value . substring ( 2 , a . value . length - 2 ) . replaceAll ( '&' , '&' ) ;
196
- let camelCased = a . name . replace ( / - ( [ a - z ] ) / g, ( g ) => g [ 1 ] . toUpperCase ( ) ) ;
196
+ const camelCased = a . name . replace ( / - ( [ a - z ] ) / g, ( g ) => g [ 1 ] . toUpperCase ( ) ) ;
197
197
let noNull = false ;
198
198
if ( value . startsWith ( '?' ) ) {
199
199
value = value . substring ( 1 ) ;
@@ -207,50 +207,41 @@ export class BaseCustomWebComponentNoAttachedTemplate extends HTMLElement {
207
207
let event = 'input' ;
208
208
if ( attributeValues . length > 1 && attributeValues [ 1 ] )
209
209
event = attributeValues [ 1 ] ;
210
- let camelCased = a . name . replace ( / - ( [ a - z ] ) / g, ( g ) => g [ 1 ] . toUpperCase ( ) ) ;
211
- if ( camelCased . startsWith ( 'set:' ) ) {
212
- const pName = camelCased . substring ( 4 ) ;
213
- event . split ( ';' ) . forEach ( x => node . addEventListener ( x , ( e ) => {
214
- let ctx = { value : node [ pName ] } ;
215
- ctx [ pName ] = node [ pName ] ; //value is in value or property-name
216
- this . _bindingRunEval ( value , repeatBindingItems , e , host , { value : node [ pName ] } )
217
- } ) ) ;
218
- } else {
219
- let noNull = false ;
220
- if ( value . startsWith ( '?' ) ) {
221
- value = value . substring ( 1 ) ;
222
- noNull = true ;
223
- }
224
- this . _bindings . push ( ( firstRun ?: boolean ) => this . _bindingSetNodeValue ( firstRun , node , a , camelCased , value , repeatBindingItems , removeAttributes , host , context , noNull ) ) ;
225
- this . _bindings [ this . _bindings . length - 1 ] ( true ) ;
226
- if ( event ) {
227
- event . split ( ';' ) . forEach ( x => node . addEventListener ( x , ( e ) => this . _bindingsSetValue ( this , value , ( < HTMLInputElement > node ) [ camelCased ] ) ) ) ;
228
- }
210
+ const camelCased = a . name . replace ( / - ( [ a - z ] ) / g, ( g ) => g [ 1 ] . toUpperCase ( ) ) ;
211
+ let noNull = false ;
212
+ if ( value . startsWith ( '?' ) ) {
213
+ value = value . substring ( 1 ) ;
214
+ noNull = true ;
215
+ }
216
+ this . _bindings . push ( ( firstRun ?: boolean ) => this . _bindingSetNodeValue ( firstRun , node , a , camelCased , value , repeatBindingItems , removeAttributes , host , context , noNull ) ) ;
217
+ this . _bindings [ this . _bindings . length - 1 ] ( true ) ;
218
+ if ( event ) {
219
+ event . split ( ';' ) . forEach ( x => node . addEventListener ( x , ( e ) => this . _bindingsSetValue ( this , value , ( < HTMLInputElement > node ) [ camelCased ] ) ) ) ;
229
220
}
230
221
}
231
222
}
232
223
} else if ( node . nodeType === 3 ) {
233
224
if ( node . nodeValue . indexOf ( '[[' ) >= 0 ) {
234
225
const text = node . nodeValue ;
235
- let matches = text . matchAll ( ( < RegExp > ( < any > this . constructor ) . _bindingRegex ) ) ;
226
+ const matches = text . matchAll ( ( < RegExp > ( < any > this . constructor ) . _bindingRegex ) ) ;
236
227
let lastindex = 0 ;
237
228
let fragment : DocumentFragment ;
238
229
for ( let m of matches ) {
239
230
if ( m . index == 0 && m [ 0 ] . length == text . length && node . parentNode . childNodes . length == 1 ) {
240
- let value = m [ 0 ] . substr ( 2 , m [ 0 ] . length - 4 ) ;
241
- let parent = node . parentNode ;
231
+ const value = m [ 0 ] . substr ( 2 , m [ 0 ] . length - 4 ) ;
232
+ const parent = node . parentNode ;
242
233
node . parentNode . removeChild ( node ) ;
243
234
this . _bindings . push ( ( firstRun ?: boolean ) => this . _bindingSetNodeValue ( firstRun , parent , null , 'innerHTML' , value , repeatBindingItems , removeAttributes , host , context , false ) ) ;
244
235
this . _bindings [ this . _bindings . length - 1 ] ( true ) ;
245
236
} else {
246
237
if ( ! fragment )
247
238
fragment = document . createDocumentFragment ( ) ;
248
239
if ( m . index - lastindex > 0 ) {
249
- let tn = document . createTextNode ( text . substr ( lastindex , m . index - lastindex ) ) ;
240
+ const tn = document . createTextNode ( text . substr ( lastindex , m . index - lastindex ) ) ;
250
241
fragment . appendChild ( tn ) ;
251
242
}
252
243
const newNode = document . createElement ( 'span' ) ;
253
- let value = m [ 0 ] . substr ( 2 , m [ 0 ] . length - 4 ) ;
244
+ const value = m [ 0 ] . substr ( 2 , m [ 0 ] . length - 4 ) ;
254
245
this . _bindings . push ( ( firstRun ?: boolean ) => this . _bindingSetNodeValue ( firstRun , newNode , null , 'innerHTML' , value , repeatBindingItems , removeAttributes , host , context , false ) ) ;
255
246
this . _bindings [ this . _bindings . length - 1 ] ( true ) ;
256
247
fragment . appendChild ( newNode ) ;
0 commit comments