Ticket #3450: 3450_4.patch
File 3450_4.patch, 5.1 KB (added by , 15 years ago) |
---|
-
_source/plugins/styles/plugin.js
197 197 { 198 198 if ( attName == '_length' ) 199 199 continue; 200 201 if ( compareAttributeValues(attName, attribs[attName], element.getAttribute( attName ) ) ) 200 if ( attribs[attName] == element.getAttribute( attName ) ) 202 201 { 203 202 if ( !fullMatch ) 204 203 return true; … … 269 268 // Browsers make some changes to the style when applying them. So, here 270 269 // we normalize it to the browser format. 271 270 if ( stylesText.length ) 272 {273 271 stylesText = normalizeCssText( stylesText ); 274 275 if ( stylesText.length ) 276 stylesText = stylesText.replace( semicolonFixRegex, ';' ); 277 } 278 272 279 273 // Return it, saving it to the next request. 280 274 return ( styleDefinition._ST = stylesText ); 281 275 }; … … 889 883 } 890 884 } 891 885 892 var spacesRegex = /\s+/g;893 886 894 887 // Returns an object that can be used for style matching comparison. 895 888 // Attributes names and values are all lowercased, and the styles get … … 912 905 for ( var styleAtt in styleAttribs ) 913 906 { 914 907 length++; 915 attribs[ styleAtt .toLowerCase() ] = styleAttribs[ styleAtt ].toLowerCase();908 attribs[ styleAtt ] = styleAttribs[ styleAtt ]; 916 909 } 917 910 } 918 911 919 912 // Includes the style definitions. 920 913 var styleText = CKEDITOR.style.getStyleText( styleDefinition ); 921 if ( styleText .length > 0)914 if ( styleText ) 922 915 { 923 916 if ( !attribs[ 'style' ] ) 924 917 length++; 925 926 attribs['style'] = styleText.replace( spacesRegex, '' ).toLowerCase(); 918 attribs[ 'style' ] = styleText; 927 919 } 928 920 929 921 // Appends the "length" information to the object. … … 1001 993 { 1002 994 // Injects the style in a temporary span object, so the browser parses it, 1003 995 // retrieving its final format. 1004 var temp Span = document.createElement( 'span' );1005 temp Span.style.cssText = unparsedCssText;1006 return temp Span.style.cssText;996 var temp = new CKEDITOR.dom.element( 'span' ); 997 temp.setAttribute( 'style', unparsedCssText ); 998 return temp.getAttribute( 'style' ); 1007 999 } 1008 1000 1009 // valueA is our internal "for comparison" value.1010 // valueB is the value retrieved from the element.1011 function compareAttributeValues( attName, valueA, valueB )1012 {1013 if ( valueA == valueB || ( !valueA && !valueB ) )1014 return true;1015 else if ( !valueA || !valueB )1016 return false;1017 1018 valueB = valueB.toLowerCase();1019 1020 if ( attName == 'style' )1021 {1022 valueB = valueB.replace( spacesRegex, '' );1023 if ( valueB.charAt( valueB.length - 1 ) != ';' )1024 valueB += ';';1025 }1026 1027 // Return true if they match or if valueA is null and valueB is an empty string1028 return ( valueA == valueB );1029 }1030 1031 1001 function applyStyle( document, remove ) 1032 1002 { 1033 1003 // Get all ranges from the selection. -
_source/core/dom/element.js
430 430 431 431 case 'style': 432 432 // 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;'); 434 437 } 435 438 436 439 return standard.call( this, name ); -
_source/tests/core/dom/element.html
172 172 var element = new CKEDITOR.dom.element( document.getElementById( 'test1' ) ); 173 173 element.setAttribute( 'style', 'position: absolute;' ); 174 174 175 assert.areEqual( 'position: absolute', document.getElementById( 'test1' ).style.cssText.replace( /[\s;]/g, '' ).toLowerCase() );175 assert.areEqual( 'position: absolute;', element.getAttribute( 'style' ) ); 176 176 }, 177 177 178 178 test_setAttribute3 : function() … … 201 201 'rows' : 5 }); 202 202 203 203 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' ); 205 205 assert.areEqual( 'TestName', document.getElementById( 'test1' ).name, 'name is wrong' ); 206 206 assert.areEqual( 5, document.getElementById( 'test1' ).rows, 'rows is wrong' ); 207 207 }, … … 414 414 assert.areEqual( 'hasExpando', element.getAttribute( 'class' ), 'class is wrong' ); 415 415 element.removeAttribute( 'class' ); 416 416 417 assert.areEqual( 'float: right', element.getAttribute( 'style' ).toLowerCase().replace( /[ ;]/g, '' ) );417 assert.areEqual( 'float: right;', element.getAttribute( 'style' ) ); 418 418 419 419 element.removeAttribute( 'style' ); 420 420 element.removeAttribute( 'id' );