Browse Source
* 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.dev
Hanks
7 years ago
committed by
Evan You
5 changed files with 53 additions and 5 deletions
@ -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) |
|||
} |
|||
} |
|||
} |
Loading…
Reference in new issue