Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(DomRenderer): Adding support for document fragments in SVG foreign objects #9458

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 25 additions & 0 deletions modules/@angular/core/test/linker/integration_spec.ts
Expand Up @@ -1994,6 +1994,31 @@ function declareTests({useJit}: {useJit: boolean}) {
});
}));

it('should support foreignObjects with document fragments',
inject(
[TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.overrideView(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: switch to tcb.overrideTemplate(html)

MyComp, new ViewMetadata({
template:
'<svg><foreignObject><xhtml:div><p>Test</p></xhtml:div></foreignObject></svg>'
}))
.createAsync(MyComp)
.then((fixture) => {
var el = fixture.debugElement.nativeElement;
var svg = getDOM().childNodes(el)[0];
var foreignObject = getDOM().childNodes(svg)[0];
var p = getDOM().childNodes(foreignObject)[0];
expect(getDOM().getProperty(<Element>svg, 'namespaceURI'))
.toEqual('http://www.w3.org/2000/svg');
expect(getDOM().getProperty(<Element>foreignObject, 'namespaceURI'))
.toEqual('http://www.w3.org/2000/svg');
expect(getDOM().getProperty(<Element>p, 'namespaceURI'))
.toEqual('http://www.w3.org/1999/xhtml');

async.done();
});
}));
});

describe('attributes', () => {
Expand Down
3 changes: 2 additions & 1 deletion modules/@angular/platform-browser/src/dom/dom_renderer.ts
Expand Up @@ -15,7 +15,8 @@ import {camelCaseToDashCase} from './util';

const NAMESPACE_URIS = {
'xlink': 'http://www.w3.org/1999/xlink',
'svg': 'http://www.w3.org/2000/svg'
'svg': 'http://www.w3.org/2000/svg',
'xhtml': 'http://www.w3.org/1999/xhtml'
};
const TEMPLATE_COMMENT_TEXT = 'template bindings={}';
var TEMPLATE_BINDINGS_EXP = /^template bindings=(.*)$/g;
Expand Down