X-Git-Url: https://jasonwoof.com/gitweb/?p=ckeditor.git;a=blobdiff_plain;f=_source%2Fcore%2Fdom%2Fnode.js;h=6a4cbdef8cdb627f59a73d1ce038dc3e14aa0c37;hp=293ce2304c3ea388224abfb8831c30c3b4d1bcd6;hb=e73319a12b56100b29ef456fd74114fe5519e01c;hpb=f0610347140239143439a511ee2bd48cb784f470 diff --git a/_source/core/dom/node.js b/_source/core/dom/node.js index 293ce23..6a4cbde 100644 --- a/_source/core/dom/node.js +++ b/_source/core/dom/node.js @@ -654,42 +654,43 @@ CKEDITOR.tools.extend( CKEDITOR.dom.node.prototype, }, /** - * Checks if this node is read-only (should not be changed). Additionally - * it returns the element that defines the read-only state of this node - * (if present). It may be the node itself or any of its parent - * nodes. - * @returns {CKEDITOR.dom.element|Boolean} An element containing - * read-only attributes or "false" if none is found. + * Checks if this node is read-only (should not be changed). + * @returns {Boolean} * @since 3.5 * @example * // For the following HTML: * // <div contenteditable="false">Some <b>text</b></div> * * // If "ele" is the above <div> - * ele.isReadOnly(); // the <div> element - * - * // If "ele" is the above <b> - * ele.isReadOnly(); // the <div> element + * ele.isReadOnly(); // true */ isReadOnly : function() { - var current = this; - while( current ) + var element = this; + if ( this.type != CKEDITOR.NODE_ELEMENT ) + element = this.getParent(); + + if ( element && typeof element.$.isContentEditable != 'undefined' ) + return ! ( element.$.isContentEditable || element.data( 'cke-editable' ) ); + else { - if ( current.type == CKEDITOR.NODE_ELEMENT ) + // Degrade for old browsers which don't support "isContentEditable", e.g. FF3 + var current = element; + while( current ) { if ( current.is( 'body' ) || !!current.data( 'cke-editable' ) ) break; if ( current.getAttribute( 'contentEditable' ) == 'false' ) - return current; + return true; else if ( current.getAttribute( 'contentEditable' ) == 'true' ) break; + + current = current.getParent(); } - current = current.getParent(); - } - return false; + return false; + } } } );