Skip to content

Commit

Permalink
Set the renderTree renderNode element for a list item
Browse files Browse the repository at this point in the history
fixes #130
  • Loading branch information
bantic committed Sep 15, 2015
1 parent 411ea90 commit 7c192ed
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/js/editor/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -561,10 +561,10 @@ class PostEditor {
*
* const range = editor.cursor.offsets;
* const markup = markerRange.headMarker.markups[0];
* editor.run((postEditor) => {
* editor.run(postEditor => {
* postEditor.removeMarkupFromRange(range, markup);
* });
* // Will result some markers possibly being split, and the markup
* // Will result in some markers possibly being split, and the markup
* // being removed from all markers between the split.
*
* The return value will be all markers between the split, the same return
Expand Down
1 change: 1 addition & 0 deletions src/js/renderers/editor-dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ class Visitor {
renderNode.element = element;

attachRenderNodeElementToDOM(renderNode, element, null);
renderNode.renderTree.elements.set(element, renderNode);

if (item.markers.length) {
const visitAll = true;
Expand Down
26 changes: 26 additions & 0 deletions tests/acceptance/editor-list-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,3 +387,29 @@ test('forward-delete end of li with markup section after', (assert) => {
Helpers.dom.insertText(editor, 'X');
assert.hasElement('#editor li:contains(abcXdef)', 'inserts text at right spot');
});

// see https://github.com/bustlelabs/content-kit-editor/issues/130
test('selecting empty list items does not cause error', (assert) => {
const mobiledoc = Helpers.mobiledoc.build(builder => {
const {post, listSection, listItem, marker} = builder;
return post([
listSection('ul', [
listItem([marker('abc')]),
listItem(),
listItem([marker('def')])
])
]);
});

createEditorWithMobiledoc(mobiledoc);

assert.equal($('#editor li').length, 3, 'precond - 3 lis');
Helpers.dom.moveCursorTo($('#editor li:eq(1)')[0], 0,
$('#editor li:eq(2)')[0], 0);
Helpers.dom.triggerEvent(editorElement, 'keyup');
assert.ok(true, 'no error');

Helpers.dom.insertText(editor, 'X');
assert.hasElement('#editor li:contains(Xdef)', 'insert text');
assert.equal($('#editor li').length, 2, 'inserting text deletes selected li');
});

0 comments on commit 7c192ed

Please sign in to comment.