Permalink
Browse files

fix(component): Do not throw err when component has `&` binding

Closes #3099
  • Loading branch information...
1 parent 126a4ad commit b5c731deb01b304565c670bfc53946340cce1f29 @christopherthielen christopherthielen committed Nov 5, 2016
Showing with 18 additions and 1 deletion.
  1. +1 −1 src/ng1/statebuilders/views.ts
  2. +17 −0 test/viewDirectiveSpec.js
@@ -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));
@@ -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',
+ });
}
}));
@@ -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');
+ });
}
});

0 comments on commit b5c731d

Please sign in to comment.