Skip to content

Commit

Permalink
Move detecting type of ignoreStyle into fixHtml.
Browse files Browse the repository at this point in the history
  • Loading branch information
engineering-this authored and f1ames committed Jul 9, 2019
1 parent 866125d commit 6f59545
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions tests/plugins/widget/_helpers/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ var widgetTestsTools = ( function() {
loaded: function( evt ) {
editor = evt.editor;

var ignoreStyle = config.ignoreStyle;
ignoreStyle = typeof ignoreStyle === 'function' ? ignoreStyle( editor ) : ignoreStyle;

initialData = fixHtml( editor.getData(), ignoreStyle );
initialData = fixHtml( editor.getData(), config.ignoreStyle, editor );

editor.dataProcessor.writer.sortAttributes = true;
},
Expand Down Expand Up @@ -73,7 +70,7 @@ var widgetTestsTools = ( function() {
// Wait & ensure async.
wait( function() {
editor.setMode( 'source', function() {
sourceModeData = fixHtml( editor.getData(), config.ignoreStyle );
sourceModeData = fixHtml( editor.getData(), config.ignoreStyle, editor );

editor.setMode( 'wysiwyg', function() {
resume( function() {
Expand Down Expand Up @@ -137,7 +134,7 @@ var widgetTestsTools = ( function() {
var instances = bender.tools.objToArray( editor.widgets.instances );
assert.areSame( config.initialInstancesNumber, instances.length, 'instances number ' + msg );

checkData && assert.areSame( initialData, fixHtml( editor.getData(), config.ignoreStyle ), 'data ' + msg );
checkData && assert.areSame( initialData, fixHtml( editor.getData(), config.ignoreStyle, editor ), 'data ' + msg );

var editable = editor.editable();
for ( var i = 0; i < instances.length; ++i )
Expand All @@ -151,12 +148,15 @@ var widgetTestsTools = ( function() {
return CKEDITOR.tools.object.keys( classesObj ).sort();
}

function fixHtml( html, ignoreStyle ) {
function fixHtml( html, ignoreStyle, editor ) {
// Because IE modify style attribute we should fix it or totally ignore style attribute.
html = html.replace( /style="([^"]*)"/g, function( styleStr ) {
ignoreStyle = typeof ignoreStyle === 'function' ? ignoreStyle( editor ) : ignoreStyle;

// If there are too many problems with styles just ignore them.
if ( ignoreStyle )
if ( ignoreStyle ) {
return '';
}

// If it is only the matter of spacers and semicolons fix attributes.
var style = styleStr.substr( 7, styleStr.length - 8 );
Expand Down

0 comments on commit 6f59545

Please sign in to comment.