Skip to content
Permalink
Browse files

Merge branch 't/14252'.

  • Loading branch information...
Comandeer committed May 24, 2016
2 parents f8b0a80 + e2f1e50 commit 0528e5aaeb104ffd283aeb4ff5efa2fcdb0616e4
Showing with 76 additions and 5 deletions.
  1. +3 −0 CHANGES.md
  2. +1 −1 core/style.js
  3. +23 −2 core/tools.js
  4. +4 −0 tests/core/style/checkelementmatch.html
  5. +26 −0 tests/core/style/checkelementmatch.js
  6. +19 −2 tests/core/tools.js
@@ -3,6 +3,9 @@ CKEditor 4 Changelog

## CKEditor 4.5.10

Fixed Issues:

* [#14252](http://dev.ckeditor.com/ticket/14252): Fixed: Styles dropdown doesn't always reflect the current style of the text line in Internet Explorer.
* [#13929](http://dev.ckeditor.com/ticket/13929): Fixed: Errors in console on IE11 with compatibility mode in manual test for [#13867](http://dev.ckeditor.com/ticket/13867).
* [#14275](http://dev.ckeditor.com/ticket/14275): Fixed: `onerror` and `onload` not used in browsers it could have been when loading scripts dynamically.
* [#14590](http://dev.ckeditor.com/ticket/14590): Fixed: Additional line break appearing after inline elements when switching modes. Thanks to [dpidcock](https://github.com/dpidcock)!
@@ -1,4 +1,4 @@
/**
/**
* @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or http://ckeditor.com/license
*/
@@ -980,6 +980,23 @@
} );
},

/**
* Normalizes hexadecimal notation so that color string is always 6 characters long and lowercased.
*
* @param {String} styleText The style data (or just a string containing HEX colors) to be converted.
* @returns {String} The style data with HEX colors normalized.
*/
normalizeHex: function( styleText ) {
return styleText.replace( /#(([0-9a-f]{3}){1,2})($|;|\s+)/gi, function( match, hexColor, hexColorPart, separator ) {
var normalizedHexColor = hexColor.toLowerCase();
if ( normalizedHexColor.length == 3 ) {
var parts = normalizedHexColor.split( '' );
normalizedHexColor = [ parts[ 0 ], parts[ 0 ], parts[ 1 ], parts[ 1 ], parts[ 2 ], parts[ 2 ] ].join( '' );
}
return '#' + normalizedHexColor + separator;
} );
},

/**
* Turns inline style text properties into one hash.
*
@@ -996,8 +1013,12 @@
// Injects the style in a temporary span object, so the browser parses it,
// retrieving its final format.
var temp = new CKEDITOR.dom.element( 'span' );
temp.setAttribute( 'style', styleText );
styleText = CKEDITOR.tools.convertRgbToHex( temp.getAttribute( 'style' ) || '' );
styleText = temp.setAttribute( 'style', styleText ).getAttribute( 'style' ) || '';
}

// Normalize colors.
if ( styleText ) {
styleText = CKEDITOR.tools.normalizeHex( CKEDITOR.tools.convertRgbToHex( styleText ) );
}

// IE will leave a single semicolon when failed to parse the style text. (#3891)
@@ -0,0 +1,4 @@
<h2 id="italictitle" style="font-style:italic;" data-cke-editable="true">Italic</h2>
<h3 id="subtitle" style="color:#a1a2a3;font-style:italic;" data-cke-editable="true">Subtitle</h3>
<div id="specialcontainer" style="background:#eee;border:1px solid #ccc;padding:5px 10px;" data-cke-editable="true">Special container</div>
<span id="yellow" style="color: rgb(255, 255, 0);" data-cke-editable="true">Yellow</span>
@@ -0,0 +1,26 @@
/* bender-tags: unit,style */

( function() {

'use strict';

bender.test( {

// #14252
'test styles color attribute normalization': function() {
var styleItalic = new CKEDITOR.style( { element: 'h2', attributes: { 'style': 'font-style:italic;' } } ),
styleSubtitle = new CKEDITOR.style( { element: 'h3', attributes: { 'style': 'color:#a1a2a3;font-style:italic;' } } ),
styleSpecialContainer = new CKEDITOR.style( { element: 'div', attributes: { 'style': 'background:#eee;border:1px solid #ccc;padding:5px 10px;' } } ),
stylesYellow = new CKEDITOR.style( { element: 'span', styles: { color: '#ff0' } } ),
stylesYellowUpper = new CKEDITOR.style( { element: 'span', styles: { color: '#FFFF00' } } ),
stylesYellowUpperShort = new CKEDITOR.style( { element: 'span', styles: { color: '#FF0' } } );

assert.isTrue( styleItalic.checkElementMatch( CKEDITOR.document.getById( 'italictitle' ), true ), 'Italic Title styles match.' );
assert.isTrue( styleSubtitle.checkElementMatch( CKEDITOR.document.getById( 'subtitle' ), true ), 'Subtitle styles match.' );
assert.isTrue( styleSpecialContainer.checkElementMatch( CKEDITOR.document.getById( 'specialcontainer' ), true ), 'Special Container styles match.' );
assert.isTrue( stylesYellow.checkElementMatch( CKEDITOR.document.getById( 'yellow' ), true ), 'Yellow styles match (short).' );
assert.isTrue( stylesYellowUpper.checkElementMatch( CKEDITOR.document.getById( 'yellow' ), true ), 'Yellow styles match (long, upper-case).' );
assert.isTrue( stylesYellowUpperShort.checkElementMatch( CKEDITOR.document.getById( 'yellow' ), true ), 'Yellow styles match (short, upper-case).' );
}
} );
} )();
@@ -225,11 +225,11 @@
// },

test_callFunction: function() {
var func = CKEDITOR.tools.addFunction( function( argA ) {
var argARef = 'http://ckeditor.com/index.html#myanchor',
func = CKEDITOR.tools.addFunction( function( argA ) {
assert.areSame( argA, argARef );
} );

var argARef = 'http://ckeditor.com/index.html#myanchor';
CKEDITOR.tools.callFunction( func, argARef );
},

@@ -347,6 +347,23 @@
assert.areSame( 'color:#010203; border-color:#ffff00;', c( 'color:rgb(1,2,3); border-color:rgb(255,255,0);' ), 'multiple' );
},

// #14252
testNormalizeHex: function() {
var c = CKEDITOR.tools.normalizeHex;

assert.areSame( '', c( '' ), 'empty' );

assert.areSame( '#000000', c( '#000000' ), 'Long hex' );
assert.areSame( '#000000', c( '#000' ), 'Short hex' );

assert.areSame( '#ffff00', c( '#ffff00' ), 'Long, lower-case hex' );
assert.areSame( '#ffff00', c( '#FFFF00' ), 'Long, upper-case hex' );
assert.areSame( '#ffff00', c( '#ff0' ), 'Short, lower-case hex' );
assert.areSame( '#ffff00', c( '#FF0' ), 'Short, upper-case hex' );
assert.areSame( '#ffff00', c( '#FfFf00' ), 'Long, mixed-case hex' );
assert.areSame( '#ffff00', c( '#Ff0' ), 'Short, mixed-case hex' );
},

testCssLength: function() {
var cssLength = CKEDITOR.tools.cssLength;

0 comments on commit 0528e5a

Please sign in to comment.
You can’t perform that action at this time.