8
0
Просмотр исходного кода

Changed: Always try to consume view element's name if a view element is upcast using conversion helpers.

Szymon Cofalik 8 лет назад
Родитель
Сommit
153911e21e

+ 0 - 1
packages/ckeditor5-engine/src/conversion/conversion.js

@@ -141,7 +141,6 @@ export default class Conversion {
 	 *				'div',
 	 *				{
 	 *					// Any element with `display: block` style.
-	 *					name: /./,
 	 *					style: {
 	 *						display: 'block'
 	 *					}

+ 7 - 1
packages/ckeditor5-engine/src/conversion/upcast-converters.js

@@ -307,6 +307,9 @@ function _prepareToElementConverter( config ) {
 			return;
 		}
 
+		// Force consuming element's name.
+		match.match.name = true;
+
 		// Create model element basing on config.
 		const modelElement = _getModelElement( config.model, data.viewItem, conversionApi.writer );
 
@@ -437,7 +440,8 @@ function _normalizeModelAttributeConfig( config, viewAttributeKeyToCopy = null )
 //
 // @param {String} modelAttributeKey The key of the model attribute to set on a model node.
 // @param {Object|Array.<Object>} config Conversion configuration. It is possible to provide multiple configurations in an array.
-// @param {Boolean} consumeName If set to `true` converter will not consume element's name.
+// @param {Boolean} consumeName If set to `true` converter will try to consume name. If set to `false` converter will not try to
+// consume name. This flag overwrites parameter returned by `Matcher#match`.
 function _prepareToAttributeConverter( config, consumeName ) {
 	const matcher = new Matcher( config.view );
 
@@ -460,6 +464,8 @@ function _prepareToAttributeConverter( config, consumeName ) {
 		if ( !consumeName ) {
 			// Do not test or consume `name` consumable.
 			delete match.match.name;
+		} else {
+			match.match.name = true;
 		}
 
 		// Try to consume appropriate values from consumable values list.

+ 0 - 1
packages/ckeditor5-engine/tests/conversion/conversion.js

@@ -157,7 +157,6 @@ describe( 'Conversion', () => {
 						'div',
 						{
 							// Any element with `display: block` style.
-							name: /./,
 							style: {
 								display: 'block'
 							}