-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(weex): WIP invoke recycle-list child component with backing inst…
…ance
- Loading branch information
Showing
11 changed files
with
59 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/platforms/weex/compiler/modules/recycle-list/component.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/platforms/weex/runtime/recycle-list/render-component-template.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// import { | ||
// // id, 'lifecycle', hookname, fn | ||
// // https://github.com/Hanks10100/weex-native-directive/tree/master/component | ||
// registerComponentHook, | ||
// updateComponentData | ||
// } from '../util/index' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters