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

Sanity-check listElement when inserting list #493

Merged
merged 1 commit into from
Jan 30, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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