Skip to content

Commit b5c731d

Browse files
fix(component): Do not throw err when component has & binding
Closes #3099
1 parent 126a4ad commit b5c731d

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/ng1/statebuilders/views.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ const scopeBindings = (bindingsObj: Obj) => Object.keys(bindingsObj || {})
8888
// [ 'input', [ '=foo', '=', 'foo' ] ]
8989
.map(key => [key, /^([=<@])[?]?(.*)/.exec(bindingsObj[key])])
9090
// skip malformed values
91-
.filter(tuple => isDefined(tuple) && isDefined(tuple[1]))
91+
.filter(tuple => isDefined(tuple) && isArray(tuple[1]))
9292
// { name: ('foo' || 'input'), type: '=' }
9393
.map(tuple => ({ name: tuple[1][2] || tuple[0], type: tuple[1][1] } as BindingTuple));
9494

test/viewDirectiveSpec.js

+17
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,11 @@ describe('angular 1.5+ style .component()', function() {
832832
bindings: { oneway: '<?oneway', twoway: '=?', attribute: '@?attr' },
833833
template: '-{{ $ctrl.oneway }},{{ $ctrl.twoway }},{{ $ctrl.attribute }}-'
834834
});
835+
836+
app.component('eventComponent', {
837+
bindings: { evt: '&' },
838+
template: 'eventCmp',
839+
});
835840
}
836841
}));
837842

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

10581063
expect(el.text()).toBe('-ONEWAY,TWOWAY,ATTRIBUTE-');
10591064
});
1065+
1066+
// Test for #3099
1067+
it('should not throw when routing to a component with output "&" binding', function () {
1068+
$stateProvider.state('nothrow', {
1069+
component: 'eventComponent',
1070+
});
1071+
1072+
var $state = svcs.$state, $q = svcs.$q;
1073+
$state.transitionTo('nothrow'); $q.flush();
1074+
1075+
expect(el.text()).toBe('eventCmp');
1076+
});
10601077
}
10611078
});
10621079

0 commit comments

Comments
 (0)