Skip to content

Commit

Permalink
fix(syntax): don't tokenize word ref inside body of attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
erik-lieben committed Oct 9, 2016
1 parent f0950fb commit b5259ca
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
11 changes: 9 additions & 2 deletions syntaxes/html.json
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,10 @@
},
{
"include": "#tag-aurelia-attribute-with-invoke-attribute"
},
},
{
"include": "#tag-aurelia-ref-attribute"
},
{
"include": "#tag-aurelia-attribute"
},
Expand Down Expand Up @@ -373,8 +376,12 @@
"match": "(?<=[^=])\\b([a-zA-Z0-9:-]+)",
"name": "entity.other.attribute-name.html"
},
"tag-aurelia-ref-attribute": {
"match": "\\bref\\b",
"name": "ref.attribute.html.au"
},
"tag-aurelia-attribute": {
"match": "[^=]\\b(as-element|replaceable|replace-part|view|ref)",
"match": "[^=-]\\b(as-element|replace-part|view|replaceable)",
"name": "attribute.html.au"
},
"string-double-quoted": {
Expand Down
28 changes: 28 additions & 0 deletions test/syntax.html/ref.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,32 @@ describe('The Aurelia HTML syntax ref attribute', () => {

});

it('must tokenize ref attribute with scope "ref.attribute.html.au"', () => {

// arrange
let scope = 'ref.attribute.html.au';

// act
let lineToken = tokenizeLine('<div ref="foo">');

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

});

it('must not tokenize ref part in body of other attribute', () => {

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

// act
let lineToken = tokenizeLine('<meta name="referrer" content="origin-when-crossorigin">');

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

});

});

0 comments on commit b5259ca

Please sign in to comment.