fix(ivy): DebugNode.classes not working on SVG elements (#34872)

Fixes Ivy throwing an error when trying to access the `DebugNode.classes` of an SVG element. The problem is that the `className` of an SVG element is an `SVGAnimatedString`, rather than a plain string.

Fixes #34868.

PR Close #34872
This commit is contained in:
Kristiyan Kostadinov
2020-01-20 21:22:38 +01:00
committed by Andrew Kushnir
parent e83fe875a0
commit 7e8aac128b
2 changed files with 23 additions and 3 deletions

View File

@ -368,6 +368,22 @@ class TestCmptWithPropInterpolation {
.toBeFalsy('Expected bound host CSS class "absent-class" to be absent');
});
it('should list classes on SVG nodes', () => {
// Class bindings on SVG elements require a polyfill
// on IE which we don't include when running tests.
if (typeof SVGElement !== 'undefined' && !('classList' in SVGElement.prototype)) {
return;
}
TestBed.overrideTemplate(TestApp, `<svg [class.foo]="true" [class.bar]="true"></svg>`);
fixture = TestBed.createComponent(TestApp);
fixture.detectChanges();
const classes = fixture.debugElement.children[0].classes;
expect(classes['foo']).toBe(true);
expect(classes['bar']).toBe(true);
});
it('should list element styles', () => {
fixture = TestBed.createComponent(TestApp);
fixture.detectChanges();