Skip to content

Commit

Permalink
Ensure targetNode matches leaf.length in formatText
Browse files Browse the repository at this point in the history
Without this call to split(), the targetNode may outgrow leaf.length, causing
the call to format.add(targetNode, value) to operate on more than was intended.

Fixes slab#310
  • Loading branch information
thomsbg committed Mar 19, 2015
1 parent e8e38b3 commit f855771
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/core/line.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class Line extends LinkedList.Node
dom(targetNode).splitBefore(@node)
while !format.match(targetNode)
targetNode = targetNode.parentNode
dom(targetNode).split(leaf.length)
# Isolate target node
if leafOffset > 0
[leftNode, targetNode] = dom(targetNode).split(leafOffset)
Expand Down
4 changes: 4 additions & 0 deletions test/unit/core/line.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,10 @@ describe('Line', ->
initial: '<b><i>01</i><s>23</s></b><i><s>45</s><b>67</b></i>'
expected: '<b><i>01</i></b><b><s>2</s></b><s>3</s><i><s>45</s></i><i>6<b>7</b></i>'
args: [3, 4, 'bold', false]
'split boundaries with parents remove at beginning':
initial: '<b><i>01</i><s>23</s></b>'
expected: '<i>01</i><s>23</s>'
args: [0, 4, 'bold', false]
'remove image':
initial: '<b>01</b><img src="http://quilljs.com/images/cloud.png"><s>34</s>'
expected: "<b>01</b>#{dom.EMBED_TEXT}<s>34</s>"
Expand Down

0 comments on commit f855771

Please sign in to comment.