|
|
@@ -153,7 +153,9 @@ if (_.inBrowser) {
|
|
|
'data-some-attr',
|
|
|
'some-other-attr',
|
|
|
'multiple-attrs',
|
|
|
- 'oneway',
|
|
|
+ 'onetime',
|
|
|
+ 'oneway-up',
|
|
|
+ 'oneway-down',
|
|
|
'with-filter',
|
|
|
'camelCase',
|
|
|
'boolean-literal'
|
|
|
@@ -164,49 +166,69 @@ if (_.inBrowser) {
|
|
|
el.setAttribute('data-some-attr', '{{a}}')
|
|
|
el.setAttribute('some-other-attr', '2')
|
|
|
el.setAttribute('multiple-attrs', 'a {{b}} c')
|
|
|
- el.setAttribute('oneway', '{{*a}}')
|
|
|
+ el.setAttribute('onetime', '{{*a}}')
|
|
|
+ el.setAttribute('oneway-up', '{{<a}}')
|
|
|
+ el.setAttribute('oneway-down', '{{>a}}')
|
|
|
el.setAttribute('with-filter', '{{a | filter}}')
|
|
|
el.setAttribute('boolean-literal', '{{true}}')
|
|
|
transclude(el, options)
|
|
|
compiler.compileAndLinkRoot(vm, el, options)
|
|
|
// should skip literals and one-time bindings
|
|
|
- expect(vm._bindDir.calls.count()).toBe(5)
|
|
|
+ expect(vm._bindDir.calls.count()).toBe(7)
|
|
|
// data-some-attr
|
|
|
var args = vm._bindDir.calls.argsFor(0)
|
|
|
expect(args[0]).toBe('prop')
|
|
|
expect(args[1]).toBe(null)
|
|
|
- expect(args[2].arg).toBe('someAttr')
|
|
|
- expect(args[2].expression).toBe('a')
|
|
|
+ expect(args[2].path).toBe('someAttr')
|
|
|
+ expect(args[2].parentPath).toBe('a')
|
|
|
expect(args[3]).toBe(def)
|
|
|
// multiple-attrs
|
|
|
args = vm._bindDir.calls.argsFor(1)
|
|
|
expect(args[0]).toBe('prop')
|
|
|
expect(args[1]).toBe(null)
|
|
|
- expect(args[2].arg).toBe('multipleAttrs')
|
|
|
- expect(args[2].expression).toBe('"a "+(b)+" c"')
|
|
|
+ expect(args[2].path).toBe('multipleAttrs')
|
|
|
+ expect(args[2].parentPath).toBe('"a "+(b)+" c"')
|
|
|
expect(args[3]).toBe(def)
|
|
|
- // oneway
|
|
|
+ // one time
|
|
|
args = vm._bindDir.calls.argsFor(2)
|
|
|
expect(args[0]).toBe('prop')
|
|
|
expect(args[1]).toBe(null)
|
|
|
- expect(args[2].arg).toBe('oneway')
|
|
|
- expect(args[2].oneWay).toBe(true)
|
|
|
- expect(args[2].expression).toBe('a')
|
|
|
+ expect(args[2].path).toBe('onetime')
|
|
|
+ expect(args[2].oneTime).toBe(true)
|
|
|
+ expect(args[2].parentPath).toBe('a')
|
|
|
expect(args[3]).toBe(def)
|
|
|
- // with-filter
|
|
|
+ // one way up
|
|
|
args = vm._bindDir.calls.argsFor(3)
|
|
|
expect(args[0]).toBe('prop')
|
|
|
expect(args[1]).toBe(null)
|
|
|
- expect(args[2].arg).toBe('withFilter')
|
|
|
- expect(args[2].expression).toBe('this._applyFilters(a,null,[{"name":"filter"}],false)')
|
|
|
+ expect(args[2].path).toBe('onewayUp')
|
|
|
+ expect(args[2].oneWayUp).toBe(true)
|
|
|
+ expect(args[2].oneWayDown).toBe(false)
|
|
|
+ expect(args[2].parentPath).toBe('a')
|
|
|
expect(args[3]).toBe(def)
|
|
|
- // boolean-literal
|
|
|
+ // one way down
|
|
|
args = vm._bindDir.calls.argsFor(4)
|
|
|
expect(args[0]).toBe('prop')
|
|
|
expect(args[1]).toBe(null)
|
|
|
- expect(args[2].arg).toBe('booleanLiteral')
|
|
|
- expect(args[2].expression).toBe('true')
|
|
|
- expect(args[2].oneWay).toBe(true)
|
|
|
+ expect(args[2].path).toBe('onewayDown')
|
|
|
+ expect(args[2].oneWayUp).toBe(false)
|
|
|
+ expect(args[2].oneWayDown).toBe(true)
|
|
|
+ expect(args[2].parentPath).toBe('a')
|
|
|
+ expect(args[3]).toBe(def)
|
|
|
+ // with-filter
|
|
|
+ args = vm._bindDir.calls.argsFor(5)
|
|
|
+ expect(args[0]).toBe('prop')
|
|
|
+ expect(args[1]).toBe(null)
|
|
|
+ expect(args[2].path).toBe('withFilter')
|
|
|
+ expect(args[2].parentPath).toBe('this._applyFilters(a,null,[{"name":"filter"}],false)')
|
|
|
+ expect(args[3]).toBe(def)
|
|
|
+ // boolean-literal
|
|
|
+ args = vm._bindDir.calls.argsFor(6)
|
|
|
+ expect(args[0]).toBe('prop')
|
|
|
+ expect(args[1]).toBe(null)
|
|
|
+ expect(args[2].path).toBe('booleanLiteral')
|
|
|
+ expect(args[2].parentPath).toBe('true')
|
|
|
+ expect(args[2].oneTime).toBe(true)
|
|
|
// camelCase should've warn
|
|
|
expect(hasWarned(_, 'using camelCase')).toBe(true)
|
|
|
// literal and one time should've called vm.$set
|
|
|
@@ -408,4 +430,4 @@ if (_.inBrowser) {
|
|
|
})
|
|
|
|
|
|
})
|
|
|
-}
|
|
|
+}
|