Ticket #3450: 3450_3.patch

File 3450_3.patch, 4.6 KB (added by Garry Yao, 11 years ago)
  • _source/core/dom/element.js

    @@ -197,8 +197,7 @@
     					{
     						if ( attName == '_length' )
     							continue;
    -
    -						if ( compareAttributeValues(attName, attribs[attName], element.getAttribute( attName ) ) )
    +						if ( attribs[attName] == element.getAttribute( attName ) )
     						{
     							if ( !fullMatch )
     								return true;
    @@ -269,13 +268,8 @@
     		// Browsers make some changes to the style when applying them. So, here
     		// we normalize it to the browser format.
     		if ( stylesText.length )
    -		{
     			stylesText = normalizeCssText( stylesText );
    -
    +		
    -			if ( stylesText.length )
    -				stylesText = stylesText.replace( semicolonFixRegex, ';' );
    -		}
    -
     		// Return it, saving it to the next request.
     		return ( styleDefinition._ST = stylesText );
     	};
    @@ -918,12 +912,12 @@
     
     		// Includes the style definitions.
     		var styleText = CKEDITOR.style.getStyleText( styleDefinition );
    -		if ( styleText.length > 0 )
    +		if ( styleText )
     		{
     			if ( !attribs[ 'style' ] )
     				length++;
     
    -			attribs['style'] = styleText.replace( spacesRegex, '' ).toLowerCase();
    +			attribs['style'] = styleText.replace( spacesRegex, '' );
     		}
     
     		// Appends the "length" information to the object.
    @@ -1001,33 +995,11 @@
     	{
     		// Injects the style in a temporary span object, so the browser parses it,
     		// retrieving its final format.
    -		var tempSpan = document.createElement( 'span' );
    -		tempSpan.style.cssText = unparsedCssText;
    -		return tempSpan.style.cssText;
    +		var temp = new CKEDITOR.dom.element( 'span' );
    +		temp.setAttribute( 'style', unparsedCssText );
    +		return temp.getAttribute( 'style' );
     	}
     
    -	// valueA is our internal "for comparison" value.
    -	// valueB is the value retrieved from the element.
    -	function compareAttributeValues( attName, valueA, valueB )
    -	{
    -		if ( valueA == valueB || ( !valueA && !valueB ) )
    -			return true;
    -		else if ( !valueA || !valueB )
    -			return false;
    -
    -		valueB = valueB.toLowerCase();
    -
    -		if ( attName == 'style' )
    -		{
    -			valueB = valueB.replace( spacesRegex, '' );
    -			if ( valueB.charAt( valueB.length - 1 ) != ';' )
    -				valueB += ';';
    -		}
    -
    -		// Return true if they match or if valueA is null and valueB is an empty string
    -		return ( valueA == valueB );
    -	}
    -
     	function applyStyle( document, remove )
     	{
     		// Get all ranges from the selection.
     
    430430
    431431                                                case 'style':
    432432                                                        // IE does not return inline styles via getAttribute(). See #2947.
    433                                                         return this.$.style.cssText;
     433                                                        var styleText = this.$.style.cssText;
     434                                                        return styleText.toLowerCase().replace(
     435                                                                /\s*(?:;\s*|$)/, ';').replace(
     436                                                                        /([^;])$/, '$1;');
    434437                                        }
    435438
    436439                                        return standard.call( this, name );
  • _source/tests/core/dom/element.html

     
    172172                        var element = new CKEDITOR.dom.element( document.getElementById( 'test1' ) );
    173173                        element.setAttribute( 'style', 'position: absolute;' );
    174174
    175                         assert.areEqual( 'position:absolute', document.getElementById( 'test1' ).style.cssText.replace( /[\s;]/g, '' ).toLowerCase() );
     175                        assert.areEqual( 'position: absolute;', element.getAttribute( 'style' ) );
    176176                },
    177177
    178178                test_setAttribute3 : function()
     
    201201                                'rows'  : 5 });
    202202
    203203                        assert.areSame( 'Test', document.getElementById( 'test1' ).className, 'class is wrong' );
    204                         assert.areEqual( 'position:absolute', document.getElementById( 'test1' ).style.cssText.replace( /[\s;]/g, '' ).toLowerCase(), 'style is wrong' );
     204                        assert.areEqual( 'position: absolute;', element.getAttribute( 'style'), 'style is wrong' );
    205205                        assert.areEqual( 'TestName', document.getElementById( 'test1' ).name, 'name is wrong' );
    206206                        assert.areEqual( 5, document.getElementById( 'test1' ).rows, 'rows is wrong' );
    207207                },
     
    414414                        assert.areEqual( 'hasExpando', element.getAttribute( 'class' ), 'class is wrong' );
    415415                        element.removeAttribute( 'class' );
    416416
    417                         assert.areEqual( 'float:right', element.getAttribute( 'style' ).toLowerCase().replace( /[ ;]/g, '' ) );
     417                        assert.areEqual( 'float: right;', element.getAttribute( 'style' ) );
    418418
    419419                        element.removeAttribute( 'style' );
    420420                        element.removeAttribute( 'id' );
© 2003 – 2019 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy