@@ -17,6 +17,7 @@ function sortedClassNames(element: Element): string[] {
17
17
* Verifies that an element contains a single <svg> child element, and returns that child.
18
18
*/
19
19
function verifyAndGetSingleSvgChild ( element : SVGElement ) : SVGElement {
20
+ expect ( element . id ) . toBeFalsy ( ) ;
20
21
expect ( element . childNodes . length ) . toBe ( 1 ) ;
21
22
const svgChild = element . childNodes [ 0 ] as SVGElement ;
22
23
expect ( svgChild . tagName . toLowerCase ( ) ) . toBe ( 'svg' ) ;
@@ -31,7 +32,9 @@ function verifyPathChildElement(element: Element, attributeValue: string): void
31
32
expect ( element . childNodes . length ) . toBe ( 1 ) ;
32
33
const pathElement = element . childNodes [ 0 ] as SVGPathElement ;
33
34
expect ( pathElement . tagName . toLowerCase ( ) ) . toBe ( 'path' ) ;
34
- expect ( pathElement . getAttribute ( 'id' ) ) . toBe ( attributeValue ) ;
35
+
36
+ // The testing data SVGs have the name attribute set for verification.
37
+ expect ( pathElement . getAttribute ( 'name' ) ) . toBe ( attributeValue ) ;
35
38
}
36
39
37
40
@@ -190,7 +193,7 @@ describe('MatIcon', () => {
190
193
svgChild = svgElement . childNodes [ 0 ] ;
191
194
// The first <svg> child should be the <g id="pig"> element.
192
195
expect ( svgChild . tagName . toLowerCase ( ) ) . toBe ( 'g' ) ;
193
- expect ( svgChild . getAttribute ( 'id ' ) ) . toBe ( 'pig' ) ;
196
+ expect ( svgChild . getAttribute ( 'name ' ) ) . toBe ( 'pig' ) ;
194
197
verifyPathChildElement ( svgChild , 'oink' ) ;
195
198
196
199
// Change the icon, and the SVG element should be replaced.
@@ -200,7 +203,7 @@ describe('MatIcon', () => {
200
203
svgChild = svgElement . childNodes [ 0 ] ;
201
204
// The first <svg> child should be the <g id="cow"> element.
202
205
expect ( svgChild . tagName . toLowerCase ( ) ) . toBe ( 'g' ) ;
203
- expect ( svgChild . getAttribute ( 'id ' ) ) . toBe ( 'cow' ) ;
206
+ expect ( svgChild . getAttribute ( 'name ' ) ) . toBe ( 'cow' ) ;
204
207
verifyPathChildElement ( svgChild , 'moo' ) ;
205
208
} ) ;
206
209
@@ -224,7 +227,8 @@ describe('MatIcon', () => {
224
227
svgChild = svgElement . childNodes [ 0 ] ;
225
228
// The <svg> child should be the <g id="pig"> element.
226
229
expect ( svgChild . tagName . toLowerCase ( ) ) . toBe ( 'g' ) ;
227
- expect ( svgChild . getAttribute ( 'id' ) ) . toBe ( 'pig' ) ;
230
+ expect ( svgChild . getAttribute ( 'name' ) ) . toBe ( 'pig' ) ;
231
+ expect ( svgChild . getAttribute ( 'id' ) ) . toBe ( '' ) ;
228
232
expect ( svgChild . childNodes . length ) . toBe ( 1 ) ;
229
233
verifyPathChildElement ( svgChild , 'oink' ) ;
230
234
@@ -237,7 +241,7 @@ describe('MatIcon', () => {
237
241
svgChild = svgElement . childNodes [ 0 ] ;
238
242
// The first <svg> child should be the <g id="cow"> element.
239
243
expect ( svgChild . tagName . toLowerCase ( ) ) . toBe ( 'g' ) ;
240
- expect ( svgChild . getAttribute ( 'id ' ) ) . toBe ( 'cow' ) ;
244
+ expect ( svgChild . getAttribute ( 'name ' ) ) . toBe ( 'cow' ) ;
241
245
expect ( svgChild . childNodes . length ) . toBe ( 1 ) ;
242
246
verifyPathChildElement ( svgChild , 'moo moo' ) ;
243
247
} ) ;
@@ -259,7 +263,7 @@ describe('MatIcon', () => {
259
263
expect ( svgElement . querySelector ( 'symbol' ) ) . toBeFalsy ( ) ;
260
264
expect ( svgElement . childNodes . length ) . toBe ( 1 ) ;
261
265
expect ( firstChild . nodeName . toLowerCase ( ) ) . toBe ( 'path' ) ;
262
- expect ( ( firstChild as HTMLElement ) . getAttribute ( 'id ' ) ) . toBe ( 'quack' ) ;
266
+ expect ( ( firstChild as HTMLElement ) . getAttribute ( 'name ' ) ) . toBe ( 'quack' ) ;
263
267
} ) ;
264
268
265
269
it ( 'should not wrap <svg> elements in icon sets in another svg tag' , ( ) => {
0 commit comments