Browse Source

Merge branch 'master' into t/ckeditor5/416d

Aleksander Nowodzinski 6 years ago
parent
commit
c9ca01a94f

+ 2 - 1
packages/ckeditor5-utils/src/dom/createelement.js

@@ -26,7 +26,8 @@ import { isString } from 'lodash-es';
  * @returns {Element} Created element.
  */
 export default function createElement( doc, name, attributes = {}, children = [] ) {
-	const element = doc.createElement( name );
+	const namespace = attributes && attributes.xmlns;
+	const element = namespace ? doc.createElementNS( namespace, name ) : doc.createElement( name );
 
 	for ( const key in attributes ) {
 		element.setAttribute( key, attributes[ key ] );

+ 5 - 5
packages/ckeditor5-utils/src/observablemixin.js

@@ -747,13 +747,13 @@ function attachBindToListeners( observable, toBindings ) {
  */
 
 /**
- * Binds {@link #set obvervable properties} to other objects implementing the
+ * Binds {@link #set observable properties} to other objects implementing the
  * {@link module:utils/observablemixin~Observable} interface.
  *
  * Read more in the {@glink framework/guides/deep-dive/observables#property-bindings dedicated guide}
  * covering the topic of property bindings with some additional examples.
  *
- * Let's consider two objects: a `button` and an associated `command` (both `Observable`).
+ * Consider two objects: a `button` and an associated `command` (both `Observable`).
  *
  * A simple property binding could be as follows:
  *
@@ -768,7 +768,7 @@ function attachBindToListeners( observable, toBindings ) {
  * * `button.isEnabled` **instantly equals** `command.isEnabled`,
  * * whenever `command.isEnabled` changes, `button.isEnabled` will immediately reflect its value.
  *
- * **Note**: To release the binding use {@link module:utils/observablemixin~Observable#unbind}.
+ * **Note**: To release the binding, use {@link module:utils/observablemixin~Observable#unbind}.
  *
  * You can also "rename" the property in the binding by specifying the new name in the `to()` chain:
  *
@@ -796,7 +796,7 @@ function attachBindToListeners( observable, toBindings ) {
  *			( isAEnabled, isBEnabled, isCEnabled ) => isAEnabled && isBEnabled && isCEnabled );
  *
  * @method #bind
- * @param {...String} bindProperties Observable properties that will be bound to another observable(s).
+ * @param {...String} bindProperties Observable properties that will be bound to other observable(s).
  * @returns {Object} The bind chain with the `to()` and `toMany()` methods.
  */
 
@@ -811,7 +811,7 @@ function attachBindToListeners( observable, toBindings ) {
  *
  * @method #unbind
  * @param {...String} [unbindProperties] Observable properties to be unbound. All the bindings will
- * be released if no properties provided.
+ * be released if no properties are provided.
  */
 
 /**

+ 9 - 0
packages/ckeditor5-utils/tests/dom/createelement.js

@@ -23,6 +23,15 @@ describe( 'createElement', () => {
 		expect( p.getAttribute( 'class' ) ).to.equal( 'foo' );
 	} );
 
+	it( 'should create element with namespace', () => {
+		const namespace = 'http://www.w3.org/2000/svg';
+		const svg = createElement( document, 'svg', { xmlns: namespace } );
+
+		expect( svg.tagName.toLowerCase() ).to.equal( 'svg' );
+		expect( svg.getAttribute( 'xmlns' ) ).to.equal( namespace );
+		expect( svg.createSVGRect ).to.be.a( 'function' );
+	} );
+
 	it( 'should create element with child text node', () => {
 		const p = createElement( document, 'p', null, 'foo' );