Skip to content

Commit

Permalink
fix(component): Do not throw err when component has & binding
Browse files Browse the repository at this point in the history
Closes #3099
  • Loading branch information
christopherthielen committed Nov 5, 2016
1 parent 126a4ad commit b5c731d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ng1/statebuilders/views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const scopeBindings = (bindingsObj: Obj) => Object.keys(bindingsObj || {})
// [ 'input', [ '=foo', '=', 'foo' ] ]
.map(key => [key, /^([=<@])[?]?(.*)/.exec(bindingsObj[key])])
// skip malformed values
.filter(tuple => isDefined(tuple) && isDefined(tuple[1]))
.filter(tuple => isDefined(tuple) && isArray(tuple[1]))
// { name: ('foo' || 'input'), type: '=' }
.map(tuple => ({ name: tuple[1][2] || tuple[0], type: tuple[1][1] } as BindingTuple));

Expand Down
17 changes: 17 additions & 0 deletions test/viewDirectiveSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,11 @@ describe('angular 1.5+ style .component()', function() {
bindings: { oneway: '<?oneway', twoway: '=?', attribute: '@?attr' },
template: '-{{ $ctrl.oneway }},{{ $ctrl.twoway }},{{ $ctrl.attribute }}-'
});

app.component('eventComponent', {
bindings: { evt: '&' },
template: 'eventCmp',
});
}
}));

Expand Down Expand Up @@ -1057,6 +1062,18 @@ describe('angular 1.5+ style .component()', function() {

expect(el.text()).toBe('-ONEWAY,TWOWAY,ATTRIBUTE-');
});

// Test for #3099
it('should not throw when routing to a component with output "&" binding', function () {
$stateProvider.state('nothrow', {
component: 'eventComponent',
});

var $state = svcs.$state, $q = svcs.$q;
$state.transitionTo('nothrow'); $q.flush();

expect(el.text()).toBe('eventCmp');
});
}
});

Expand Down

0 comments on commit b5c731d

Please sign in to comment.