Fix quoting inside of spoiler/code tag when common ancestor is not text node.

This commit is contained in:
ccd0 2014-12-06 01:28:57 -08:00
parent 7b348a00c6
commit ac4083b9f4

View File

@ -220,12 +220,11 @@ QR =
range = sel.getRangeAt 0 range = sel.getRangeAt 0
frag = range.cloneContents() frag = range.cloneContents()
ancestor = range.commonAncestorContainer ancestor = range.commonAncestorContainer
if ancestor.nodeName is '#text'
# Quoting the insides of a spoiler/code tag. # Quoting the insides of a spoiler/code tag.
if $.x 'ancestor::s', ancestor if $.x 'ancestor-or-self::s', ancestor
$.prepend frag, $.tn '[spoiler]' $.prepend frag, $.tn '[spoiler]'
$.add frag, $.tn '[/spoiler]' $.add frag, $.tn '[/spoiler]'
if $.x 'ancestor::pre[contains(@class,"prettyprint")]', ancestor if $.x 'ancestor-or-self::pre[contains(@class,"prettyprint")]', ancestor
$.prepend frag, $.tn '[code]' $.prepend frag, $.tn '[code]'
$.add frag, $.tn '[/code]' $.add frag, $.tn '[/code]'
for node in $$ 'br', frag for node in $$ 'br', frag