File tree 2 files changed +9
-9
lines changed
2 files changed +9
-9
lines changed Original file line number Diff line number Diff line change 1
- // __UNSAFE__
2
- // Reason: potentially setting innerHTML.
3
- // This can come from explicit usage of v-html or innerHTML as a prop in render
4
-
5
1
import { DeprecationTypes , compatUtils , warn } from '@vue/runtime-core'
6
2
import { includeBooleanAttr } from '@vue/shared'
3
+ import { unsafeToTrustedHTML } from '../nodeOps'
7
4
8
5
// functions. The user is responsible for using them with only trusted content.
9
6
export function patchDOMProp (
@@ -12,11 +9,15 @@ export function patchDOMProp(
12
9
value : any ,
13
10
parentComponent : any ,
14
11
) : void {
12
+ // __UNSAFE__
13
+ // Reason: potentially setting innerHTML.
14
+ // This can come from explicit usage of v-html or innerHTML as a prop in render
15
15
if ( key === 'innerHTML' || key === 'textContent' ) {
16
16
// null value case is handled in renderer patchElement before patching
17
17
// children
18
- if ( value == null ) return
19
- el [ key ] = value
18
+ if ( value != null ) {
19
+ el [ key ] = key === 'innerHTML' ? unsafeToTrustedHTML ( value ) : value
20
+ }
20
21
return
21
22
}
22
23
Original file line number Diff line number Diff line change @@ -31,9 +31,8 @@ if (tt) {
31
31
// This function merely perform a type-level trusted type conversion
32
32
// for use in `innerHTML` assignment, etc.
33
33
// Be careful of whatever value passed to this function.
34
- const unsafeToTrustedHTML : ( value : string ) => TrustedHTML | string = policy
35
- ? val => policy . createHTML ( val )
36
- : val => val
34
+ export const unsafeToTrustedHTML : ( value : string ) => TrustedHTML | string =
35
+ policy ? val => policy . createHTML ( val ) : val => val
37
36
38
37
export const svgNS = 'http://www.w3.org/2000/svg'
39
38
export const mathmlNS = 'http://www.w3.org/1998/Math/MathML'
You can’t perform that action at this time.
0 commit comments