Skip to content

Commit c0b9b6d

Browse files
committed
use cheaper escape
1 parent 36bdf48 commit c0b9b6d

File tree

6 files changed

+20
-6
lines changed

6 files changed

+20
-6
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* @flow */
22

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

55
import {
66
isDef,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* @flow */
22

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

66
export default function renderClass (node: VNodeWithData): ?string {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* @flow */
22

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

src/platforms/web/server/util.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,18 @@ export const propsToAttrMap = {
3434
htmlFor: 'for',
3535
httpEquiv: 'http-equiv'
3636
}
37+
38+
const ESC = {
39+
'<': '&lt;',
40+
'>': '&gt;',
41+
'"': '&quot;',
42+
'&': '&amp;'
43+
}
44+
45+
export function escape (s: string) {
46+
return s.replace(/[<>"&]/g, escapeChar)
47+
}
48+
49+
function escapeChar (a) {
50+
return ESC[a] || a
51+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* @flow */
22

3-
import { escape } from 'he'
3+
import { escape } from 'web/server/util'
44
import { isObject } from 'shared/util'
55
import { renderAttr } from 'web/server/modules/attrs'
66
import { renderClass } from 'web/util/class'

src/server/render.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/* @flow */
22

3-
const { escape } = require('he')
4-
3+
import { escape } from 'web/server/util'
54
import { SSR_ATTR } from 'shared/constants'
65
import { RenderContext } from './render-context'
76
import { ssrCompileToFunctions } from 'web/server/compiler'

0 commit comments

Comments
 (0)