Skip to content

Commit

Permalink
Merge pull request #406 from Asana/fix_link_double_format
Browse files Browse the repository at this point in the history
Fix nested anchor tags after applying multiple link formats.
  • Loading branch information
jhchen committed Jul 2, 2015
2 parents 54cae74 + d98f442 commit ea8e31c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/format.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class Format
dom(node.parentNode.previousSibling).merge(node.parentNode)
if node.parentNode.tagName == node.parentNode.nextSibling?.tagName
dom(node.parentNode).merge(node.parentNode.nextSibling)
if _.isString(@config.tag)
if _.isString(@config.tag) and node.tagName != @config.tag
formatNode = document.createElement(@config.tag)
if dom.VOID_TAGS[formatNode.tagName]?
dom(node).replace(formatNode) if node.parentNode?
Expand Down
7 changes: 7 additions & 0 deletions test/unit/core/format.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,13 @@ describe('Format', ->
expect(@container).toEqualHTML('<span style="color: red;">Text</span>')
)

it('change value with given tag', ->
@container.innerHTML = '<a href="link1">a</a>'
format = new Quill.Format(Quill.Format.FORMATS.link)
format.add(@container.firstChild, 'link2')
expect(@container).toEqualHTML('<a href="link2">a</a>')
)

it('default value', ->
@container.innerHTML = '<span>Text</span>'
format = new Quill.Format(Quill.Format.FORMATS.size)
Expand Down

0 comments on commit ea8e31c

Please sign in to comment.