Refactor %for macro handling: dynamically bind key attribute and remove original %key attribute
This commit is contained in:
		
							parent
							
								
									719853d2d1
								
							
						
					
					
						commit
						1afae00c45
					
				
							
								
								
									
										10
									
								
								src/main.ts
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								src/main.ts
									
									
									
									
									
								
							|  | @ -466,10 +466,18 @@ export default (options: ComponentOptions) => { | |||
| 					const itemContext = { | ||||
| 						[itemVar]: item | ||||
| 					} | ||||
| 					if (indexVar) { | ||||
| 					if (indexVar) | ||||
| 						itemContext[indexVar] = index | ||||
| 
 | ||||
| 					// insert %key attribute, which dynamically bind the key
 | ||||
| 					if (keyAttr) { | ||||
| 						const keyValue = this._evaluateExpressionWithItemContext(keyAttr, itemContext) | ||||
| 						itemElement.setAttribute('data-laterano-key', String(keyValue)) | ||||
| 					} | ||||
| 
 | ||||
| 					// remove original %key attribute
 | ||||
| 					itemElement.removeAttribute('%key') | ||||
| 
 | ||||
| 					// Apply the item context to the element
 | ||||
| 					// We will use recursive processing here!
 | ||||
| 					this._processElementWithItemContext(itemElement, itemContext) | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user