Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
forked fromvuejs/vue

Commit207c18c

Browse files
committed
further reduce normalizeChildren usage
1 parent7c3c86f commit207c18c

File tree

9 files changed

+22
-22
lines changed

9 files changed

+22
-22
lines changed

‎flow/component.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ declare interface Component {
7575
propsData: ?Object,
7676
listeners: ?{[key:string]:Function|Array<Function>},
7777
parentVnode:VNode,
78-
renderChildren: ?VNodeChildren
78+
renderChildren: ?Array<VNode>
7979
)=>void;
8080
// rendering
8181
_render:()=>VNode;

‎flow/options.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ declare type InternalComponentOptions = {
44
propsData: ?Object;
55
_parentVnode:VNode;
66
_parentListeners: ?Object;
7-
_renderChildren: ?VNodeChildren;
7+
_renderChildren: ?Array<VNode>;
88
_componentTag: ?string;
99
_parentElm: ?Node;
1010
_refElm: ?Node;
@@ -59,7 +59,7 @@ declare type ComponentOptions = {
5959
_propKeys?:Array<string>;
6060
_parentVnode?:VNode;
6161
_parentListeners?: ?Object;
62-
_renderChildren?: ?VNodeChildren;
62+
_renderChildren?: ?Array<VNode>;
6363
_componentTag: ?string;
6464
_scopeId: ?string;
6565
_base:Class<Component>;

‎flow/vnode.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ declare type VNodeComponentOptions = {
44
Ctor:Class<Component>;
55
propsData: ?Object;
66
listeners: ?Object;
7-
children: ?VNodeChildren;
7+
children: ?Array<VNode>;
88
tag?:string;
99
}
1010

@@ -19,7 +19,7 @@ declare type MountedComponentVNode = {
1919
declaretypeVNodeWithData={
2020
tag:string;
2121
data:VNodeData;
22-
children:Array<VNode>|void;
22+
children:?Array<VNode>;
2323
text:void;
2424
elm:any;
2525
ns:string|void;

‎src/core/instance/lifecycle.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export function lifecycleMixin (Vue: Class<Component>) {
117117
propsData: ?Object,
118118
listeners: ?Object,
119119
parentVnode:VNode,
120-
renderChildren: ?VNodeChildren
120+
renderChildren: ?Array<VNode>
121121
){
122122
constvm:Component=this
123123
consthasChildren=!!(vm.$options._renderChildren||renderChildren)

‎src/core/instance/render.js

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

33
importconfigfrom'../config'
4-
import{normalizeChildren}from'../vdom/helpers/index'
54
importVNode,{
65
cloneVNode,
76
cloneVNodes,
@@ -34,7 +33,7 @@ export function initRender (vm: Component) {
3433
// bind the createElement fn to this instance
3534
// so that we get proper render context inside it.
3635
// args order: tag, data, children, needNormalization
37-
// the needNormalization flag isflipped and defaults to true for the public version.
36+
// the needNormalization flag isdisabled for the public version.
3837
vm._h=(a,b,c,d)=>createElement(vm,a,b,c,d,false)
3938
vm.$createElement=(a,b,c,d)=>createElement(vm,a,b,c,d,true)
4039
if(vm.$options.el){
@@ -270,14 +269,13 @@ export function renderMixin (Vue: Class<Component>) {
270269
}
271270

272271
exportfunctionresolveSlots(
273-
renderChildren: ?VNodeChildren,
272+
children: ?Array<VNode>,
274273
context: ?Component
275274
):{[key:string]:Array<VNode>}{
276275
const slots={}
277-
if(!renderChildren){
276+
if(!children){
278277
returnslots
279278
}
280-
constchildren=normalizeChildren(renderChildren)||[]
281279
constdefaultSlot=[]
282280
letname, child
283281
for(leti=0, l=children.length;i<l;i++){

‎src/core/vdom/create-component.js

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

33
importVNodefrom'./vnode'
4-
import{normalizeChildren}from'./helpers/index'
54
import{resolveConstructorOptions}from'../instance/init'
65
import{activeInstance,callHook}from'../instance/lifecycle'
76
import{resolveSlots}from'../instance/render'
@@ -15,7 +14,7 @@ export function createComponent (
1514
Ctor:Class<Component>|Function|Object|void,
1615
data?:VNodeData,
1716
context:Component,
18-
children?:VNodeChildren,
17+
children: ?Array<VNode>,
1918
tag?:string
2019
):VNode|void{
2120
if(!Ctor){
@@ -96,7 +95,7 @@ function createFunctionalComponent (
9695
propsData: ?Object,
9796
data:VNodeData,
9897
context:Component,
99-
children?:VNodeChildren
98+
children: ?Array<VNode>
10099
):VNode|void{
101100
constprops={}
102101
constpropOptions=Ctor.options.props
@@ -113,7 +112,7 @@ function createFunctionalComponent (
113112
props,
114113
data,
115114
parent:context,
116-
children:normalizeChildren(children),
115+
children,
117116
slots:()=>resolveSlots(children,context)
118117
})
119118
if(vnodeinstanceofVNode){

‎src/core/vdom/create-element.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ export function createElement (
1414
data:any,
1515
children:any,
1616
needNormalization:any,
17-
flipNormalization:boolean
17+
alwaysNormalize:boolean
1818
):VNode{
1919
if(Array.isArray(data)||isPrimitive(data)){
2020
needNormalization=children
2121
children=data
2222
data=undefined
2323
}
24-
if(flipNormalization)needNormalization=!needNormalization
24+
if(alwaysNormalize)needNormalization=true
2525
return_createElement(context,tag,data,children,needNormalization)
2626
}
2727

@@ -51,14 +51,17 @@ export function _createElement (
5151
data.scopedSlots={default:children[0]}
5252
children.length=0
5353
}
54+
if(needNormalization){
55+
children=normalizeChildren(children)
56+
}
5457
letvnode,ns
5558
if(typeoftag==='string'){
5659
letCtor
5760
ns=config.getTagNamespace(tag)
5861
if(config.isReservedTag(tag)){
5962
// platform built-in elements
6063
vnode=newVNode(
61-
tag,data,needNormalization ?normalizeChildren(children) :children,
64+
tag,data,children,
6265
undefined,undefined,context
6366
)
6467
}elseif((Ctor=resolveAsset(context.$options,'components',tag))){
@@ -70,7 +73,7 @@ export function _createElement (
7073
// parent normalizes children
7174
ns=tag==='foreignObject' ?'xhtml' :ns
7275
vnode=newVNode(
73-
tag,data,needNormalization ?normalizeChildren(children) :children,
76+
tag,data,children,
7477
undefined,undefined,context
7578
)
7679
}

‎src/core/vdom/helpers/normalize-children.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import{isPrimitive}from'core/util/index'
44
importVNode,{createTextVNode}from'core/vdom/vnode'
55

6-
exportfunctionnormalizeChildren(children:any):Array<VNode>|void{
6+
exportfunctionnormalizeChildren(children:any):?Array<VNode>{
77
returnisPrimitive(children)
88
?[createTextVNode(children)]
99
:Array.isArray(children)

‎src/core/vdom/vnode.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
exportdefaultclassVNode{
44
tag:string|void;
55
data:VNodeData|void;
6-
children:Array<VNode>|void;
6+
children:?Array<VNode>;
77
text:string|void;
88
elm:Node|void;
99
ns:string|void;
@@ -23,7 +23,7 @@ export default class VNode {
2323
constructor(
2424
tag?:string,
2525
data?:VNodeData,
26-
children?:Array<VNode>|void,
26+
children?:?Array<VNode>,
2727
text?:string,
2828
elm?:Node,
2929
context?:Component,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp