浏览代码

Utils.mix() should not override existing properties.

Piotrek Koszuliński 10 年之前
父节点
当前提交
b9dfd25d9f
共有 1 个文件被更改,包括 7 次插入1 次删除
  1. 7 1
      packages/ckeditor5-ui/src/utils.js

+ 7 - 1
packages/ckeditor5-ui/src/utils.js

@@ -125,7 +125,9 @@ const utils = {
 	 *
 	 *		utils.mix( Editor, SomeMixin, ... );
 	 *
-	 *		new Editor().a(); -> 'a'
+	 *		new Editor().a(); // -> 'a'
+	 *
+	 * Note: Properties which already exist in the base class will not be overriden.
 	 *
 	 * @param {Function} [baseClass] Class which prototype will be extended.
 	 * @param {Object} [...mixins] Objects from which to get properties.
@@ -134,6 +136,10 @@ const utils = {
 		mixins.forEach( ( mixin ) => {
 			Object.getOwnPropertyNames( mixin ).concat( Object.getOwnPropertySymbols( mixin ) )
 				.forEach( ( key ) => {
+					if ( key in baseClass.prototype ) {
+						return;
+					}
+
 					const sourceDescriptor = Object.getOwnPropertyDescriptor( mixin, key );
 					sourceDescriptor.enumerable = false;