Permalink
Browse files

fix(SyntaxInterpreter): fix defaultBindingMode condition

  • Loading branch information...
bigopon authored and jdanyow committed Sep 23, 2017
1 parent 23938a6 commit c1a9792a7fd7953dd6c0ca1899d0dc02ecccd1da
Showing with 23 additions and 1 deletion.
  1. +3 −1 src/syntax-interpreter.js
  2. +20 −0 test/syntax-interpreter.spec.js
@@ -66,7 +66,9 @@ export class SyntaxInterpreter {
this.observerLocator,
this.attributeMap.map(element.tagName, info.attrName),
this.parser.parse(info.attrValue),
info.defaultBindingMode || this.determineDefaultBindingMode(element, info.attrName, context),
info.defaultBindingMode === undefined || info.defaultBindingMode === null
? this.determineDefaultBindingMode(element, info.attrName, context)
: info.defaultBindingMode,
resources.lookupFunctions
);
@@ -1,4 +1,5 @@
import './setup';
import {AttributeMap} from '../src/attribute-map';
import {SyntaxInterpreter} from '../src/syntax-interpreter';
import {
Parser,
@@ -11,6 +12,9 @@ import {
bindingMode
} from 'aurelia-binding';
import {DOM} from 'aurelia-pal';
import {
ViewResources
} from 'aurelia-templating';
export function createElement(html) {
let div = DOM.createElement('div');
@@ -112,6 +116,22 @@ describe('SyntaxInterpreter', () => {
expect(interpreter.determineDefaultBindingMode(el, 'undefined', context)).toBe(bindingMode.oneWay);
expect(interpreter.determineDefaultBindingMode(el, 'missing', context)).toBe(bindingMode.oneWay);
});
it('uses specified defaultBindingMode in `bind` method', () => {
interpreter.attributeMap = new AttributeMap();
interpreter.attributeMap.svg = {
isStandardSvgAttribute: () => false
}
let element = document.createElement('input');
let attrName = 'value';
let info = {
attrName: attrName,
attrValue: 'bar',
defaultBindingMode: bindingMode.oneTime
}
let instruction = interpreter.bind(new ViewResources(), element, info);
expect(instruction.attributes[attrName].mode).toBe(bindingMode.oneTime);
});
});
describe('for', () => {

0 comments on commit c1a9792

Please sign in to comment.