Skip to content

Commit 91346ef

Browse files
committed
Merge branch 't/13886'
2 parents 806c408 + ce516e2 commit 91346ef

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ CKEditor 4 Changelog
55

66
Fixed Issues:
77

8+
* [#13886](http://dev.ckeditor.com/ticket/13886): Fixed: Invalid handling of [`CKEDITOR.style`](http://docs.ckeditor.com/#!/api/CKEDITOR.style) instance with `styles` property by [`CKEDITOR.filter`](http://docs.ckeditor.com/#!/api/CKEDITOR.filter).
89
* [#14535](http://dev.ckeditor.com/ticket/14535): Fixed: CSS syntax corrections. Thanks to [mdjdenormandie](https://github.com/mdjdenormandie)!
910

1011
## CKEditor 4.5.8

core/filter.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,22 +1248,20 @@
12481248
styles = styleDef.styles,
12491249
attrs = styleDef.attributes || {};
12501250

1251-
if ( styles ) {
1251+
if ( styles && !CKEDITOR.tools.isEmpty( styles ) ) {
12521252
styles = copy( styles );
12531253
attrs.style = CKEDITOR.tools.writeCssText( styles, true );
12541254
} else {
12551255
styles = {};
12561256
}
12571257

1258-
var el = {
1258+
return {
12591259
name: styleDef.element,
12601260
attributes: attrs,
12611261
classes: attrs[ 'class' ] ? attrs[ 'class' ].split( /\s+/ ) : [],
12621262
styles: styles,
12631263
children: []
12641264
};
1265-
1266-
return el;
12671265
}
12681266

12691267
// Mock hash based on string.
@@ -1873,6 +1871,7 @@
18731871
//
18741872
// TRANSFORMATIONS --------------------------------------------------------
18751873
//
1874+
var transformationsTools;
18761875

18771876
// Apply given transformations group to the element.
18781877
function applyTransformationsGroup( filter, element, group ) {
@@ -2021,7 +2020,7 @@
20212020
* @class CKEDITOR.filter.transformationsTools
20222021
* @singleton
20232022
*/
2024-
var transformationsTools = CKEDITOR.filter.transformationsTools = {
2023+
transformationsTools = CKEDITOR.filter.transformationsTools = {
20252024
/**
20262025
* Converts `width` and `height` attributes to styles.
20272026
*

tests/core/filter/check.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@
7575
'test element + styles - style': function() {
7676
var test = createTest( 'a p{color,width,border-*}' );
7777

78+
// #13886
79+
test( true, st( { element: 'a', styles: {} } ) );
7880
test( true, st( { element: 'p', styles: { color: 'red' } } ) );
7981
test( true, st( { element: 'a', styles: { color: 'red', width: '10px' } } ) );
8082
test( true, st( { element: 'p', styles: { 'border-style': 'solid' } } ) );
@@ -364,4 +366,4 @@
364366
test( false, [ 'x', 'y' ] );
365367
}
366368
} );
367-
} )();
369+
} )();

tests/core/filter/filter.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,15 @@
860860
filter( '<bar><foo>bar</foo></bar>', '<bar>bar</bar>' );
861861
// #12683
862862
filter( '<bar><h1>bar</h1></bar>', '<p>bar</p>' );
863+
},
864+
865+
// #13886
866+
'test filter styles validation with none or empty styles': function() {
867+
var filter = new CKEDITOR.filter( 'a {color}' );
868+
869+
assert.isTrue( filter.check( new CKEDITOR.style( { element: 'a' } ) ) );
870+
assert.isTrue( filter.check( new CKEDITOR.style( { element: 'a', styles: {} } ) ) );
871+
assert.isTrue( filter.check( new CKEDITOR.style( { element: 'a', styles: { color: 'red' } } ) ) );
863872
}
864873
} );
865-
} )();
874+
} )();

0 commit comments

Comments
 (0)