Skip to content
This repository has been archived by the owner on Jun 15, 2021. It is now read-only.

Commit

Permalink
Sanity-check listElement when inserting list
Browse files Browse the repository at this point in the history
  • Loading branch information
danburzo committed Jul 22, 2016
1 parent 28cf9bc commit 2ec807b
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions src/plugins/core/patches/commands/insert-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,25 @@ define([], function () {
return node.nodeName === 'OL' || node.nodeName === 'UL';
});

/**
* Firefox: If we apply the insertOrderedList or the insertUnorderedList
* command on an empty block, a P will be inserted after the OL/UL.
* As per: http://jsbin.com/cubacoli/3/edit?html,js,output
*/

if (listElement.nextElementSibling &&
listElement.nextElementSibling.childNodes.length === 0) {
nodeHelpers.removeNode(listElement.nextElementSibling);
}
if (listElement) {

/**
* Chrome: If we apply the insertOrderedList or the insertUnorderedList
* command on an empty block, the OL/UL will be nested inside the block.
* As per: http://jsbin.com/eFiRedUc/1/edit?html,js,output
*/
/**
* Firefox: If we apply the insertOrderedList or the insertUnorderedList
* command on an empty block, a P will be inserted after the OL/UL.
* As per: http://jsbin.com/cubacoli/3/edit?html,js,output
*/

if (listElement.nextElementSibling &&
listElement.nextElementSibling.childNodes.length === 0) {
nodeHelpers.removeNode(listElement.nextElementSibling);
}

/**
* Chrome: If we apply the insertOrderedList or the insertUnorderedList
* command on an empty block, the OL/UL will be nested inside the block.
* As per: http://jsbin.com/eFiRedUc/1/edit?html,js,output
*/

if (listElement) {
var listParentNode = listElement.parentNode;
// If list is within a text block then split that block
if (listParentNode && /^(H[1-6]|P)$/.test(listParentNode.nodeName)) {
Expand All @@ -63,9 +64,9 @@ define([], function () {
nodeHelpers.removeNode(listParentNode);
}
}
}

nodeHelpers.removeChromeArtifacts(listElement);
nodeHelpers.removeChromeArtifacts(listElement);
}
}
}.bind(this));
};
Expand Down

0 comments on commit 2ec807b

Please sign in to comment.