Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1798 from Sebobo/t/1797
Browse files Browse the repository at this point in the history
Feature: Added support for creating elements from other XML namespaces. See ckeditor/ckeditor5#2088.
  • Loading branch information
Reinmar authored Oct 8, 2019
2 parents 45c82be + 1f2d981 commit a9190c9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/view/domconverter.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,11 @@ export default class DomConverter {
return domElement;
} else {
// Create DOM element.
domElement = domDocument.createElement( viewNode.name );
if ( viewNode.hasAttribute( 'xmlns' ) ) {
domElement = domDocument.createElementNS( viewNode.getAttribute( 'xmlns' ), viewNode.name );
} else {
domElement = domDocument.createElement( viewNode.name );
}

if ( options.bind ) {
this.bindElements( domElement, viewNode );
Expand Down
9 changes: 9 additions & 0 deletions tests/view/domconverter/view-to-dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,15 @@ describe( 'DomConverter', () => {
expect( domTextNode.data ).to.equal( 'foo' );
} );

it( 'should create namespaced elements', () => {
const namespace = 'http://www.w3.org/2000/svg';
const viewSvg = new ViewElement( 'svg', { xmlns: namespace } );

const domSvg = converter.viewToDom( viewSvg, document );

expect( domSvg.createSVGRect ).to.be.a( 'function' );
} );

describe( 'it should convert spaces to  ', () => {
it( 'at the beginning of each container element', () => {
const viewDiv = new ViewContainerElement( 'div', null, [
Expand Down

0 comments on commit a9190c9

Please sign in to comment.