(node: html.Element, context: I18nMessageVisitorContext)
| 211 | } |
| 212 | |
| 213 | private _visitElementLike(node: html.Element, context: I18nMessageVisitorContext): i18n.Node { |
| 214 | const children = html.visitAll(this, node.children, context); |
| 215 | const attrs: {[k: string]: string} = {}; |
| 216 | const visitAttribute = (attr: html.Attribute) => { |
| 217 | // Do not visit the attributes, translatable ones are top-level ASTs |
| 218 | attrs[attr.name] = attr.value; |
| 219 | }; |
| 220 | |
| 221 | const nodeName = node.name; |
| 222 | const isVoid = getHtmlTagDefinition(node.name).isVoid; |
| 223 | |
| 224 | node.attrs.forEach(visitAttribute); |
| 225 | |
| 226 | const startPhName = context.placeholderRegistry.getStartTagPlaceholderName( |
| 227 | nodeName, |
| 228 | attrs, |
| 229 | isVoid, |
| 230 | ); |
| 231 | context.placeholderToContent[startPhName] = { |
| 232 | text: node.startSourceSpan.toString(), |
| 233 | sourceSpan: node.startSourceSpan, |
| 234 | }; |
| 235 | |
| 236 | let closePhName = ''; |
| 237 | |
| 238 | if (!isVoid) { |
| 239 | closePhName = context.placeholderRegistry.getCloseTagPlaceholderName(nodeName); |
| 240 | context.placeholderToContent[closePhName] = { |
| 241 | text: `</${nodeName}>`, |
| 242 | sourceSpan: node.endSourceSpan ?? node.sourceSpan, |
| 243 | }; |
| 244 | } |
| 245 | |
| 246 | const i18nNode = new i18n.TagPlaceholder( |
| 247 | nodeName, |
| 248 | attrs, |
| 249 | startPhName, |
| 250 | closePhName, |
| 251 | children, |
| 252 | isVoid, |
| 253 | node.sourceSpan, |
| 254 | node.startSourceSpan, |
| 255 | node.endSourceSpan, |
| 256 | ); |
| 257 | return context.visitNodeFn(node, i18nNode); |
| 258 | } |
| 259 | |
| 260 | /** |
| 261 | * Convert, text and interpolated tokens up into text and placeholder pieces. |
no test coverage detected