JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.2
[ckeditor.git] / _source / core / dom / element.js
index 534d6e1..ead6581 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.\r
 For licensing, see LICENSE.html or http://ckeditor.com/license\r
 */\r
 \r
@@ -243,10 +243,13 @@ CKEDITOR.tools.extend( CKEDITOR.dom.element.prototype,
                                lastChild = lastChild.getPrevious();\r
                        if ( !lastChild || !lastChild.is || !lastChild.is( 'br' ) )\r
                        {\r
-                               this.append(\r
-                                       CKEDITOR.env.opera ?\r
+                               var bogus = CKEDITOR.env.opera ?\r
                                                this.getDocument().createText('') :\r
-                                               this.getDocument().createElement( 'br' ) );\r
+                                               this.getDocument().createElement( 'br' );\r
+\r
+                               CKEDITOR.env.gecko && bogus.setAttribute( 'type', '_moz' );\r
+\r
+                               this.append( bogus );\r
                        }\r
                },\r
 \r
@@ -256,15 +259,15 @@ CKEDITOR.tools.extend( CKEDITOR.dom.element.prototype,
                 * @param {CKEDITOR.dom.element} parent The anscestor element to get broken.\r
                 * @example\r
                 * // Before breaking:\r
-                * //     <b>This <i>is some<span /> sample</i> test text</b>\r
-                * // If "element" is <span /> and "parent" is <i>:\r
-                * //     <b>This <i>is some</i><span /><i> sample</i> test text</b>\r
+                * //     &lt;b&gt;This &lt;i&gt;is some&lt;span /&gt; sample&lt;/i&gt; test text&lt;/b&gt;\r
+                * // If "element" is &lt;span /&gt; and "parent" is &lt;i&gt;:\r
+                * //     &lt;b&gt;This &lt;i&gt;is some&lt;/i&gt;&lt;span /&gt;&lt;i&gt; sample&lt;/i&gt; test text&lt;/b&gt;\r
                 * element.breakParent( parent );\r
                 * @example\r
                 * // Before breaking:\r
-                * //     <b>This <i>is some<span /> sample</i> test text</b>\r
-                * // If "element" is <span /> and "parent" is <b>:\r
-                * //     <b>This <i>is some</i></b><span /><b><i> sample</i> test text</b>\r
+                * //     &lt;b&gt;This &lt;i&gt;is some&lt;span /&gt; sample&lt;/i&gt; test text&lt;/b&gt;\r
+                * // If "element" is &lt;span /&gt; and "parent" is &lt;b&gt;:\r
+                * //     &lt;b&gt;This &lt;i&gt;is some&lt;/i&gt;&lt;/b&gt;&lt;span /&gt;&lt;b&gt;&lt;i&gt; sample&lt;/i&gt; test text&lt;/b&gt;\r
                 * element.breakParent( parent );\r
                 */\r
                breakParent : function( parent )\r
@@ -328,7 +331,9 @@ CKEDITOR.tools.extend( CKEDITOR.dom.element.prototype,
                 */\r
                getHtml : function()\r
                {\r
-                       return this.$.innerHTML;\r
+                       var retval = this.$.innerHTML;\r
+                       // Strip <?xml:namespace> tags in IE. (#3341).\r
+                       return CKEDITOR.env.ie ? retval.replace( /<\?[^>]*>/g, '' ) : retval;\r
                },\r
 \r
                getOuterHtml : function()\r
@@ -616,7 +621,6 @@ CKEDITOR.tools.extend( CKEDITOR.dom.element.prototype,
                        }\r
 \r
                        return (\r
-                       /** @ignore */\r
                        this.getName = function()\r
                                {\r
                                        return nodeName;\r
@@ -987,8 +991,16 @@ CKEDITOR.tools.extend( CKEDITOR.dom.element.prototype,
 \r
                removeAttributes : function ( attributes )\r
                {\r
-                       for ( var i = 0 ; i < attributes.length ; i++ )\r
-                               this.removeAttribute( attributes[ i ] );\r
+                       if ( CKEDITOR.tools.isArray( attributes ) )\r
+                       {\r
+                               for ( var i = 0 ; i < attributes.length ; i++ )\r
+                                       this.removeAttribute( attributes[ i ] );\r
+                       }\r
+                       else\r
+                       {\r
+                               for ( var attr in attributes )\r
+                                       attributes.hasOwnProperty( attr ) && this.removeAttribute( attr );\r
+                       }\r
                },\r
 \r
                /**\r
@@ -1344,7 +1356,7 @@ CKEDITOR.tools.extend( CKEDITOR.dom.element.prototype,
                                if ( attrName in skipAttributes )\r
                                        continue;\r
 \r
-                               if( attrName == 'checked' && ( attrValue = this.getAttribute( attrName ) ) )\r
+                               if ( attrName == 'checked' && ( attrValue = this.getAttribute( attrName ) ) )\r
                                        dest.setAttribute( attrName, attrValue );\r
                                // IE BUG: value attribute is never specified even if it exists.\r
                                else if ( attribute.specified ||\r