Ticket #4527: 4527_2.patch

File 4527_2.patch, 4.7 KB (added by Garry Yao, 14 years ago)
  • _source/plugins/forms/dialogs/checkbox.js

     
    7979                                                accessKey : 'V',
    8080                                                setup : function( element )
    8181                                                {
    82                                                         this.setValue( element.getAttribute( 'value' ) || '' );
     82                                                        var value = element.getAttribute( 'value' );
     83                                                        // IE Return 'on' as default attr value.
     84                                                        this.setValue(  CKEDITOR.env.ie && value == 'on' ? '' : value  );
    8385                                                },
    8486                                                commit : function( data )
    8587                                                {
    86                                                         var element = data.element;
     88                                                        var element = data.element,
     89                                                                value = this.getValue();
    8790
    88                                                         if ( this.getValue() )
    89                                                                 element.setAttribute( 'value', this.getValue() );
     91                                                        if ( value && !( CKEDITOR.env.ie && value == 'on' ) )
     92                                                                element.setAttribute( 'value', value );
    9093                                                        else
    9194                                                                element.removeAttribute( 'value' );
    9295                                                }
     
    115118                                                                {
    116119                                                                        var replace = CKEDITOR.dom.element.createFromHtml( '<input type="checkbox"'
    117120                                                                                   + ( isChecked ? ' checked="checked"' : '' )
    118                                                                                    + '></input>', editor.document );
     121                                                                                   + '/>', editor.document );
     122
    119123                                                                        element.copyAttributes( replace, { type : 1, checked : 1 } );
    120124                                                                        replace.replace( element );
    121125                                                                        editor.getSelection().selectElement( replace );
     
    124128                                                        }
    125129                                                        else
    126130                                                        {
    127                                                                 if ( this.getValue() )
    128                                                                         element.setAttribute( 'checked', this.getValue() );
     131                                                                var value = this.getValue();
     132                                                                if ( value )
     133                                                                        element.setAttribute( 'checked', 'checked' );
    129134                                                                else
    130135                                                                        element.removeAttribute( 'checked' );
    131136                                                        }
  • _source/core/dom/element.js

     
    425425                                                        break;
    426426
    427427                                                case 'checked':
    428                                                         return this.$.checked;
    429                                                         break;
    430 
     428                                                {
     429                                                        var attr = this.$.attributes.getNamedItem( name ),
     430                                                                attrValue = attr.specified ? attr.nodeValue     // For value given by parser.
     431                                                                                                                         : this.$.checked;  // For value created via DOM interface.
     432                                                       
     433                                                        return attrValue ? 'checked' : null;
     434                                                }
     435
    431436                                                case 'style':
    432437                                                        // IE does not return inline styles via getAttribute(). See #2947.
    433438                                                        return this.$.style.cssText;
     
    13231328                        {
    13241329                                var attribute = attributes[n];
    13251330
    1326                                 // IE BUG: value attribute is never specified even if it exists.
    1327                                 if ( attribute.specified ||
    1328                                   ( CKEDITOR.env.ie && attribute.nodeValue && attribute.nodeName.toLowerCase() == 'value' ) )
    1329                                 {
    1330                                         var attrName = attribute.nodeName;
    1331                                         // We can set the type only once, so do it with the proper value, not copying it.
    1332                                         if ( attrName in skipAttributes )
    1333                                                 continue;
     1331                                // Lowercase attribute name hard rule is broken for
     1332                                // some attribute on IE, e.g. CHECKED.
     1333                                var attrName = attribute.nodeName.toLowerCase(),
     1334                                        attrValue;
     1335
     1336                                // We can set the type only once, so do it with the proper value, not copying it.
     1337                                if ( attrName in skipAttributes )
     1338                                        continue;
    13341339
    1335                                         var attrValue = this.getAttribute( attrName );
     1340                                if( attrName == 'checked' && ( attrValue = this.getAttribute( attrName ) ) )
     1341                                        dest.setAttribute( attrName, attrValue );
     1342                                // IE BUG: value attribute is never specified even if it exists.
     1343                                else if ( attribute.specified ||
     1344                                  ( CKEDITOR.env.ie && attribute.nodeValue && attrName == 'value' ) )
     1345                                {
     1346                                        attrValue = this.getAttribute( attrName );
    13361347                                        if ( attrValue === null )
    13371348                                                attrValue = attribute.nodeValue;
    13381349
  • _source/plugins/forms/plugin.js

     
    162162                                });
    163163                }
    164164        },
     165
     166        afterInit : function( editor )
     167        {
     168                // Cleanup certain IE form elements default values.
     169                if( CKEDITOR.env.ie )
     170                {
     171                        var dataProcessor = editor.dataProcessor,
     172                                htmlFilter = dataProcessor && dataProcessor.htmlFilter;
     173
     174                        htmlFilter && htmlFilter.addRules(
     175                        {
     176                                elements :
     177                                {
     178                                        input : function( input )
     179                                        {
     180                                                var attrs = input.attributes,
     181                                                        type = attrs.type;
     182                                                if( type == 'checkbox' || type == 'radio' )
     183                                                        attrs.value == 'on' && delete attrs.value;
     184                                        }
     185                                }
     186                        } );
     187                }
     188        },
    165189        requires : [ 'image' ]
    166190} );
    167191
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy