@@ -48,15 +48,19 @@ const isSpecialTag = makeMap('script,style', true)
48
48
49
49
const reCache = { }
50
50
51
- const ampRE = / & a m p ; / g
52
51
const ltRE = / & l t ; / g
53
52
const gtRE = / & g t ; / g
53
+ const nlRE = / & # 1 0 ; / g
54
+ const ampRE = / & a m p ; / g
54
55
const quoteRE = / & q u o t ; / g
55
56
56
- function decodeAttr ( value , shouldDecodeTags ) {
57
+ function decodeAttr ( value , shouldDecodeTags , shouldDecodeNewlines ) {
57
58
if ( shouldDecodeTags ) {
58
59
value = value . replace ( ltRE , '<' ) . replace ( gtRE , '>' )
59
60
}
61
+ if ( shouldDecodeNewlines ) {
62
+ value = value . replace ( nlRE , '\n' )
63
+ }
60
64
return value . replace ( ampRE , '&' ) . replace ( quoteRE , '"' )
61
65
}
62
66
@@ -65,7 +69,6 @@ export function parseHTML (html, options) {
65
69
const expectHTML = options . expectHTML
66
70
const isUnaryTag = options . isUnaryTag || no
67
71
const isFromDOM = options . isFromDOM
68
- const shouldDecodeTags = options . shouldDecodeTags
69
72
let index = 0
70
73
let last , lastTag
71
74
while ( html ) {
@@ -215,7 +218,11 @@ export function parseHTML (html, options) {
215
218
const value = args [ 3 ] || args [ 4 ] || args [ 5 ] || ''
216
219
attrs [ i ] = {
217
220
name : args [ 1 ] ,
218
- value : isFromDOM ? decodeAttr ( value , shouldDecodeTags ) : value
221
+ value : isFromDOM ? decodeAttr (
222
+ value ,
223
+ options . shouldDecodeTags ,
224
+ options . shouldDecodeNewlines
225
+ ) : value
219
226
}
220
227
}
221
228
0 commit comments