Skip to content

Commit

Permalink
Merge pull request #215 from leoasis/fix_leaf_delete_text_embed_tag
Browse files Browse the repository at this point in the history
Fix Leaf deleteText with embed tag nodes
  • Loading branch information
jhchen committed Sep 19, 2014
2 parents e58238a + 268390e commit 102a59f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/leaf.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Leaf extends LinkedList.Node
@length = @text.length
if dom.EMBED_TAGS[@node.tagName]?
textNode = @node.ownerDocument.createTextNode(@text)
@node = dom(@node).replace(@textNode)
@node = dom(@node).replace(textNode)
else
dom(@node).text(@text)

Expand Down
12 changes: 12 additions & 0 deletions test/unit/core/leaf.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,18 @@ describe('Leaf', ->
)
)

describe('deleteText() with embed tags', ->
it('removes the embed tag and replaces it with an empty text node', ->
@container.innerHTML = '<img>'
leaf = new Quill.Leaf(@container.firstChild, {})

leaf.deleteText(0, 1)

expect(leaf.text).toEqualHTML('')
expect(dom(leaf.node).text()).toEqualHTML('')
)
)

describe('insertText()', ->
tests =
'element with text node':
Expand Down

0 comments on commit 102a59f

Please sign in to comment.