Skip to content

Commit ebbbbbc

Browse files
yyx990803张祥闰
authored and
张祥闰
committed
fix(ssr): fix cachedEscape memory issue
close vuejs#6332
1 parent 9d66ecb commit ebbbbbc

File tree

5 files changed

+10
-12
lines changed

5 files changed

+10
-12
lines changed

src/platforms/web/server/modules/attrs.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* @flow */
22

3-
import { cachedEscape } from '../util'
3+
import { escape } from '../util'
44

55
import {
66
isDef,
@@ -50,7 +50,7 @@ export function renderAttr (key: string, value: string): string {
5050
} else if (isEnumeratedAttr(key)) {
5151
return ` ${key}="${isFalsyAttrValue(value) || value === 'false' ? 'false' : 'true'}"`
5252
} else if (!isFalsyAttrValue(value)) {
53-
return ` ${key}="${cachedEscape(String(value))}"`
53+
return ` ${key}="${escape(String(value))}"`
5454
}
5555
return ''
5656
}
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/* @flow */
22

3-
import { cachedEscape } from '../util'
3+
import { escape } from '../util'
44
import { genClassForVnode } from 'web/util/index'
55

66
export default function renderClass (node: VNodeWithData): ?string {
77
const classList = genClassForVnode(node)
88
if (classList !== '') {
9-
return ` class="${cachedEscape(classList)}"`
9+
return ` class="${escape(classList)}"`
1010
}
1111
}

src/platforms/web/server/modules/style.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* @flow */
22

3-
import { cachedEscape } from '../util'
3+
import { escape } from '../util'
44
import { hyphenate } from 'shared/util'
55
import { getStyle } from 'web/util/style'
66

@@ -23,6 +23,6 @@ export function genStyle (style: Object): string {
2323
export default function renderStyle (vnode: VNodeWithData): ?string {
2424
const styleText = genStyle(getStyle(vnode, false))
2525
if (styleText !== '') {
26-
return ` style=${JSON.stringify(cachedEscape(styleText))}`
26+
return ` style=${JSON.stringify(escape(styleText))}`
2727
}
2828
}

src/platforms/web/server/util.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* @flow */
22

3-
import { makeMap, cached } from 'shared/util'
3+
import { makeMap } from 'shared/util'
44

55
const isAttr = makeMap(
66
'accept,accept-charset,accesskey,action,align,alt,async,autocomplete,' +
@@ -46,8 +46,6 @@ export function escape (s: string) {
4646
return s.replace(/[<>"&]/g, escapeChar)
4747
}
4848

49-
export const cachedEscape = cached(escape)
50-
5149
function escapeChar (a) {
5250
return ESC[a] || a
5351
}

src/server/optimizing-compiler/runtime-helpers.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* @flow */
22

3-
import { escape, cachedEscape } from 'web/server/util'
3+
import { escape } from 'web/server/util'
44
import { isObject, extend } from 'shared/util'
55
import { renderAttr } from 'web/server/modules/attrs'
66
import { renderClass } from 'web/util/class'
@@ -123,7 +123,7 @@ function renderSSRClass (
123123
dynamic: any
124124
): string {
125125
const res = renderClass(staticClass, dynamic)
126-
return res === '' ? res : ` class="${cachedEscape(res)}"`
126+
return res === '' ? res : ` class="${escape(res)}"`
127127
}
128128

129129
function renderSSRStyle (
@@ -136,5 +136,5 @@ function renderSSRStyle (
136136
if (dynamic) extend(style, normalizeStyleBinding(dynamic))
137137
if (extra) extend(style, extra)
138138
const res = genStyle(style)
139-
return res === '' ? res : ` style=${JSON.stringify(cachedEscape(res))}`
139+
return res === '' ? res : ` style=${JSON.stringify(escape(res))}`
140140
}

0 commit comments

Comments
 (0)