Extract direct text nodes only when parsing directive
This commit is contained in:
		| @@ -22,12 +22,17 @@ export class DirectiveParser extends AbstractTemplateParser implements ParserInt | |||||||
| 			.each((i: number, element: CheerioElement) => { | 			.each((i: number, element: CheerioElement) => { | ||||||
| 				const $element = $(element); | 				const $element = $(element); | ||||||
| 				const attr = $element.attr('translate'); | 				const attr = $element.attr('translate'); | ||||||
| 				const text = $element.html().trim(); |  | ||||||
|  |  | ||||||
| 				if (attr) { | 				if (attr) { | ||||||
| 					results.push(attr); | 					results.push(attr); | ||||||
| 				} else if (text) { | 				} else { | ||||||
| 					results.push(text); | 					$element | ||||||
|  | 						.contents() | ||||||
|  | 						.toArray() | ||||||
|  | 						.filter(textNode => textNode.type === 'text') | ||||||
|  | 						.map(textNode => textNode.nodeValue.trim()) | ||||||
|  | 						.filter(text => text.length > 0) | ||||||
|  | 						.forEach(text => results.push(text)); | ||||||
| 				} | 				} | ||||||
| 			}); | 			}); | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user