| 1 | Index: editor/_source/internals/fckdomtools.js |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- editor/_source/internals/fckdomtools.js (revision 2662) |
|---|
| 4 | +++ editor/_source/internals/fckdomtools.js (working copy) |
|---|
| 5 | @@ -376,17 +376,23 @@ |
|---|
| 6 | |
|---|
| 7 | GetIndexOf : function( node ) |
|---|
| 8 | { |
|---|
| 9 | - var currentNode = node.parentNode ? node.parentNode.firstChild : null ; |
|---|
| 10 | - var currentIndex = -1 ; |
|---|
| 11 | + if (!node.parentNode) |
|---|
| 12 | + return -1; |
|---|
| 13 | |
|---|
| 14 | - while ( currentNode ) |
|---|
| 15 | - { |
|---|
| 16 | - currentIndex++ ; |
|---|
| 17 | - |
|---|
| 18 | - if ( currentNode == node ) |
|---|
| 19 | - return currentIndex ; |
|---|
| 20 | - |
|---|
| 21 | - currentNode = currentNode.nextSibling ; |
|---|
| 22 | + if (node.parentNode.firstChild) { |
|---|
| 23 | + var currentIndex = 0; |
|---|
| 24 | + var currentNode = node.parentNode.firstChild; |
|---|
| 25 | + while (currentNode) { |
|---|
| 26 | + if (currentNode == node) |
|---|
| 27 | + return currentIndex; |
|---|
| 28 | + currentNode = currentNode.nextSibling; |
|---|
| 29 | + currentIndex++; |
|---|
| 30 | + } |
|---|
| 31 | + } else { |
|---|
| 32 | + if (node.parentNode.childNodes) |
|---|
| 33 | + for (var i = 0; i < node.parentNode.childNodes.length; i++) |
|---|
| 34 | + if (node.parentNode.childNodes[i] == node) |
|---|
| 35 | + return i; |
|---|
| 36 | } |
|---|
| 37 | |
|---|
| 38 | return -1 ; |
|---|