JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.6.2
[ckeditor.git] / _source / core / dom / node.js
index 293ce23..6a4cbde 100644 (file)
@@ -654,42 +654,43 @@ CKEDITOR.tools.extend( CKEDITOR.dom.node.prototype,
                },\r
 \r
                /**\r
-                * Checks if this node is read-only (should not be changed). Additionally\r
-                * it returns the element that defines the read-only state of this node\r
-                * (if present). It may be the node itself or any of its parent\r
-                * nodes.\r
-                * @returns {CKEDITOR.dom.element|Boolean} An element containing\r
-                *              read-only attributes or "false" if none is found.\r
+                * Checks if this node is read-only (should not be changed).\r
+                * @returns {Boolean}\r
                 * @since 3.5\r
                 * @example\r
                 * // For the following HTML:\r
                 * // <div contenteditable="false">Some <b>text</b></div>\r
                 *\r
                 * // If "ele" is the above <div>\r
-                * ele.isReadOnly();  // the <div> element\r
-                *\r
-                * // If "ele" is the above <b>\r
-                * ele.isReadOnly();  // the <div> element\r
+                * ele.isReadOnly();  // true\r
                 */\r
                isReadOnly : function()\r
                {\r
-                       var current = this;\r
-                       while( current )\r
+                       var element = this;\r
+                       if ( this.type != CKEDITOR.NODE_ELEMENT )\r
+                               element = this.getParent();\r
+\r
+                       if ( element && typeof element.$.isContentEditable != 'undefined' )\r
+                               return ! ( element.$.isContentEditable || element.data( 'cke-editable' ) );\r
+                       else\r
                        {\r
-                               if ( current.type == CKEDITOR.NODE_ELEMENT )\r
+                               // Degrade for old browsers which don't support "isContentEditable", e.g. FF3\r
+                               var current = element;\r
+                               while( current )\r
                                {\r
                                        if ( current.is( 'body' ) || !!current.data( 'cke-editable' ) )\r
                                                break;\r
 \r
                                        if ( current.getAttribute( 'contentEditable' ) == 'false' )\r
-                                               return current;\r
+                                               return true;\r
                                        else if ( current.getAttribute( 'contentEditable' ) == 'true' )\r
                                                break;\r
+\r
+                                       current = current.getParent();\r
                                }\r
-                               current = current.getParent();\r
-                       }\r
 \r
-                       return false;\r
+                               return false;\r
+                       }\r
                }\r
        }\r
 );\r