@@ -89,18 +89,23 @@ public void handleElement(Element elt, HtmlPopulator.Context context) {
8989 }
9090 } else {
9191 Attributes attributes = elt .getAttributes ();
92+ boolean attributesAreExtracted = shouldExtractAttributes (elt );
9293 // attributes can be null for directives
9394 if (attributes != null )
9495 for (Attribute attr : attributes ) {
9596 // ignore empty attributes
9697 if (attr .getValue () == null || attr .getValue ().isEmpty ()) continue ;
9798
99+ // If attributes are not extracted we can't use the attribute as the parent node.
100+ // In this case, use the enclosing element as the node.
101+ Segment parentSegment = attributesAreExtracted ? attr : elt ;
102+
98103 extractTemplateTags (
99104 textualExtractor ,
100105 attr .getSource (),
101106 attr .getBegin (),
102107 attr .getEnd (),
103- () -> context .getNodeLabel (attr ));
108+ () -> context .getNodeLabel (parentSegment ));
104109
105110 String source = attr .getValue ();
106111 int valueStart = attr .getValueSegment ().getBegin ();
@@ -113,7 +118,7 @@ public void handleElement(Element elt, HtmlPopulator.Context context) {
113118 source ,
114119 valueStart ,
115120 false /* isTypeScript */ ,
116- context .getNodeLabel (attr ));
121+ context .getNodeLabel (parentSegment ));
117122 } else if (isAngularTemplateAttributeName (attr .getName ())) {
118123 // For an attribute *ngFor="let var of EXPR", start parsing at EXPR
119124 int offset = 0 ;
@@ -133,7 +138,7 @@ public void handleElement(Element elt, HtmlPopulator.Context context) {
133138 source ,
134139 valueStart + offset ,
135140 false /* isTypeScript */ ,
136- context .getNodeLabel (attr ));
141+ context .getNodeLabel (parentSegment ));
137142 } else if (source .startsWith ("javascript:" )) {
138143 source = source .substring (11 );
139144 extractSnippet (
@@ -144,7 +149,7 @@ public void handleElement(Element elt, HtmlPopulator.Context context) {
144149 source ,
145150 valueStart + 11 ,
146151 false /* isTypeScript */ ,
147- context .getNodeLabel (attr ));
152+ context .getNodeLabel (parentSegment ));
148153 }
149154 }
150155 }
0 commit comments