Skip to content
This repository was archived by the owner on Apr 30, 2018. It is now read-only.

Commit aaa767c

Browse files
author
Kent C. Dodds
committed
fix(ngModelAttrsManipulator): Override existing attributes
If you're explicitly specifying then it's likely you'll want to override exisitng attributes in the template. This should have been the default. BREAKING CHANGE: If you were depending on the behavior before of not overriding existing properties, this will break you.
1 parent 33ae9c6 commit aaa767c

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/run/formlyNgModelAttrsManipulator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ function addFormlyNgModelAttrsManipulator(formlyConfig, $interpolate, formlyWarn
127127

128128
function addNgModelElAttrs() {
129129
angular.forEach(options.ngModelElAttrs, (val, name) => {
130-
addIfNotPresent(modelNodes, name, val);
130+
addRegardlessOfPresence(modelNodes, name, val);
131131
});
132132
}
133133
}

src/run/formlyNgModelAttrsManipulator.test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,14 @@ describe('formlyNgModelAttrsManipulator', () => {
362362
).to.equal('{{::to.bar}}');
363363

364364
});
365+
366+
it(`should override existing attributes`, () => {
367+
field.ngModelElAttrs = {
368+
'ng-model': 'formState.foo.bar'
369+
};
370+
manipulate();
371+
expect(resultEl.attr('ng-model')).to.equal('formState.foo.bar');
372+
});
365373
});
366374

367375

0 commit comments

Comments
 (0)