@@ -89,18 +89,23 @@ public void handleElement(Element elt, HtmlPopulator.Context context) {
89
89
}
90
90
} else {
91
91
Attributes attributes = elt .getAttributes ();
92
+ boolean attributesAreExtracted = shouldExtractAttributes (elt );
92
93
// attributes can be null for directives
93
94
if (attributes != null )
94
95
for (Attribute attr : attributes ) {
95
96
// ignore empty attributes
96
97
if (attr .getValue () == null || attr .getValue ().isEmpty ()) continue ;
97
98
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
+
98
103
extractTemplateTags (
99
104
textualExtractor ,
100
105
attr .getSource (),
101
106
attr .getBegin (),
102
107
attr .getEnd (),
103
- () -> context .getNodeLabel (attr ));
108
+ () -> context .getNodeLabel (parentSegment ));
104
109
105
110
String source = attr .getValue ();
106
111
int valueStart = attr .getValueSegment ().getBegin ();
@@ -113,7 +118,7 @@ public void handleElement(Element elt, HtmlPopulator.Context context) {
113
118
source ,
114
119
valueStart ,
115
120
false /* isTypeScript */ ,
116
- context .getNodeLabel (attr ));
121
+ context .getNodeLabel (parentSegment ));
117
122
} else if (isAngularTemplateAttributeName (attr .getName ())) {
118
123
// For an attribute *ngFor="let var of EXPR", start parsing at EXPR
119
124
int offset = 0 ;
@@ -133,7 +138,7 @@ public void handleElement(Element elt, HtmlPopulator.Context context) {
133
138
source ,
134
139
valueStart + offset ,
135
140
false /* isTypeScript */ ,
136
- context .getNodeLabel (attr ));
141
+ context .getNodeLabel (parentSegment ));
137
142
} else if (source .startsWith ("javascript:" )) {
138
143
source = source .substring (11 );
139
144
extractSnippet (
@@ -144,7 +149,7 @@ public void handleElement(Element elt, HtmlPopulator.Context context) {
144
149
source ,
145
150
valueStart + 11 ,
146
151
false /* isTypeScript */ ,
147
- context .getNodeLabel (attr ));
152
+ context .getNodeLabel (parentSegment ));
148
153
}
149
154
}
150
155
}
0 commit comments