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

changeAttribute converter consumes even if element creators returns null #4320

Closed
scofalik opened this issue Mar 19, 2018 · 3 comments · Fixed by ckeditor/ckeditor5-engine#1372
Assignees
Labels
package:engine type:bug This issue reports a buggy (incorrect) behavior.
Milestone

Comments

@scofalik
Copy link
Contributor

As in title, changeAttribute converter first consumes consumables even if it is not going to do anything because elementCreators returned null. This means that changeAttribute cannot be "aborted" using a proper (if statement) in a callback.

In contrary, wrap does it correctly:

return ( evt, data, conversionApi ) => {
	const oldViewElement = elementCreator( data.attributeOldValue, conversionApi.writer );
	const newViewElement = elementCreator( data.attributeNewValue, conversionApi.writer );

	if ( !oldViewElement && !newViewElement ) {
		return;
	}

	if ( !conversionApi.consumable.consume( data.item, evt.name ) ) {
		return;
	}
	
	// ... convert ...
};
@scofalik scofalik self-assigned this Mar 19, 2018
@scofalik scofalik changed the title changeAttribute converter consumes even if element creators returns null changeAttribute converter consumes even if element creators returns null Mar 19, 2018
@Reinmar
Copy link
Member

Reinmar commented Mar 19, 2018

Any chance it's related to https://github.com/ckeditor/ckeditor5-font/issues/12?

@scofalik
Copy link
Contributor Author

I don't think so. 😢

@Reinmar
Copy link
Member

Reinmar commented Mar 20, 2018

@jodator clarified that the issue with font is caused by https://github.com/ckeditor/ckeditor5-engine/issues/1348, so I'm fine with that :D

jodator referenced this issue in ckeditor/ckeditor5-engine Mar 21, 2018
Fixed: conversion.downcast-converters.changeAttribute should not consume if element creators returned null. Closes #1369.
@mlewand mlewand transferred this issue from ckeditor/ckeditor5-engine Oct 9, 2019
@mlewand mlewand added this to the iteration 15 milestone Oct 9, 2019
@mlewand mlewand added module:conversion type:bug This issue reports a buggy (incorrect) behavior. package:engine labels Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:engine type:bug This issue reports a buggy (incorrect) behavior.
Projects
None yet
3 participants