dom getdeepestnode improvements

This commit is contained in:
Murod Khaydarov 2018-05-25 14:08:56 +03:00
commit 01a1b9676f
No known key found for this signature in database
GPG key ID: C480BA53A8D274C5
4 changed files with 28 additions and 7 deletions

View file

@ -534,7 +534,7 @@ var Dom = function () {
*
* @param {Node} node - root Node. From this vertex we start Deep-first search {@link https://en.wikipedia.org/wiki/Depth-first_search}
* @param {Boolean} atLast - find last text node
* @return {Node|null} - it can be text Node or Element Node, so that caret will able to work with it
* @return {Node} - it can be text Node or Element Node, so that caret will able to work with it
*/
}, {
@ -549,7 +549,16 @@ var Dom = function () {
if (nodeChild.tagName === 'BR') {
nodeChild = nodeChild.nextSibling || nodeChild.parentNode.nextSibling;
if (nodeChild.nextSibling) {
nodeChild = nodeChild.nextSibling;
} else if (!nodeChild.nextSibling && nodeChild.parentNode.nextSibling) {
nodeChild = nodeChild.parentNode.nextSibling;
} else {
return nodeChild.parentNode;
}
}
return this.getDeepestNode(nodeChild, atLast);
@ -2285,7 +2294,7 @@ var Block = function () {
key: 'mergeable',
get: function get() {
return !!(this.tool.merge && typeof this.tool.merge === 'function');
return typeof this.tool.merge === 'function';
}
}, {
key: 'isEmpty',

File diff suppressed because one or more lines are too long

View file

@ -111,7 +111,7 @@ export default class Block {
*/
get mergeable() {
return !!(this.tool.merge && typeof this.tool.merge === 'function');
return typeof this.tool.merge === 'function';
}

View file

@ -105,7 +105,7 @@ export default class Dom {
*
* @param {Node} node - root Node. From this vertex we start Deep-first search {@link https://en.wikipedia.org/wiki/Depth-first_search}
* @param {Boolean} atLast - find last text node
* @return {Node|null} - it can be text Node or Element Node, so that caret will able to work with it
* @return {Node} - it can be text Node or Element Node, so that caret will able to work with it
*/
static getDeepestNode(node, atLast = false) {
@ -115,7 +115,19 @@ export default class Dom {
if (nodeChild.tagName === 'BR') {
nodeChild = nodeChild.nextSibling || nodeChild.parentNode.nextSibling;
if (nodeChild.nextSibling) {
nodeChild = nodeChild.nextSibling;
} else if (!nodeChild.nextSibling && nodeChild.parentNode.nextSibling) {
nodeChild = nodeChild.parentNode.nextSibling;
} else {
return nodeChild.parentNode;
}
}