|
@@ -1,5 +1,7 @@
|
|
|
var _ = require('../util')
|
|
var _ = require('../util')
|
|
|
var Watcher = require('../watcher')
|
|
var Watcher = require('../watcher')
|
|
|
|
|
+var expParser = require('../parsers/expression')
|
|
|
|
|
+var literalRE = /^(true|false|\s?('[^']*'|"[^"]")\s?)$/
|
|
|
|
|
|
|
|
module.exports = {
|
|
module.exports = {
|
|
|
|
|
|
|
@@ -20,6 +22,17 @@ module.exports = {
|
|
|
_.warn(
|
|
_.warn(
|
|
|
'v-with must be used on an instance with a parent.'
|
|
'v-with must be used on an instance with a parent.'
|
|
|
)
|
|
)
|
|
|
|
|
+ } else if (literalRE.test(parentKey)) {
|
|
|
|
|
+ // no need to setup watchers for literal bindings
|
|
|
|
|
+ if (!this.arg) {
|
|
|
|
|
+ _.warn(
|
|
|
|
|
+ 'v-with cannot bind literal value as $data: ' +
|
|
|
|
|
+ parentKey
|
|
|
|
|
+ )
|
|
|
|
|
+ } else {
|
|
|
|
|
+ var value = expParser.parse(parentKey).get()
|
|
|
|
|
+ child.$set(childKey, value)
|
|
|
|
|
+ }
|
|
|
} else {
|
|
} else {
|
|
|
|
|
|
|
|
// simple lock to avoid circular updates.
|
|
// simple lock to avoid circular updates.
|