Skip to content

Commit 3644eef

Browse files
gionkunzvicb
authored andcommitted
feat(DomRenderer): Adding support for document fragments in SVG foreign objects (angular#9458)
1 parent fb25096 commit 3644eef

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

modules/@angular/core/test/linker/integration_spec.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2000,6 +2000,31 @@ function declareTests({useJit}: {useJit: boolean}) {
20002000
});
20012001
}));
20022002

2003+
it('should support foreignObjects with document fragments',
2004+
inject(
2005+
[TestComponentBuilder, AsyncTestCompleter],
2006+
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
2007+
tcb.overrideView(
2008+
MyComp, new ViewMetadata({
2009+
template:
2010+
'<svg><foreignObject><xhtml:div><p>Test</p></xhtml:div></foreignObject></svg>'
2011+
}))
2012+
.createAsync(MyComp)
2013+
.then((fixture) => {
2014+
var el = fixture.debugElement.nativeElement;
2015+
var svg = getDOM().childNodes(el)[0];
2016+
var foreignObject = getDOM().childNodes(svg)[0];
2017+
var p = getDOM().childNodes(foreignObject)[0];
2018+
expect(getDOM().getProperty(<Element>svg, 'namespaceURI'))
2019+
.toEqual('http://www.w3.org/2000/svg');
2020+
expect(getDOM().getProperty(<Element>foreignObject, 'namespaceURI'))
2021+
.toEqual('http://www.w3.org/2000/svg');
2022+
expect(getDOM().getProperty(<Element>p, 'namespaceURI'))
2023+
.toEqual('http://www.w3.org/1999/xhtml');
2024+
2025+
async.done();
2026+
});
2027+
}));
20032028
});
20042029

20052030
describe('attributes', () => {

modules/@angular/platform-browser/src/dom/dom_renderer.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ import {camelCaseToDashCase} from './util';
2323

2424
const NAMESPACE_URIS = {
2525
'xlink': 'http://www.w3.org/1999/xlink',
26-
'svg': 'http://www.w3.org/2000/svg'
26+
'svg': 'http://www.w3.org/2000/svg',
27+
'xhtml': 'http://www.w3.org/1999/xhtml'
2728
};
2829
const TEMPLATE_COMMENT_TEXT = 'template bindings={}';
2930
var TEMPLATE_BINDINGS_EXP = /^template bindings=(.*)$/g;

0 commit comments

Comments
 (0)