X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fcore%2Fdom%2Fnode.js;h=2ae3a134c112f8183a49457dbf9c1b9f65d4baee;hb=059b4c2fef02528bf1af189f7996e80652faddfb;hp=6f25ec1f21feceeb130a899cba5ba0f922e6c017;hpb=941b0a9ba4e673e292510d80a5a86806994b8ea6;p=ckeditor.git diff --git a/_source/core/dom/node.js b/_source/core/dom/node.js index 6f25ec1..2ae3a13 100644 --- a/_source/core/dom/node.js +++ b/_source/core/dom/node.js @@ -25,6 +25,10 @@ CKEDITOR.dom.node = function( domNode ) { switch ( domNode.nodeType ) { + // Safari don't consider document as element node type. (#3389) + case CKEDITOR.NODE_DOCUMENT : + return new CKEDITOR.dom.document( domNode ); + case CKEDITOR.NODE_ELEMENT : return new CKEDITOR.dom.element( domNode ); @@ -49,6 +53,13 @@ CKEDITOR.dom.node.prototype = new CKEDITOR.dom.domObject(); CKEDITOR.NODE_ELEMENT = 1; /** + * Document node type. + * @constant + * @example + */ +CKEDITOR.NODE_DOCUMENT = 9; + +/** * Text node type. * @constant * @example @@ -194,27 +205,30 @@ CKEDITOR.tools.extend( CKEDITOR.dom.node.prototype, var parentNode = node.parentNode; var currentIndex = -1; - for ( var i = 0 ; i < parentNode.childNodes.length ; i++ ) + if ( parentNode ) { - var candidate = parentNode.childNodes[i]; - - if ( normalized && - candidate.nodeType == 3 && - candidate.previousSibling && - candidate.previousSibling.nodeType == 3 ) + for ( var i = 0 ; i < parentNode.childNodes.length ; i++ ) { - continue; - } + var candidate = parentNode.childNodes[i]; - currentIndex++; + if ( normalized && + candidate.nodeType == 3 && + candidate.previousSibling && + candidate.previousSibling.nodeType == 3 ) + { + continue; + } - if ( candidate == node ) - break; - } + currentIndex++; + + if ( candidate == node ) + break; + } - address.unshift( currentIndex ); + address.unshift( currentIndex ); + } - node = node.parentNode; + node = parentNode; } return address; @@ -232,7 +246,6 @@ CKEDITOR.tools.extend( CKEDITOR.dom.node.prototype, var document = new CKEDITOR.dom.document( this.$.ownerDocument || this.$.parentNode.ownerDocument ); return ( - /** @ignore */ this.getDocument = function() { return document;