Evan You
7 years ago
11 changed files with 59 additions and 17 deletions
@ -0,0 +1,12 @@ |
|||
/* @flow */ |
|||
|
|||
import { addAttr } from 'compiler/helpers' |
|||
import { RECYCLE_LIST_MARKER } from 'weex/util/index' |
|||
|
|||
// mark components as inside recycle-list so that we know we need to invoke
|
|||
// their special @render function instead of render in create-component.js
|
|||
export function postTransformComponent (el: ASTElement, options: CompilerOptions) { |
|||
if (!options.isReservedTag(el.tag) && el.tag !== 'cell-slot') { |
|||
addAttr(el, RECYCLE_LIST_MARKER, true) |
|||
} |
|||
} |
@ -0,0 +1,17 @@ |
|||
/* @flow */ |
|||
|
|||
import { RECYCLE_LIST_MARKER } from 'weex/util/index' |
|||
import { createComponentInstanceForVnode } from 'core/vdom/create-component' |
|||
|
|||
export function isRecyclableComponent (vnode: VNodeWithData): boolean { |
|||
return vnode.data.attrs && (RECYCLE_LIST_MARKER in vnode.data.attrs) |
|||
} |
|||
|
|||
export function renderRecyclableComponentTemplate (vnode: VNodeWithData): VNode { |
|||
// TODO:
|
|||
// 1. adding @isComponentRoot / @componentProps to the root node
|
|||
// 2. proper error handling
|
|||
delete vnode.data.attrs[RECYCLE_LIST_MARKER] |
|||
const instance = createComponentInstanceForVnode(vnode) |
|||
return instance.$options['@render'].call(instance) |
|||
} |
@ -0,0 +1,6 @@ |
|||
// import {
|
|||
// // id, 'lifecycle', hookname, fn
|
|||
// // https://github.com/Hanks10100/weex-native-directive/tree/master/component
|
|||
// registerComponentHook,
|
|||
// updateComponentData
|
|||
// } from '../util/index'
|
Loading…
Reference in new issue