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

Commit d521c7e

Browse files
committed
v7.3.6
2 parents 9696fc9 + a053c0d commit d521c7e

File tree

6 files changed

+95
-17
lines changed

6 files changed

+95
-17
lines changed

dist/formly.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* angular-formly JavaScript Library v7.3.5
2+
* angular-formly JavaScript Library v7.3.6
33
*
44
* @license MIT (http://license.angular-formly.com)
55
*
@@ -153,7 +153,7 @@ return /******/ (function(modules) { // webpackBootstrap
153153

154154
ngModule.constant('formlyApiCheck', _providersFormlyApiCheck2['default']);
155155
ngModule.constant('formlyErrorAndWarningsUrlPrefix', _otherDocsBaseUrl2['default']);
156-
ngModule.constant('formlyVersion', ("7.3.5")); // <-- webpack variable
156+
ngModule.constant('formlyVersion', ("7.3.6")); // <-- webpack variable
157157

158158
ngModule.provider('formlyUsability', _providersFormlyUsability2['default']);
159159
ngModule.provider('formlyConfig', _providersFormlyConfig2['default']);
@@ -424,7 +424,7 @@ return /******/ (function(modules) { // webpackBootstrap
424424
Object.defineProperty(exports, "__esModule", {
425425
value: true
426426
});
427-
exports["default"] = "https://github.com/formly-js/angular-formly/blob/" + ("7.3.5") + "/other/ERRORS_AND_WARNINGS.md#";
427+
exports["default"] = "https://github.com/formly-js/angular-formly/blob/" + ("7.3.6") + "/other/ERRORS_AND_WARNINGS.md#";
428428
module.exports = exports["default"];
429429

430430
/***/ },
@@ -1220,7 +1220,7 @@ return /******/ (function(modules) { // webpackBootstrap
12201220

12211221
// @ngInject
12221222
function FormlyFieldController($scope, $timeout, $parse, $controller, formlyValidationMessages) {
1223-
/* eslint max-statements:[2, 31] */
1223+
/* eslint max-statements:[2, 32] */
12241224
if ($scope.options.fieldGroup) {
12251225
setupFieldGroup();
12261226
return;
@@ -1267,13 +1267,17 @@ return /******/ (function(modules) { // webpackBootstrap
12671267
return parseGet($scope.options.key, $scope.model);
12681268
}
12691269

1270+
function shouldNotUseParseKey(key) {
1271+
return _angularFix2['default'].isNumber(key) || /^\d/.test(key) && key.indexOf('[') === -1;
1272+
}
1273+
12701274
function parseSet(key, model, newVal) {
12711275
// If either of these are null/undefined then just return undefined
12721276
if (!key || !model) {
12731277
return;
12741278
}
12751279
// If we are working with a number then $parse wont work, default back to the old way for now
1276-
if (_angularFix2['default'].isNumber(key)) {
1280+
if (shouldNotUseParseKey(key)) {
12771281
// TODO: Fix this so we can get several levels instead of just one with properties that are numeric
12781282
model[key] = newVal;
12791283
} else {
@@ -1291,7 +1295,7 @@ return /******/ (function(modules) { // webpackBootstrap
12911295
}
12921296

12931297
// If we are working with a number then $parse wont work, default back to the old way for now
1294-
if (_angularFix2['default'].isNumber(key)) {
1298+
if (shouldNotUseParseKey(key)) {
12951299
// TODO: Fix this so we can get several levels instead of just one with properties that are numeric
12961300
return model[key];
12971301
} else {

dist/formly.min.js

Lines changed: 10 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/formly.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-formly",
3-
"version": "7.3.5",
3+
"version": "7.3.6",
44
"author": "Astrism <[email protected]>",
55
"contributors": [
66
"Astrism <[email protected]>",

src/directives/formly-field.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function formlyField($http, $q, $compile, $templateCache, $interpolate, formlyCo
3535

3636
// @ngInject
3737
function FormlyFieldController($scope, $timeout, $parse, $controller, formlyValidationMessages) {
38-
/* eslint max-statements:[2, 31] */
38+
/* eslint max-statements:[2, 32] */
3939
if ($scope.options.fieldGroup) {
4040
setupFieldGroup()
4141
return
@@ -82,13 +82,17 @@ function formlyField($http, $q, $compile, $templateCache, $interpolate, formlyCo
8282
return parseGet($scope.options.key, $scope.model)
8383
}
8484

85+
function shouldNotUseParseKey(key) {
86+
return angular.isNumber(key) || (/^\d/.test(key) && key.indexOf('[') === -1)
87+
}
88+
8589
function parseSet(key, model, newVal) {
8690
// If either of these are null/undefined then just return undefined
8791
if (!key || !model) {
8892
return
8993
}
9094
// If we are working with a number then $parse wont work, default back to the old way for now
91-
if (angular.isNumber(key)) {
95+
if (shouldNotUseParseKey(key)) {
9296
// TODO: Fix this so we can get several levels instead of just one with properties that are numeric
9397
model[key] = newVal
9498
} else {
@@ -106,7 +110,7 @@ function formlyField($http, $q, $compile, $templateCache, $interpolate, formlyCo
106110
}
107111

108112
// If we are working with a number then $parse wont work, default back to the old way for now
109-
if (angular.isNumber(key)) {
113+
if (shouldNotUseParseKey(key)) {
110114
// TODO: Fix this so we can get several levels instead of just one with properties that are numeric
111115
return model[key]
112116
} else {

src/directives/formly-field.test.js

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,72 @@ describe('formly-field', function() {
519519
})
520520
})
521521

522+
describe('getterSetters', () => {
523+
it('should get and set values when key is all alpha', () => {
524+
const key = 'foo'
525+
const defaultValue = 'bar'
526+
527+
scope.fields = [
528+
{template: input, key, defaultValue},
529+
]
530+
scope.model = {}
531+
532+
compileAndDigest()
533+
expect(scope.model[key]).to.eq(defaultValue)
534+
})
535+
536+
it('should get and set values when key is all numeric', () => {
537+
const key = '1333'
538+
const defaultValue = 'bar'
539+
540+
scope.fields = [
541+
{template: input, key, defaultValue},
542+
]
543+
scope.model = {}
544+
545+
compileAndDigest()
546+
expect(scope.model[key]).to.eq(defaultValue)
547+
})
548+
549+
it('should get and set values when key is alpha numeric with alpha first', () => {
550+
const key = 'A1'
551+
const defaultValue = 'bar'
552+
553+
scope.fields = [
554+
{template: input, key, defaultValue},
555+
]
556+
scope.model = {}
557+
558+
compileAndDigest()
559+
expect(scope.model[key]).to.eq(defaultValue)
560+
})
561+
562+
it('should get and set values when key is alpha numeric with numeric first', () => {
563+
const key = '1A'
564+
const defaultValue = 'bar'
565+
566+
scope.fields = [
567+
{template: input, key, defaultValue},
568+
]
569+
scope.model = {}
570+
571+
compileAndDigest()
572+
expect(scope.model[key]).to.eq(defaultValue)
573+
})
574+
575+
it('should work with nested keys with numbers in the key', () => {
576+
const key = 'foo3bar.baz4foobar'
577+
const defaultValue = 'baz'
578+
scope.fields = [
579+
{template: input, key, defaultValue},
580+
]
581+
scope.model = {}
582+
583+
compileAndDigest()
584+
expect(scope.model.foo3bar.baz4foobar).to.equal(defaultValue)
585+
})
586+
})
587+
522588
describe(`id property`, () => {
523589
it(`should default to a semi-random id that you cannot rely on and don't have to think about`, () => {
524590
scope.fields = [getNewField()]

0 commit comments

Comments
 (0)