Skip to content

Commit 982d5a4

Browse files
VitorLuizCyyx990803
authored andcommittedMar 18, 2019
fix(types): support string type for style in VNode data (#9728)
fix #9727
1 parent 653c74e commit 982d5a4

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed
 

‎flow/vnode.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ declare interface VNodeData {
4242
staticClass?: string;
4343
class?: any;
4444
staticStyle?: { [key: string]: any };
45-
style?: Array<Object> | Object;
45+
style?: string | Array<Object> | Object;
4646
normalizedStyle?: Object;
4747
props?: { [key: string]: any };
4848
attrs?: { [key: string]: string };

‎types/test/vue-test.ts

+25
Original file line numberDiff line numberDiff line change
@@ -213,3 +213,28 @@ class Decorated extends Vue {
213213

214214
const obj = Vue.observable({ a: 1 })
215215
obj.a++
216+
217+
// VNodeData style tests.
218+
const ComponentWithStyleInVNodeData = Vue.extend({
219+
render (h) {
220+
const elementWithStyleAsString = h('div', {
221+
style: 'background-color: red;'
222+
});
223+
224+
const elementWithStyleAsObject = h('div', {
225+
style: { backgroundColor: 'green' }
226+
});
227+
228+
const elementWithStyleAsArrayOfObjects = h('div', {
229+
style: [
230+
{ backgroundColor: 'blue' }
231+
]
232+
});
233+
234+
return h('div', undefined, [
235+
elementWithStyleAsString,
236+
elementWithStyleAsObject,
237+
elementWithStyleAsArrayOfObjects
238+
]);
239+
}
240+
});

‎types/vnode.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export interface VNodeData {
4848
staticClass?: string;
4949
class?: any;
5050
staticStyle?: { [key: string]: any };
51-
style?: object[] | object;
51+
style?: string | object[] | object;
5252
props?: { [key: string]: any };
5353
attrs?: { [key: string]: any };
5454
domProps?: { [key: string]: any };

0 commit comments

Comments
 (0)
Please sign in to comment.