fix(platform-server): support svg elements with namespaced attributes (#15101)
This commit is contained in:
parent
80649ea03c
commit
f093501501
|
@ -453,11 +453,15 @@ export class Parse5DomAdapter extends DomAdapter {
|
|||
hasAttribute(element: any, attribute: string): boolean {
|
||||
return element.attribs && element.attribs[attribute] != null;
|
||||
}
|
||||
hasAttributeNS(element: any, ns: string, attribute: string): boolean { throw 'not implemented'; }
|
||||
hasAttributeNS(element: any, ns: string, attribute: string): boolean {
|
||||
return this.hasAttribute(element, attribute);
|
||||
}
|
||||
getAttribute(element: any, attribute: string): string {
|
||||
return this.hasAttribute(element, attribute) ? element.attribs[attribute] : null;
|
||||
}
|
||||
getAttributeNS(element: any, ns: string, attribute: string): string { throw 'not implemented'; }
|
||||
getAttributeNS(element: any, ns: string, attribute: string): string {
|
||||
return this.getAttribute(element, attribute);
|
||||
}
|
||||
setAttribute(element: any, attribute: string, value: string) {
|
||||
if (attribute) {
|
||||
element.attribs[attribute] = value;
|
||||
|
@ -467,7 +471,7 @@ export class Parse5DomAdapter extends DomAdapter {
|
|||
}
|
||||
}
|
||||
setAttributeNS(element: any, ns: string, attribute: string, value: string) {
|
||||
throw 'not implemented';
|
||||
this.setAttribute(element, attribute, value);
|
||||
}
|
||||
removeAttribute(element: any, attribute: string) {
|
||||
if (attribute) {
|
||||
|
|
|
@ -70,6 +70,18 @@ class MyAsyncServerApp {
|
|||
class AsyncServerModule {
|
||||
}
|
||||
|
||||
@Component({selector: 'app', template: '<svg><use xlink:href="#clear"></use></svg>'})
|
||||
class SVGComponent {
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
declarations: [SVGComponent],
|
||||
imports: [BrowserModule.withServerTransition({appId: 'svg-server'}), ServerModule],
|
||||
bootstrap: [SVGComponent]
|
||||
})
|
||||
class SVGServerModule {
|
||||
}
|
||||
|
||||
@Component({selector: 'app', template: `Works!`, styles: [':host { color: red; }']})
|
||||
class MyStylesApp {
|
||||
}
|
||||
|
@ -322,6 +334,15 @@ export function main() {
|
|||
called = true;
|
||||
});
|
||||
})));
|
||||
|
||||
it('works with SVG elements', async(() => {
|
||||
renderModule(SVGServerModule, {document: doc}).then(output => {
|
||||
expect(output).toBe(
|
||||
'<html><head></head><body><app ng-version="0.0.0-PLACEHOLDER">' +
|
||||
'<svg><use xlink:href="#clear"></use></svg></app></body></html>');
|
||||
called = true;
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
describe('http', () => {
|
||||
|
|
Loading…
Reference in New Issue