From 035bd9c50c904238c7834b33eb5ea1a2fdc7a1a0 Mon Sep 17 00:00:00 2001 From: Yujian Yao Date: Wed, 1 Jul 2015 11:13:24 -0700 Subject: [PATCH] Fix nested anchor tags after applying multiple link formats. --- src/core/format.coffee | 2 +- test/unit/core/format.coffee | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) 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)