Skip to content

Commit

Permalink
feat(syntax): tokenize capture event binding
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Lieben committed May 7, 2017
1 parent da1a0a6 commit 2662c01
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 14 deletions.
2 changes: 1 addition & 1 deletion syntaxes/html.json
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@
}
},
"tag-aurelia-attribute-with-invoke-attribute": {
"match": "(?=\\s)[^=](([a-zA-Z0-9:-]+)(\\.)(trigger|delegate|call))",
"match": "(?=\\s)[^=](([a-zA-Z0-9:-]+)(\\.)(trigger|delegate|call|capture))",
"captures": {
"2": {
"name": "entity.other.attribute-name.html"
Expand Down
41 changes: 28 additions & 13 deletions test/syntax.html/invoke.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,46 +31,61 @@ describe('The Aurelia HTML syntax invoke attributes', () => {

});

it('must not tokenize attribute body that contains click.trigger keyword', () => {
it('must tokenize delegate attribute with scope "invoke.attribute.html.au"', () => {

// arrange-
let scope = 'meta.tag.block.any.html';
// arrange
let scope = 'invoke.attribute.html.au';

// act
let lineToken = tokenizeLine('<div value.bind="click.trigger">');
let lineToken = tokenizeLine('<div click.delegate="test()">');

// assert
let token = getTokenOnCharRange(lineToken, 17, 30);
let token = getTokenOnCharRange(lineToken, 11, 19);
assert.isOk(hasScope(token.scopes, scope));

});

it('must not tokenize invokes in attribute body with scope "invoke.attribute.html.au"', () => {
it('must tokenize capture attribute with scope "invoke.attribute.html.au"', () => {

// arrange
let scope = 'meta.tag.inline.any.html';
let scope = 'invoke.attribute.html.au';

// act
let lineToken = tokenizeLine('<a b="draw.call:animate(data)">');
let lineToken = tokenizeLine('<div click.capture="test()">');

// assert
let token = getTokenOnCharRange(lineToken, 6, 29);
let token = getTokenOnCharRange(lineToken, 11, 18);
assert.isOk(hasScope(token.scopes, scope));

});

it('must not tokenize attribute body that contains click.trigger keyword', () => {

// arrange-
let scope = 'meta.tag.block.any.html';

// act
let lineToken = tokenizeLine('<div value.bind="click.trigger">');

// assert
let token = getTokenOnCharRange(lineToken, 17, 30);
assert.isOk(hasScope(token.scopes, scope));

});

it('must tokenize delegate attribute with scope "invoke.attribute.html.au"', () => {
it('must not tokenize invokes in attribute body with scope "invoke.attribute.html.au"', () => {

// arrange
let scope = 'invoke.attribute.html.au';
let scope = 'meta.tag.inline.any.html';

// act
let lineToken = tokenizeLine('<div click.delegate="test()">');
let lineToken = tokenizeLine('<a b="draw.call:animate(data)">');

// assert
let token = getTokenOnCharRange(lineToken, 11, 19);
let token = getTokenOnCharRange(lineToken, 6, 29);
assert.isOk(hasScope(token.scopes, scope));

});


});

0 comments on commit 2662c01

Please sign in to comment.