-
-
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($compiler): supports compiling v-bind to the weex native directi…
…ve in recycle-list
- Loading branch information
1 parent
c104cc5
commit 8b893c1
Showing
5 changed files
with
48 additions
and
6 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
31 changes: 31 additions & 0 deletions
31
src/platforms/weex/compiler/modules/recycle-list/v-bind.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,31 @@ | ||
/* @flow */ | ||
|
||
import { getAndRemoveAttr, addAttr } from 'compiler/helpers' | ||
|
||
function isBindingAttr (name) { | ||
return /^(v\-bind)?\:/.test(name) | ||
} | ||
|
||
function parseRealName (name: string): string { | ||
return name.replace(/^(v\-bind)?\:/, '') | ||
} | ||
|
||
export function transformVBind (el: ASTElement) { | ||
if (!el.attrsList.length) { | ||
return | ||
} | ||
el.attrsList.forEach(attr => { | ||
// console.log('is binding attr:', attr.name, isBindingAttr(attr.name)) | ||
if (isBindingAttr(attr.name)) { | ||
const realName: string = parseRealName(attr.name) | ||
const binding = getAndRemoveAttr(el, attr.name) | ||
if (el.attrs) { | ||
el.attrs = el.attrs.filter(at => at.name !== realName) // omit duplicated | ||
} | ||
getAndRemoveAttr(el, realName) | ||
addAttr(el, realName, { '@binding': binding }) | ||
} | ||
}) | ||
el.hasBindings = false | ||
// el.plain = true | ||
} |