@@ -17,6 +17,7 @@ function sortedClassNames(element: Element): string[] {
1717 * Verifies that an element contains a single <svg> child element, and returns that child.
1818 */
1919function verifyAndGetSingleSvgChild ( element : SVGElement ) : SVGElement {
20+ expect ( element . id ) . toBeFalsy ( ) ;
2021 expect ( element . childNodes . length ) . toBe ( 1 ) ;
2122 const svgChild = element . childNodes [ 0 ] as SVGElement ;
2223 expect ( svgChild . tagName . toLowerCase ( ) ) . toBe ( 'svg' ) ;
@@ -31,7 +32,9 @@ function verifyPathChildElement(element: Element, attributeValue: string): void
3132 expect ( element . childNodes . length ) . toBe ( 1 ) ;
3233 const pathElement = element . childNodes [ 0 ] as SVGPathElement ;
3334 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 ) ;
3538}
3639
3740
@@ -190,7 +193,7 @@ describe('MatIcon', () => {
190193 svgChild = svgElement . childNodes [ 0 ] ;
191194 // The first <svg> child should be the <g id="pig"> element.
192195 expect ( svgChild . tagName . toLowerCase ( ) ) . toBe ( 'g' ) ;
193- expect ( svgChild . getAttribute ( 'id ' ) ) . toBe ( 'pig' ) ;
196+ expect ( svgChild . getAttribute ( 'name ' ) ) . toBe ( 'pig' ) ;
194197 verifyPathChildElement ( svgChild , 'oink' ) ;
195198
196199 // Change the icon, and the SVG element should be replaced.
@@ -200,7 +203,7 @@ describe('MatIcon', () => {
200203 svgChild = svgElement . childNodes [ 0 ] ;
201204 // The first <svg> child should be the <g id="cow"> element.
202205 expect ( svgChild . tagName . toLowerCase ( ) ) . toBe ( 'g' ) ;
203- expect ( svgChild . getAttribute ( 'id ' ) ) . toBe ( 'cow' ) ;
206+ expect ( svgChild . getAttribute ( 'name ' ) ) . toBe ( 'cow' ) ;
204207 verifyPathChildElement ( svgChild , 'moo' ) ;
205208 } ) ;
206209
@@ -224,7 +227,8 @@ describe('MatIcon', () => {
224227 svgChild = svgElement . childNodes [ 0 ] ;
225228 // The <svg> child should be the <g id="pig"> element.
226229 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 ( '' ) ;
228232 expect ( svgChild . childNodes . length ) . toBe ( 1 ) ;
229233 verifyPathChildElement ( svgChild , 'oink' ) ;
230234
@@ -237,7 +241,7 @@ describe('MatIcon', () => {
237241 svgChild = svgElement . childNodes [ 0 ] ;
238242 // The first <svg> child should be the <g id="cow"> element.
239243 expect ( svgChild . tagName . toLowerCase ( ) ) . toBe ( 'g' ) ;
240- expect ( svgChild . getAttribute ( 'id ' ) ) . toBe ( 'cow' ) ;
244+ expect ( svgChild . getAttribute ( 'name ' ) ) . toBe ( 'cow' ) ;
241245 expect ( svgChild . childNodes . length ) . toBe ( 1 ) ;
242246 verifyPathChildElement ( svgChild , 'moo moo' ) ;
243247 } ) ;
@@ -259,7 +263,7 @@ describe('MatIcon', () => {
259263 expect ( svgElement . querySelector ( 'symbol' ) ) . toBeFalsy ( ) ;
260264 expect ( svgElement . childNodes . length ) . toBe ( 1 ) ;
261265 expect ( firstChild . nodeName . toLowerCase ( ) ) . toBe ( 'path' ) ;
262- expect ( ( firstChild as HTMLElement ) . getAttribute ( 'id ' ) ) . toBe ( 'quack' ) ;
266+ expect ( ( firstChild as HTMLElement ) . getAttribute ( 'name ' ) ) . toBe ( 'quack' ) ;
263267 } ) ;
264268
265269 it ( 'should not wrap <svg> elements in icon sets in another svg tag' , ( ) => {
0 commit comments