Ticket #5931: 5931_2.patch
File 5931_2.patch, 2.0 KB (added by , 13 years ago) |
---|
-
_source/plugins/styles/plugin.js
481 481 // Get the element that holds the entire range. 482 482 var parent = styleRange.getCommonAncestor(); 483 483 484 var removeList = { 485 styles : {}, 486 attrs : {} 487 }; 488 489 var attName, styleName; 490 484 491 // Loop through the parents, removing the redundant attributes 485 492 // from the element to be applied. 486 493 while ( styleNode && parent ) 487 494 { 488 495 if ( parent.getName() == elementName ) 489 496 { 490 for ( varattName in def.attributes )497 for ( attName in def.attributes ) 491 498 { 492 499 if ( styleNode.getAttribute( attName ) == parent.getAttribute( attName ) ) 493 styleNode.removeAttribute( attName ); 500 removeList.attrs[ attName ] = 1; 501 else 502 delete removeList.attrs[ attName ]; 494 503 } 495 504 496 for ( varstyleName in def.styles )505 for ( styleName in def.styles ) 497 506 { 498 507 if ( styleNode.getStyle( styleName ) == parent.getStyle( styleName ) ) 499 styleNode.removeStyle( styleName ); 508 removeList.attrs[ attName ] = 1; 509 else 510 delete removeList.attrs[ attName ]; 500 511 } 512 } 501 513 502 if ( !styleNode.hasAttributes() ) 503 { 504 styleNode = null; 505 break; 506 } 507 } 514 parent = parent.getParent(); 515 } 516 517 for ( attName in removeList.attrs ) 518 { 519 // Skip prototype extensions. 520 if ( !removeList.attrs.hasOwnProperty( attName ) ) 521 continue; 522 styleNode.removeAttribute( attName ); 523 } 508 524 509 parent = parent.getParent(); 525 for ( styleName in removeList.styles ) 526 { 527 // Skip prototype extensions. 528 if ( !removeList.styles.hasOwnProperty( styleName ) ) 529 continue; 530 styleNode.removeStyle( styleName ); 510 531 } 511 532 533 if ( !styleNode.hasAttributes() ) 534 styleNode = null; 535 512 536 if ( styleNode ) 513 537 { 514 538 // Move the contents of the range to the style element.