@@ -48,15 +48,19 @@ const isSpecialTag = makeMap('script,style', true)
4848
4949const reCache = { }
5050
51- const ampRE = / & a m p ; / g
5251const ltRE = / & l t ; / g
5352const gtRE = / & g t ; / g
53+ const nlRE = / & # 1 0 ; / g
54+ const ampRE = / & a m p ; / g
5455const quoteRE = / & q u o t ; / g
5556
56- function decodeAttr ( value , shouldDecodeTags ) {
57+ function decodeAttr ( value , shouldDecodeTags , shouldDecodeNewlines ) {
5758 if ( shouldDecodeTags ) {
5859 value = value . replace ( ltRE , '<' ) . replace ( gtRE , '>' )
5960 }
61+ if ( shouldDecodeNewlines ) {
62+ value = value . replace ( nlRE , '\n' )
63+ }
6064 return value . replace ( ampRE , '&' ) . replace ( quoteRE , '"' )
6165}
6266
@@ -65,7 +69,6 @@ export function parseHTML (html, options) {
6569 const expectHTML = options . expectHTML
6670 const isUnaryTag = options . isUnaryTag || no
6771 const isFromDOM = options . isFromDOM
68- const shouldDecodeTags = options . shouldDecodeTags
6972 let index = 0
7073 let last , lastTag
7174 while ( html ) {
@@ -215,7 +218,11 @@ export function parseHTML (html, options) {
215218 const value = args [ 3 ] || args [ 4 ] || args [ 5 ] || ''
216219 attrs [ i ] = {
217220 name : args [ 1 ] ,
218- value : isFromDOM ? decodeAttr ( value , shouldDecodeTags ) : value
221+ value : isFromDOM ? decodeAttr (
222+ value ,
223+ options . shouldDecodeTags ,
224+ options . shouldDecodeNewlines
225+ ) : value
219226 }
220227 }
221228
0 commit comments