-
-
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): support compiling
v-on
in the weex native directive (#6892
) * refactor(compiler): move postTransforms to after children are processed * feat(weex): recycle-list support WIP * refactor: fix types * feat(weex): split text into separate module * feat($compiler): supports compiling v-bind to the weex native directive in recycle-list * feat(compile): supports compiling v-if to the weex native directive * feat($compiler): supports compiling v-for to the weex native directive * feat($compiler): compile weex native directives in preTransformNode * feat($compiler): supports compiling v-else-if and v-else to the weex native directive * feat($event): support binding parameters on event handler within weex recycle-list * refactor: mark weex-specific block * feat(wip): recycle list template inline expand * build: add weex factory dev script * feat($compiler): support to compile "v-on" into weex native directive * feat($compiler): adjust handler params to fit the weex native renderer + Filter the non-expression params and the `$event`. + Use `$event` as the last argument of handler.
- Loading branch information
1 parent
ac99957
commit 2cb8ea3
Showing
5 changed files
with
53 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* @flow */ | ||
|
||
const inlineStatementRE = /^\s*([A-Za-z_$0-9\.]+)*\s*\(\s*(([A-Za-z_$0-9\'\"]+)?(\s*,\s*([A-Za-z_$0-9\'\"]+))*)\s*\)$/ | ||
|
||
function parseHandlerParams (handler: ASTElementHandler) { | ||
const res = inlineStatementRE.exec(handler.value) | ||
if (res && res[2]) { | ||
handler.params = res[2].split(/\s*,\s*/) | ||
} | ||
} | ||
|
||
export function postTransformVOn (el: ASTElement) { | ||
const events: ASTElementHandlers | void = el.events | ||
if (!events) { | ||
return | ||
} | ||
for (const name in events) { | ||
const handler: ASTElementHandler | Array<ASTElementHandler> = events[name] | ||
if (Array.isArray(handler)) { | ||
handler.map(fn => parseHandlerParams(fn)) | ||
} else { | ||
parseHandlerParams(handler) | ||
} | ||
} | ||
} |