Ticket #7387: 7387_2.patch

File 7387_2.patch, 3.5 KB (added by Alfonso Martínez de Lizarrondo, 13 years ago)

Revised patch

  • _source/core/dom/node.js

     
    488488
    489489                /**
    490490                 * Gets the closest ancestor node of this node, specified by its node name.
    491                  * @param {String} name The node name of the ancestor node to search.
     491                 * @param {String} reference The node name of the ancestor node to search, or
     492                 * an object with the names to search for (since 3.6)
    492493                 * @param {Boolean} [includeSelf] Whether to include the current
    493494                 * node in the search.
    494495                 * @returns {CKEDITOR.dom.node} The located ancestor node or null if not found.
     
    499500                 * ascendant = node.getAscendant( 'div' );      // ascendant == <div id="inner"&gt
    500501                 * ascendant = node.getAscendant( 'b' );        // ascendant == null
    501502                 * ascendant = node.getAscendant( 'b', true );  // ascendant == <b>
     503                 * ascendant = node.getAscendant( { div: 1, p: 1} );      // Searchs for the first 'div' or 'p': ascendant == <div id="inner"&gt
    502504                 */
    503                 getAscendant : function( name, includeSelf )
     505                getAscendant : function( reference, includeSelf )
    504506                {
    505                         var $ = this.$;
     507                        var $ = this.$,
     508                                name;
    506509
    507510                        if ( !includeSelf )
    508511                                $ = $.parentNode;
    509512
    510513                        while ( $ )
    511514                        {
    512                                 if ( $.nodeName && $.nodeName.toLowerCase() == name )
     515                                if ( $.nodeName && ( name = $.nodeName.toLowerCase(), ( typeof reference == 'string' ? name == reference : name in reference ) ) )
    513516                                        return new CKEDITOR.dom.node( $ );
    514517
    515518                                $ = $.parentNode;
  • _source/plugins/styles/plugin.js

     
    9898                        replaceVariables( styleDefinition.styles, variablesValues );
    9999                }
    100100
    101                 var element = this.element = ( styleDefinition.element || '*' ).toLowerCase();
     101                var element = this.element = styleDefinition.element ?
     102                                ( typeof styleDefinition.element == 'string' ? styleDefinition.element.toLowerCase() : styleDefinition.element )
     103                                : '*';
    102104
    103105                this.type =
    104106                        blockElements[ element ] ?
     
    108110                        :
    109111                                CKEDITOR.STYLE_INLINE;
    110112
     113                // If the 'element' property is an object with a set of possible element, it will be applied like an object style: only to existing elements
     114                if ( typeof this.element == 'object' )
     115                        this.type = CKEDITOR.STYLE_OBJECT;
     116
    111117                this._ =
    112118                {
    113119                        definition : styleDefinition
     
    179185                                                          && ( element == elementPath.block || element == elementPath.blockLimit ) )
    180186                                                        continue;
    181187
    182                                                 if( this.type == CKEDITOR.STYLE_OBJECT
    183                                                          && !( element.getName() in objectElements ) )
     188                                                if( this.type == CKEDITOR.STYLE_OBJECT )
     189                                                {
     190                                                        var name = element.getName();
     191                                                        if ( !( typeof this.element == 'string' ? name == this.element : name in this.element ) )
    184192                                                                continue;
     193                                                }
    185194
    186195                                                if ( this.checkElementRemovable( element, true ) )
    187196                                                        return true;
     
    217226                                return false;
    218227
    219228                        var def = this._.definition,
    220                                 attribs;
     229                                attribs,
     230                                name = element.getName();
    221231
    222232                        // If the element name is the same as the style name.
    223                         if ( element.getName() == this.element )
     233                        if ( typeof this.element == 'string' ? name == this.element : name in this.element )
    224234                        {
    225235                                // If no attributes are defined in the element.
    226236                                if ( !fullMatch && !element.hasAttributes() )
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy