X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fcore%2Fdom%2Fnode.js;h=ef41e06bafb09cd617ac9aac2c28cfc6f6e50cee;hb=48b1db88210b4160dce439c6e3e32e14af8c106b;hp=02a726c5e08de168937ee694432c92f4758c66f8;hpb=e371ddf8abcb89013e20e6d0dd746adec344d0e5;p=ckeditor.git diff --git a/_source/core/dom/node.js b/_source/core/dom/node.js index 02a726c..ef41e06 100644 --- a/_source/core/dom/node.js +++ b/_source/core/dom/node.js @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -107,24 +107,25 @@ CKEDITOR.tools.extend( CKEDITOR.dom.node.prototype, { var $clone = this.$.cloneNode( includeChildren ); - if ( !cloneId ) + var removeIds = function( node ) { - var removeIds = function( node ) - { - if ( node.nodeType != CKEDITOR.NODE_ELEMENT ) - return; + if ( node.nodeType != CKEDITOR.NODE_ELEMENT ) + return; - node.removeAttribute( 'id', false ) ; - node.removeAttribute( '_cke_expando', false ) ; + if ( !cloneId ) + node.removeAttribute( 'id', false ); + node.removeAttribute( 'data-cke-expando', false ); + if ( includeChildren ) + { var childs = node.childNodes; - for ( var i=0 ; i < childs.length ; i++ ) + for ( var i=0; i < childs.length; i++ ) removeIds( childs[ i ] ); - }; + } + }; - // The "id" attribute should never be cloned to avoid duplication. - removeIds( $clone ); - } + // The "id" attribute should never be cloned to avoid duplication. + removeIds( $clone ); return new CKEDITOR.dom.node( $clone ); }, @@ -243,13 +244,7 @@ CKEDITOR.tools.extend( CKEDITOR.dom.node.prototype, */ getDocument : function() { - var document = new CKEDITOR.dom.document( this.$.ownerDocument || this.$.parentNode.ownerDocument ); - - return ( - this.getDocument = function() - { - return document; - })(); + return new CKEDITOR.dom.document( this.$.ownerDocument || this.$.parentNode.ownerDocument ); }, getIndex : function() @@ -659,6 +654,24 @@ CKEDITOR.tools.extend( CKEDITOR.dom.node.prototype, } }, + /** + * Checks is this node is read-only (should not be changed). It + * additionaly returns the element, if any, which defines the read-only + * state of this node. 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. + * @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 + */ isReadOnly : function() { var current = this; @@ -666,7 +679,7 @@ CKEDITOR.tools.extend( CKEDITOR.dom.node.prototype, { if ( current.type == CKEDITOR.NODE_ELEMENT ) { - if ( current.is( 'body' ) || current.getCustomData( '_cke_notReadOnly' ) ) + if ( current.is( 'body' ) || !!current.data( 'cke-editable' ) ) break; if ( current.getAttribute( 'contentEditable' ) == 'false' )