Skip to content

Commit

Permalink
Merge pull request #38 from AlexWayfer/allow-spaces-for-parsing
Browse files Browse the repository at this point in the history
feat: Allow whitespaces in bindingsParser
finom authored Oct 2, 2016

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents 1defba7 + 9bd0c28 commit 2320f50
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/parsebindings/_parserdata.js
Original file line number Diff line number Diff line change
@@ -33,11 +33,11 @@ calc(parserData, {
},
bindingReg: {
source: ['escLeftBracket', 'escRightBracket'],
handler: (left, right) => new RegExp(`${left}(.+?)${right}`, 'g')
handler: (left, right) => new RegExp(`${left}\\s*(.+?)\\s*${right}`, 'g')
},
strictBindingReg: {
source: ['escLeftBracket', 'escRightBracket'],
handler: (left, right) => new RegExp(`^${left}(.+?)${right}$`, 'g')
handler: (left, right) => new RegExp(`^${left}\\s*(.+?)\\s*${right}$`, 'g')
}
}, {
debounceCalc: false // we need to get new regexps immediately when brackets are changed
9 changes: 9 additions & 0 deletions test/spec/bindings/bindings_parser_spec.js
Original file line number Diff line number Diff line change
@@ -24,6 +24,15 @@ describe('Bindings parser', () => {
expect(node.textContent).toEqual(obj.x);
});

it('should parse inner content with spaces', () => {
const node = parse('<span>{{ x }}</span>');
const obj = {};

parseBindings(obj, node, noDebounceFlag);
obj.x = 'foo';
expect(node.textContent).toEqual(obj.x);
});

it('should parse inner content and keep node empty if property value is not given', () => {
const node = parse('<span>{{x}}</span>');
const obj = {};

0 comments on commit 2320f50

Please sign in to comment.