diff --git a/src/core/format.coffee b/src/core/format.coffee index 76ef8858f2..3243259ec7 100644 --- a/src/core/format.coffee +++ b/src/core/format.coffee @@ -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? diff --git a/test/unit/core/format.coffee b/test/unit/core/format.coffee index 7fd7972470..459e53f7e5 100644 --- a/test/unit/core/format.coffee +++ b/test/unit/core/format.coffee @@ -137,6 +137,13 @@ describe('Format', -> expect(@container).toEqualHTML('Text') ) + it('change value with given tag', -> + @container.innerHTML = 'a' + format = new Quill.Format(Quill.Format.FORMATS.link) + format.add(@container.firstChild, 'link2') + expect(@container).toEqualHTML('a') + ) + it('default value', -> @container.innerHTML = 'Text' format = new Quill.Format(Quill.Format.FORMATS.size)