Skip to content

Commit

Permalink
fix(core/directives/directive_provider): fix regexp to allow more att…
Browse files Browse the repository at this point in the history
…ributes within @HostListener (#78)
  • Loading branch information
elmariofredo authored and Hotell committed May 6, 2016
1 parent dc68889 commit 92bd0a3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/directives/directive_provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ export class DirectiveProvider {
const cbString = hostListener[ eventKey ];
// here we parse out callback method and its argument to separate strings
// - for instance we got from 'onMove($event.target)' --> 'onMove','$event.target'
const [,cbMethodName,cbMethodArgs] = /^(\w+)\(([$\w.,]*)\)$/.exec( cbString );
const [,cbMethodName,cbMethodArgs] = /^(\w+)\(([$\w.\s,]*)\)$/.exec( cbString );
const eventValue = [
cbMethodName,
// filter out empty values and trim values
Expand Down
4 changes: 4 additions & 0 deletions test/core/directives/directive_provider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,8 @@ describe( `directives/directive_provider`, ()=> {
'[attr.aria-label]': 'ariaLabel',
'[readonly]': 'isReadonly',
'(mousemove)': 'onMove($event.target)',
'(mouseenter)': 'onMouseEnter($event.clientX,$event.clientY)',
'(mouseleave)': 'onMouseLeave($event.clientX, $event.clientY)',
'(mouseout)': 'onMoveOut()',
'(document: click)': 'onDocumentClick()',
'(window : resize)': 'onWindowResize()',
Expand All @@ -711,6 +713,8 @@ describe( `directives/directive_provider`, ()=> {
},
hostListeners: {
'mousemove': [ 'onMove', '$event.target' ],
'mouseenter': [ 'onMouseEnter', '$event.clientX', '$event.clientY' ],
'mouseleave': [ 'onMouseLeave', '$event.clientX', '$event.clientY' ],
'mouseout': [ 'onMoveOut' ],
'document:click': [ 'onDocumentClick' ],
'window:resize': [ 'onWindowResize' ],
Expand Down

0 comments on commit 92bd0a3

Please sign in to comment.